Clean image types

This commit is contained in:
James Grogan 2022-11-11 16:32:55 +00:00
parent e7683cd94e
commit c6d03f16d0
18 changed files with 169 additions and 107 deletions

View file

@ -1,9 +1,10 @@
#include "WaylandSurface.h"
#include "WaylandEglWindowInterface.h"
#include "ImagePrimitives.h"
WaylandSurface::WaylandSurface(mt::Window* window)
: mWindow(window)
: IPlatformWindow(window)
{
}
@ -36,17 +37,22 @@ void WaylandSurface::initialize(wl_compositor* compositor, xdg_wm_base* xdg_wm_b
mXdgTopLevel = xdg_surface_get_toplevel(mXdgSurface);
xdg_toplevel_set_title(mXdgTopLevel, "Example client");
wl_surface_commit(mSurface);
auto region = wl_compositor_create_region(compositor);
wl_region_add(region, 0, 0, mWindow->GetWidth(), mWindow->GetHeight());
wl_surface_set_opaque_region(mSurface, region);
wl_surface_commit(mSurface);
}
void WaylandSurface::onConfigure(xdg_surface *xdg_surface, uint32_t serial)
{
xdg_surface_ack_configure(xdg_surface, serial);
paint(nullptr);
}
void WaylandSurface::paint(mt::Screen* screen)
{
if (mEglWindowInterface)
{
mEglWindowInterface->initialize(mSurface, mWindow->GetWidth(), mWindow->GetHeight());
@ -77,29 +83,11 @@ wl_buffer* WaylandSurface::drawFrame()
mBuffer->setUpPool(shm_pool_size, width, height, stride);
int offset = 0;
drawCheckerboard(width, height, offset);
ImagePrimitives::drawCheckerboard(mBuffer->getPoolData(), width, height, offset);
mBuffer->tearDownPool(shm_pool_size);
return mBuffer->getWorkingBuffer();
}
void WaylandSurface::drawCheckerboard(int width, int height, int offset)
{
uint32_t *pixels = (uint32_t *)&(mBuffer->getPoolData())[offset];
for (int y = 100; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
if ((x + y / 8 * 8) % 16 < 8)
{
pixels[y * width + x] = 0xFF666666;
}
else
{
pixels[y * width + x] = 0xFFEEEEEE;
}
}
}
}

View file

@ -7,6 +7,8 @@
#include "SharedMemory.h"
#include "WaylandBuffer.h"
#include "IPlatformWindow.h"
struct wl_surface;
struct xdg_surface;
struct xdg_toplevel;
@ -14,7 +16,7 @@ struct xdg_toplevel;
class WaylandEglInterface;
class WaylandEglWindowInterface;
class WaylandSurface
class WaylandSurface : public IPlatformWindow
{
public:
@ -28,9 +30,24 @@ public:
wl_buffer* drawFrame();
void drawCheckerboard(int width, int height, int offset);
void show() const
{
map();
}
void map() const
{
}
void clear() const
{
}
private:
void paint(mt::Screen* screen) override;
mt::Window* mWindow{nullptr};
wl_surface* mSurface{nullptr};