mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
cogl-texture-2d: Add update_area equivalent for Wayland
This commit is contained in:
parent
5c5715f4da
commit
af480a2b8b
@ -292,22 +292,13 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
|
|||||||
#endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */
|
#endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */
|
||||||
|
|
||||||
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
|
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
|
||||||
CoglTexture2D *
|
static void
|
||||||
cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
|
||||||
struct wl_resource *buffer,
|
CoglPixelFormat *format_out,
|
||||||
CoglError **error)
|
CoglPixelFormat *internal_format_out)
|
||||||
{
|
{
|
||||||
struct wl_shm_buffer *shm_buffer;
|
|
||||||
|
|
||||||
shm_buffer = wl_shm_buffer_get (buffer);
|
|
||||||
|
|
||||||
if (shm_buffer)
|
|
||||||
{
|
|
||||||
int stride = wl_shm_buffer_get_stride (shm_buffer);
|
|
||||||
CoglPixelFormat format;
|
CoglPixelFormat format;
|
||||||
CoglPixelFormat internal_format = COGL_PIXEL_FORMAT_ANY;
|
CoglPixelFormat internal_format = COGL_PIXEL_FORMAT_ANY;
|
||||||
int width = wl_shm_buffer_get_width (shm_buffer);
|
|
||||||
int height = wl_shm_buffer_get_height (shm_buffer);
|
|
||||||
|
|
||||||
switch (wl_shm_buffer_get_format (shm_buffer))
|
switch (wl_shm_buffer_get_format (shm_buffer))
|
||||||
{
|
{
|
||||||
@ -333,6 +324,52 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
|||||||
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (format_out)
|
||||||
|
*format_out = format;
|
||||||
|
if (internal_format_out)
|
||||||
|
*internal_format_out = internal_format;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_wayland_texture_2d_update_area (CoglTexture2D *texture,
|
||||||
|
struct wl_shm_buffer *shm_buffer,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
CoglPixelFormat format;
|
||||||
|
|
||||||
|
shm_buffer_get_cogl_pixel_format (shm_buffer, &format, NULL);
|
||||||
|
|
||||||
|
cogl_texture_set_region (COGL_TEXTURE (texture),
|
||||||
|
x, y,
|
||||||
|
x, y,
|
||||||
|
width, height,
|
||||||
|
width, height,
|
||||||
|
format,
|
||||||
|
wl_shm_buffer_get_stride (shm_buffer),
|
||||||
|
wl_shm_buffer_get_data (shm_buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglTexture2D *
|
||||||
|
cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
||||||
|
struct wl_resource *buffer,
|
||||||
|
CoglError **error)
|
||||||
|
{
|
||||||
|
struct wl_shm_buffer *shm_buffer;
|
||||||
|
|
||||||
|
shm_buffer = wl_shm_buffer_get (buffer);
|
||||||
|
|
||||||
|
if (shm_buffer)
|
||||||
|
{
|
||||||
|
int stride = wl_shm_buffer_get_stride (shm_buffer);
|
||||||
|
int width = wl_shm_buffer_get_width (shm_buffer);
|
||||||
|
int height = wl_shm_buffer_get_height (shm_buffer);
|
||||||
|
CoglPixelFormat format, internal_format;
|
||||||
|
|
||||||
|
shm_buffer_get_cogl_pixel_format (shm_buffer, &format, &internal_format);
|
||||||
|
|
||||||
return cogl_texture_2d_new_from_data (ctx,
|
return cogl_texture_2d_new_from_data (ctx,
|
||||||
width, height,
|
width, height,
|
||||||
format,
|
format,
|
||||||
|
@ -79,6 +79,14 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
|||||||
struct wl_resource *buffer,
|
struct wl_resource *buffer,
|
||||||
CoglError **error);
|
CoglError **error);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_wayland_texture_2d_update_area (CoglTexture2D *texture,
|
||||||
|
struct wl_shm_buffer *shm_buffer,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
COGL_END_DECLS
|
COGL_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_WAYLAND_SERVER_H */
|
#endif /* __COGL_WAYLAND_SERVER_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user