diff options
author | Neil Roberts <neil@linux.intel.com> | 2013-11-25 17:04:16 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2013-11-28 18:12:22 +0000 |
commit | a29b8c475e778f91fca3f6c4e6ef07e1786ae35f (patch) | |
tree | ea7f4284af3e3bc472e8e2de42f9505e6983d2ee /examples | |
parent | 5ef1020e8a33cc6e30a60cb472802f20c6db1245 (diff) |
wayland: Add a convenience function to update a region from SHM buffer
Adds cogl_wayland_texture_set_region_from_shm_buffer which is a
convenience wrapper around cogl_texture_set_region but it uses the
correct format to copy the data from a Wayland SHM buffer. This will
typically be used by compositors to update the texture for a surface
when an SHM buffer is attached. The ordering of the arguments is based
on cogl_texture_set_region_from_bitmap.
Based on a patch by Jasper St. Pierre.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit c76c1d136d2cac7f3d1331a4d1dc0dd0f06e812c)
Conflicts:
examples/cogland.c
Diffstat (limited to 'examples')
-rw-r--r-- | examples/cogland.c | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/examples/cogland.c b/examples/cogland.c index eb4a92bd..f2082110 100644 --- a/examples/cogland.c +++ b/examples/cogland.c @@ -445,42 +445,14 @@ surface_damaged (CoglandSurface *surface, wl_shm_buffer_get (surface->buffer_ref.buffer->resource); if (shm_buffer) - { - CoglPixelFormat format; - int stride = wl_shm_buffer_get_stride (shm_buffer); - const uint8_t *data = wl_shm_buffer_get_data (shm_buffer); - - switch (wl_shm_buffer_get_format (shm_buffer)) - { -#if G_BYTE_ORDER == G_BIG_ENDIAN - case WL_SHM_FORMAT_ARGB8888: - format = COGL_PIXEL_FORMAT_ARGB_8888_PRE; - break; - case WL_SHM_FORMAT_XRGB8888: - format = COGL_PIXEL_FORMAT_ARGB_8888; - break; -#elif G_BYTE_ORDER == G_LITTLE_ENDIAN - case WL_SHM_FORMAT_ARGB8888: - format = COGL_PIXEL_FORMAT_BGRA_8888_PRE; - break; - case WL_SHM_FORMAT_XRGB8888: - format = COGL_PIXEL_FORMAT_BGRA_8888; - break; -#endif - default: - g_warn_if_reached (); - format = COGL_PIXEL_FORMAT_ARGB_8888; - } - - cogl_texture_set_region (surface->texture, - x, y, /* src_x/y */ - x, y, /* dst_x/y */ - width, height, /* dst_width/height */ - width, height, /* width/height */ - format, - stride, - data); - } + cogl_wayland_texture_set_region_from_shm_buffer (surface->texture, + x, y, + width, + height, + shm_buffer, + x, y, + 0, /* level */ + NULL); } cogland_queue_redraw (surface->compositor); |