mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
cogl/texture: Add API to check whether _get_data() will work
Currently, GL_TEXTURE_EXTERNAL_OES textures doesn't support getting pixel data. Make it possible for texture users to know this. https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
This commit is contained in:
parent
c681ccef3c
commit
eac18647c3
@ -1025,6 +1025,7 @@ cogl_atlas_texture_vtable =
|
|||||||
FALSE, /* not primitive */
|
FALSE, /* not primitive */
|
||||||
_cogl_atlas_texture_allocate,
|
_cogl_atlas_texture_allocate,
|
||||||
_cogl_atlas_texture_set_region,
|
_cogl_atlas_texture_set_region,
|
||||||
|
NULL, /* is_get_data_supported */
|
||||||
NULL, /* get_data */
|
NULL, /* get_data */
|
||||||
_cogl_atlas_texture_foreach_sub_texture_in_region,
|
_cogl_atlas_texture_foreach_sub_texture_in_region,
|
||||||
_cogl_atlas_texture_get_max_waste,
|
_cogl_atlas_texture_get_max_waste,
|
||||||
|
@ -199,6 +199,9 @@ struct _CoglDriverVtable
|
|||||||
int level,
|
int level,
|
||||||
CoglError **error);
|
CoglError **error);
|
||||||
|
|
||||||
|
CoglBool
|
||||||
|
(* texture_2d_is_get_data_supported) (CoglTexture2D *tex_2d);
|
||||||
|
|
||||||
/* Reads back the full contents of the given texture and write it to
|
/* Reads back the full contents of the given texture and write it to
|
||||||
* @data in the given @format and with the given @rowstride.
|
* @data in the given @format and with the given @rowstride.
|
||||||
*
|
*
|
||||||
|
@ -428,6 +428,14 @@ _cogl_sub_texture_set_region (CoglTexture *tex,
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CoglBool
|
||||||
|
_cogl_sub_texture_is_get_data_supported (CoglTexture *tex)
|
||||||
|
{
|
||||||
|
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
|
||||||
|
|
||||||
|
return cogl_texture_is_get_data_supported (sub_tex->full_texture);
|
||||||
|
}
|
||||||
|
|
||||||
static CoglPixelFormat
|
static CoglPixelFormat
|
||||||
_cogl_sub_texture_get_format (CoglTexture *tex)
|
_cogl_sub_texture_get_format (CoglTexture *tex)
|
||||||
{
|
{
|
||||||
@ -458,6 +466,7 @@ cogl_sub_texture_vtable =
|
|||||||
FALSE, /* not primitive */
|
FALSE, /* not primitive */
|
||||||
_cogl_sub_texture_allocate,
|
_cogl_sub_texture_allocate,
|
||||||
_cogl_sub_texture_set_region,
|
_cogl_sub_texture_set_region,
|
||||||
|
_cogl_sub_texture_is_get_data_supported,
|
||||||
NULL, /* get_data */
|
NULL, /* get_data */
|
||||||
_cogl_sub_texture_foreach_sub_texture_in_region,
|
_cogl_sub_texture_foreach_sub_texture_in_region,
|
||||||
_cogl_sub_texture_get_max_waste,
|
_cogl_sub_texture_get_max_waste,
|
||||||
|
@ -1524,6 +1524,7 @@ cogl_texture_2d_sliced_vtable =
|
|||||||
FALSE, /* not primitive */
|
FALSE, /* not primitive */
|
||||||
_cogl_texture_2d_sliced_allocate,
|
_cogl_texture_2d_sliced_allocate,
|
||||||
_cogl_texture_2d_sliced_set_region,
|
_cogl_texture_2d_sliced_set_region,
|
||||||
|
NULL, /* is_get_data_supported */
|
||||||
NULL, /* get_data */
|
NULL, /* get_data */
|
||||||
_cogl_texture_2d_sliced_foreach_sub_texture_in_region,
|
_cogl_texture_2d_sliced_foreach_sub_texture_in_region,
|
||||||
_cogl_texture_2d_sliced_get_max_waste,
|
_cogl_texture_2d_sliced_get_max_waste,
|
||||||
|
@ -629,6 +629,15 @@ _cogl_texture_2d_set_region (CoglTexture *tex,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CoglBool
|
||||||
|
_cogl_texture_2d_is_get_data_supported (CoglTexture *tex)
|
||||||
|
{
|
||||||
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
|
|
||||||
|
return ctx->driver_vtable->texture_2d_is_get_data_supported (tex_2d);
|
||||||
|
}
|
||||||
|
|
||||||
static CoglBool
|
static CoglBool
|
||||||
_cogl_texture_2d_get_data (CoglTexture *tex,
|
_cogl_texture_2d_get_data (CoglTexture *tex,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
@ -677,6 +686,7 @@ cogl_texture_2d_vtable =
|
|||||||
TRUE, /* primitive */
|
TRUE, /* primitive */
|
||||||
_cogl_texture_2d_allocate,
|
_cogl_texture_2d_allocate,
|
||||||
_cogl_texture_2d_set_region,
|
_cogl_texture_2d_set_region,
|
||||||
|
_cogl_texture_2d_is_get_data_supported,
|
||||||
_cogl_texture_2d_get_data,
|
_cogl_texture_2d_get_data,
|
||||||
NULL, /* foreach_sub_texture_in_region */
|
NULL, /* foreach_sub_texture_in_region */
|
||||||
_cogl_texture_2d_get_max_waste,
|
_cogl_texture_2d_get_max_waste,
|
||||||
|
@ -737,6 +737,7 @@ cogl_texture_3d_vtable =
|
|||||||
TRUE, /* primitive */
|
TRUE, /* primitive */
|
||||||
_cogl_texture_3d_allocate,
|
_cogl_texture_3d_allocate,
|
||||||
_cogl_texture_3d_set_region,
|
_cogl_texture_3d_set_region,
|
||||||
|
NULL, /* is_get_data_supported */
|
||||||
_cogl_texture_3d_get_data,
|
_cogl_texture_3d_get_data,
|
||||||
NULL, /* foreach_sub_texture_in_region */
|
NULL, /* foreach_sub_texture_in_region */
|
||||||
_cogl_texture_3d_get_max_waste,
|
_cogl_texture_3d_get_max_waste,
|
||||||
|
@ -91,6 +91,8 @@ struct _CoglTextureVtable
|
|||||||
CoglBitmap *bitmap,
|
CoglBitmap *bitmap,
|
||||||
CoglError **error);
|
CoglError **error);
|
||||||
|
|
||||||
|
CoglBool (* is_get_data_supported) (CoglTexture *texture);
|
||||||
|
|
||||||
/* This should copy the image data of the texture into @data. The
|
/* This should copy the image data of the texture into @data. The
|
||||||
requested format will have been first passed through
|
requested format will have been first passed through
|
||||||
ctx->texture_driver->find_best_gl_get_data_format so it should
|
ctx->texture_driver->find_best_gl_get_data_format so it should
|
||||||
|
@ -755,6 +755,7 @@ cogl_texture_rectangle_vtable =
|
|||||||
TRUE, /* primitive */
|
TRUE, /* primitive */
|
||||||
_cogl_texture_rectangle_allocate,
|
_cogl_texture_rectangle_allocate,
|
||||||
_cogl_texture_rectangle_set_region,
|
_cogl_texture_rectangle_set_region,
|
||||||
|
NULL, /* is_get_data_supported */
|
||||||
_cogl_texture_rectangle_get_data,
|
_cogl_texture_rectangle_get_data,
|
||||||
NULL, /* foreach_sub_texture_in_region */
|
NULL, /* foreach_sub_texture_in_region */
|
||||||
_cogl_texture_rectangle_get_max_waste,
|
_cogl_texture_rectangle_get_max_waste,
|
||||||
|
@ -203,6 +203,15 @@ _cogl_texture_is_foreign (CoglTexture *texture)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoglBool
|
||||||
|
cogl_texture_is_get_data_supported (CoglTexture *texture)
|
||||||
|
{
|
||||||
|
if (texture->vtable->is_get_data_supported)
|
||||||
|
return texture->vtable->is_get_data_supported (texture);
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_width (CoglTexture *texture)
|
cogl_texture_get_width (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
|
@ -511,6 +511,12 @@ CoglBool
|
|||||||
cogl_texture_allocate (CoglTexture *texture,
|
cogl_texture_allocate (CoglTexture *texture,
|
||||||
CoglError **error);
|
CoglError **error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_texture_is_get_data_supported: (skip)
|
||||||
|
*/
|
||||||
|
CoglBool
|
||||||
|
cogl_texture_is_get_data_supported (CoglTexture *texture);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_H__ */
|
#endif /* __COGL_TEXTURE_H__ */
|
||||||
|
@ -110,6 +110,9 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
|
|||||||
int level,
|
int level,
|
||||||
CoglError **error);
|
CoglError **error);
|
||||||
|
|
||||||
|
CoglBool
|
||||||
|
_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
|
_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
|
@ -838,6 +838,15 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoglBool
|
||||||
|
_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d)
|
||||||
|
{
|
||||||
|
if (tex_2d->gl_target == GL_TEXTURE_EXTERNAL_OES)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
|
_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
|
@ -705,6 +705,7 @@ _cogl_driver_gl =
|
|||||||
_cogl_texture_2d_gl_get_gl_handle,
|
_cogl_texture_2d_gl_get_gl_handle,
|
||||||
_cogl_texture_2d_gl_generate_mipmap,
|
_cogl_texture_2d_gl_generate_mipmap,
|
||||||
_cogl_texture_2d_gl_copy_from_bitmap,
|
_cogl_texture_2d_gl_copy_from_bitmap,
|
||||||
|
_cogl_texture_2d_gl_is_get_data_supported,
|
||||||
_cogl_texture_2d_gl_get_data,
|
_cogl_texture_2d_gl_get_data,
|
||||||
_cogl_gl_flush_attributes_state,
|
_cogl_gl_flush_attributes_state,
|
||||||
_cogl_clip_stack_gl_flush,
|
_cogl_clip_stack_gl_flush,
|
||||||
|
@ -469,6 +469,7 @@ _cogl_driver_gles =
|
|||||||
_cogl_texture_2d_gl_get_gl_handle,
|
_cogl_texture_2d_gl_get_gl_handle,
|
||||||
_cogl_texture_2d_gl_generate_mipmap,
|
_cogl_texture_2d_gl_generate_mipmap,
|
||||||
_cogl_texture_2d_gl_copy_from_bitmap,
|
_cogl_texture_2d_gl_copy_from_bitmap,
|
||||||
|
NULL, /* texture_2d_is_get_data_supported */
|
||||||
NULL, /* texture_2d_get_data */
|
NULL, /* texture_2d_get_data */
|
||||||
_cogl_gl_flush_attributes_state,
|
_cogl_gl_flush_attributes_state,
|
||||||
_cogl_clip_stack_gl_flush,
|
_cogl_clip_stack_gl_flush,
|
||||||
|
@ -79,6 +79,7 @@ _cogl_driver_nop =
|
|||||||
_cogl_texture_2d_nop_get_gl_handle,
|
_cogl_texture_2d_nop_get_gl_handle,
|
||||||
_cogl_texture_2d_nop_generate_mipmap,
|
_cogl_texture_2d_nop_generate_mipmap,
|
||||||
_cogl_texture_2d_nop_copy_from_bitmap,
|
_cogl_texture_2d_nop_copy_from_bitmap,
|
||||||
|
NULL, /* texture_2d_is_get_data_supported */
|
||||||
NULL, /* texture_2d_get_data */
|
NULL, /* texture_2d_get_data */
|
||||||
_cogl_nop_flush_attributes_state,
|
_cogl_nop_flush_attributes_state,
|
||||||
_cogl_clip_stack_nop_flush,
|
_cogl_clip_stack_nop_flush,
|
||||||
|
@ -1162,6 +1162,7 @@ cogl_texture_pixmap_x11_vtable =
|
|||||||
FALSE, /* not primitive */
|
FALSE, /* not primitive */
|
||||||
_cogl_texture_pixmap_x11_allocate,
|
_cogl_texture_pixmap_x11_allocate,
|
||||||
_cogl_texture_pixmap_x11_set_region,
|
_cogl_texture_pixmap_x11_set_region,
|
||||||
|
NULL, /* is_get_data_supported */
|
||||||
_cogl_texture_pixmap_x11_get_data,
|
_cogl_texture_pixmap_x11_get_data,
|
||||||
_cogl_texture_pixmap_x11_foreach_sub_texture_in_region,
|
_cogl_texture_pixmap_x11_foreach_sub_texture_in_region,
|
||||||
_cogl_texture_pixmap_x11_get_max_waste,
|
_cogl_texture_pixmap_x11_get_max_waste,
|
||||||
|
Loading…
Reference in New Issue
Block a user