Skip to content

Commit 7553e86

Browse files
committed
Update Container.Size
1 parent e2c629d commit 7553e86

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

modules/Window/Wayland.mpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export module CppUtils.Window.Wayland;
1717

1818
import std;
1919

20-
import CppUtils.Container.Size2d;
20+
import CppUtils.Container.Size;
2121
import CppUtils.Logger;
2222
import CppUtils.Memory;
2323
import CppUtils.String;

modules/Window/Window.mpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export module CppUtils.Window;
1919

2020
import std;
2121

22-
import CppUtils.Container.Size2d;
22+
import CppUtils.Container.Size;
2323
import CppUtils.Logger;
2424
import CppUtils.Memory;
2525
import CppUtils.String;
@@ -116,11 +116,11 @@ namespace CppUtils::Window
116116
{
117117
inline ImageStorage() = default;
118118

119-
inline explicit ImageStorage(Container::Size2d<std::size_t> size):
119+
inline explicit ImageStorage(Container::Size2 size):
120120
m_size{std::move(size)}
121121
{
122-
const auto strideSize = m_size.width * Wayland::bytesPerPixel;
123-
const auto screenBufferSize = strideSize * m_size.height;
122+
const auto strideSize = m_size.width() * Wayland::bytesPerPixel;
123+
const auto screenBufferSize = strideSize * m_size.height();
124124
const auto bufferSize = screenBufferSize * 3; // triple buffering
125125

126126
m_fileDescriptor = System::FileDescriptor{System::allocateSharedMemory(bufferSize, "WaylandBuffer").value()};
@@ -130,8 +130,8 @@ namespace CppUtils::Window
130130
wl_shm_pool_create_buffer(
131131
pool.get(),
132132
static_cast<std::int32_t>(screenBufferSize * 0),
133-
static_cast<std::int32_t>(m_size.width),
134-
static_cast<std::int32_t>(m_size.height),
133+
static_cast<std::int32_t>(m_size.width()),
134+
static_cast<std::int32_t>(m_size.height()),
135135
static_cast<std::int32_t>(strideSize),
136136
WL_SHM_FORMAT_ARGB8888)); // WL_SHM_FORMAT_XRGB8888
137137

@@ -147,7 +147,7 @@ namespace CppUtils::Window
147147
}
148148

149149
private:
150-
Container::Size2d<std::size_t> m_size;
150+
Container::Size2 m_size;
151151
System::FileDescriptor m_fileDescriptor;
152152

153153
public:
@@ -200,7 +200,7 @@ namespace CppUtils::Window
200200
#if defined(OS_WINDOWS)
201201
auto hInstance = GetModuleHandleA(nullptr);
202202
m_window = CreateWindowEx(
203-
0, windowClassName, m_title.c_str(), generateStyle(m_style), CW_USEDEFAULT, CW_USEDEFAULT, size.width, size.height, nullptr, nullptr, hInstance, nullptr);
203+
0, windowClassName, m_title.c_str(), generateStyle(m_style), CW_USEDEFAULT, CW_USEDEFAULT, m_size.width(), m_size.height(), nullptr, nullptr, hInstance, nullptr);
204204
if (m_window == nullptr)
205205
return std::unexpected{"Window creation failed."sv};
206206
#elif defined(OS_LINUX)
@@ -218,7 +218,7 @@ namespace CppUtils::Window
218218
}
219219

220220
public:
221-
inline Window(std::string title, Container::Size2d<std::size_t> size, Style style = Style{Style::IsMinimizable | Style::IsCloseable}):
221+
inline Window(std::string title, Container::Size2 size, Style style = Style{Style::IsMinimizable | Style::IsCloseable}):
222222
m_title{std::move(title)},
223223
m_style{style},
224224
m_size{size}
@@ -257,7 +257,7 @@ namespace CppUtils::Window
257257
return m_title;
258258
}
259259

260-
inline auto setSize(Container::Size2d<std::size_t> size) noexcept -> void
260+
inline auto setSize(Container::Size2 size) noexcept -> void
261261
{
262262
m_size = size;
263263
}
@@ -292,7 +292,7 @@ namespace CppUtils::Window
292292
private:
293293
std::string m_title;
294294
[[maybe_unused]] Style m_style;
295-
Container::Size2d<std::size_t> m_size;
295+
Container::Size2 m_size;
296296
#if defined(OS_WINDOWS)
297297
static inline constexpr auto windowClassName = L"Window";
298298
HWND m_window;
@@ -316,13 +316,13 @@ namespace CppUtils::Window
316316
window.m_imageStorage = Window::ImageStorage{imageSize};
317317
}
318318
auto* pixels = window.getPixels();
319-
for (auto y = 0uz; y < imageSize.height; ++y)
319+
for (auto y = 0uz; y < imageSize.height(); ++y)
320320
{
321-
for (auto x = 0uz; x < imageSize.width; ++x)
321+
for (auto x = 0uz; x < imageSize.width(); ++x)
322322
if ((x + y / 8 * 8) % 16 < 8)
323-
pixels[y * imageSize.width + x] = 0xFF'66'66'66;
323+
pixels[y * imageSize.width() + x] = 0xFF'66'66'66;
324324
else
325-
pixels[y * imageSize.width + x] = 0xFF'EE'EE'EE;
325+
pixels[y * imageSize.width() + x] = 0xFF'EE'EE'EE;
326326
}
327327
}
328328

0 commit comments

Comments
 (0)