mirror of
https://github.com/brl/mutter.git
synced 2025-02-05 08:04:10 +00:00
tests/wayland/buffer-transform: Use WaylandBuffer
The custom drawing requires adjusting the test. Instead of poking at memory directly, we can just draw a color at certain coordinates which makes it independent of the pixel format used. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3350>
This commit is contained in:
parent
145649538a
commit
d842fe601d
@ -94,16 +94,17 @@ draw_main (void)
|
|||||||
static uint32_t color1 = 0xff00ffff;
|
static uint32_t color1 = 0xff00ffff;
|
||||||
static uint32_t color2 = 0xffff00ff;
|
static uint32_t color2 = 0xffff00ff;
|
||||||
static uint32_t color3 = 0xffffff00;
|
static uint32_t color3 = 0xffffff00;
|
||||||
struct wl_buffer *buffer;
|
WaylandBuffer *buffer;
|
||||||
void *buffer_data;
|
int x, y;
|
||||||
uint32_t *pixels;
|
|
||||||
int x, y, size;
|
|
||||||
|
|
||||||
if (!create_shm_buffer (display, window_width, window_height,
|
buffer = wayland_buffer_create (display, NULL,
|
||||||
&buffer, &buffer_data, &size))
|
window_width, window_height,
|
||||||
g_error ("Failed to create shm buffer");
|
DRM_FORMAT_XRGB8888,
|
||||||
|
NULL, 0,
|
||||||
|
GBM_BO_USE_LINEAR);
|
||||||
|
if (!buffer)
|
||||||
|
g_error ("Failed to create buffer");
|
||||||
|
|
||||||
pixels = buffer_data;
|
|
||||||
for (y = 0; y < window_height; y++)
|
for (y = 0; y < window_height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < window_width; x++)
|
for (x = 0; x < window_width; x++)
|
||||||
@ -125,11 +126,11 @@ draw_main (void)
|
|||||||
current_color = color3;
|
current_color = color3;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixels[y * window_width + x] = current_color;
|
wayland_buffer_draw_pixel (buffer, x, y, current_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_attach (surface, buffer, 0, 0);
|
wl_surface_attach (surface, wayland_buffer_get_wl_buffer (buffer), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user