mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 09:00:42 -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
6dc7bacf08
commit
e27c63e41b
@ -1043,5 +1043,6 @@ cogl_atlas_texture_vtable =
|
|||||||
_cogl_atlas_texture_get_gl_format,
|
_cogl_atlas_texture_get_gl_format,
|
||||||
_cogl_atlas_texture_get_type,
|
_cogl_atlas_texture_get_type,
|
||||||
NULL, /* is_foreign */
|
NULL, /* is_foreign */
|
||||||
NULL /* set_auto_mipmap */
|
NULL, /* set_auto_mipmap */
|
||||||
|
NULL /* is_get_data_supported */
|
||||||
};
|
};
|
||||||
|
@ -210,6 +210,9 @@ struct _CoglDriverVtable
|
|||||||
int rowstride,
|
int rowstride,
|
||||||
uint8_t *data);
|
uint8_t *data);
|
||||||
|
|
||||||
|
CoglBool
|
||||||
|
(* texture_2d_is_get_data_supported) (CoglTexture2D *tex_2d);
|
||||||
|
|
||||||
/* Prepares for drawing by flushing the journal, framebuffer state,
|
/* Prepares for drawing by flushing the journal, framebuffer state,
|
||||||
* pipeline state and attribute state.
|
* pipeline state and attribute state.
|
||||||
*/
|
*/
|
||||||
|
@ -454,6 +454,14 @@ _cogl_sub_texture_get_type (CoglTexture *tex)
|
|||||||
return _cogl_texture_get_type (sub_tex->full_texture);
|
return _cogl_texture_get_type (sub_tex->full_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 const CoglTextureVtable
|
static const CoglTextureVtable
|
||||||
cogl_sub_texture_vtable =
|
cogl_sub_texture_vtable =
|
||||||
{
|
{
|
||||||
@ -476,5 +484,6 @@ cogl_sub_texture_vtable =
|
|||||||
_cogl_sub_texture_get_gl_format,
|
_cogl_sub_texture_get_gl_format,
|
||||||
_cogl_sub_texture_get_type,
|
_cogl_sub_texture_get_type,
|
||||||
NULL, /* is_foreign */
|
NULL, /* is_foreign */
|
||||||
NULL /* set_auto_mipmap */
|
NULL, /* set_auto_mipmap */
|
||||||
|
_cogl_sub_texture_is_get_data_supported
|
||||||
};
|
};
|
||||||
|
@ -1542,5 +1542,6 @@ cogl_texture_2d_sliced_vtable =
|
|||||||
_cogl_texture_2d_sliced_get_gl_format,
|
_cogl_texture_2d_sliced_get_gl_format,
|
||||||
_cogl_texture_2d_sliced_get_type,
|
_cogl_texture_2d_sliced_get_type,
|
||||||
_cogl_texture_2d_sliced_is_foreign,
|
_cogl_texture_2d_sliced_is_foreign,
|
||||||
NULL /* set_auto_mipmap */
|
NULL, /* set_auto_mipmap */
|
||||||
|
NULL /* is_get_data_supported */
|
||||||
};
|
};
|
||||||
|
@ -94,6 +94,15 @@ _cogl_texture_2d_set_auto_mipmap (CoglTexture *tex,
|
|||||||
tex_2d->auto_mipmap = value;
|
tex_2d->auto_mipmap = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
CoglTexture2D *
|
CoglTexture2D *
|
||||||
_cogl_texture_2d_create_base (CoglContext *ctx,
|
_cogl_texture_2d_create_base (CoglContext *ctx,
|
||||||
int width,
|
int width,
|
||||||
@ -693,5 +702,6 @@ cogl_texture_2d_vtable =
|
|||||||
_cogl_texture_2d_get_gl_format,
|
_cogl_texture_2d_get_gl_format,
|
||||||
_cogl_texture_2d_get_type,
|
_cogl_texture_2d_get_type,
|
||||||
_cogl_texture_2d_is_foreign,
|
_cogl_texture_2d_is_foreign,
|
||||||
_cogl_texture_2d_set_auto_mipmap
|
_cogl_texture_2d_set_auto_mipmap,
|
||||||
|
_cogl_texture_2d_is_get_data_supported
|
||||||
};
|
};
|
||||||
|
@ -755,5 +755,6 @@ cogl_texture_3d_vtable =
|
|||||||
_cogl_texture_3d_get_gl_format,
|
_cogl_texture_3d_get_gl_format,
|
||||||
_cogl_texture_3d_get_type,
|
_cogl_texture_3d_get_type,
|
||||||
NULL, /* is_foreign */
|
NULL, /* is_foreign */
|
||||||
_cogl_texture_3d_set_auto_mipmap
|
_cogl_texture_3d_set_auto_mipmap,
|
||||||
|
NULL /* is_get_data_supported */
|
||||||
};
|
};
|
||||||
|
@ -149,6 +149,8 @@ struct _CoglTextureVtable
|
|||||||
/* Only needs to be implemented if is_primitive == TRUE */
|
/* Only needs to be implemented if is_primitive == TRUE */
|
||||||
void (* set_auto_mipmap) (CoglTexture *texture,
|
void (* set_auto_mipmap) (CoglTexture *texture,
|
||||||
CoglBool value);
|
CoglBool value);
|
||||||
|
|
||||||
|
CoglBool (* is_get_data_supported) (CoglTexture *texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum _CoglTextureSoureType {
|
typedef enum _CoglTextureSoureType {
|
||||||
|
@ -773,5 +773,6 @@ cogl_texture_rectangle_vtable =
|
|||||||
_cogl_texture_rectangle_get_gl_format,
|
_cogl_texture_rectangle_get_gl_format,
|
||||||
_cogl_texture_rectangle_get_type,
|
_cogl_texture_rectangle_get_type,
|
||||||
_cogl_texture_rectangle_is_foreign,
|
_cogl_texture_rectangle_is_foreign,
|
||||||
_cogl_texture_rectangle_set_auto_mipmap
|
_cogl_texture_rectangle_set_auto_mipmap,
|
||||||
|
NULL /* is_get_data_supported */
|
||||||
};
|
};
|
||||||
|
@ -205,6 +205,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);
|
||||||
|
|
||||||
COGL_END_DECLS
|
COGL_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_H__ */
|
#endif /* __COGL_TEXTURE_H__ */
|
||||||
|
@ -116,4 +116,7 @@ _cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
|
|||||||
int rowstride,
|
int rowstride,
|
||||||
uint8_t *data);
|
uint8_t *data);
|
||||||
|
|
||||||
|
CoglBool
|
||||||
|
_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d);
|
||||||
|
|
||||||
#endif /* _COGL_TEXTURE_2D_GL_PRIVATE_H_ */
|
#endif /* _COGL_TEXTURE_2D_GL_PRIVATE_H_ */
|
||||||
|
@ -869,3 +869,12 @@ _cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
|
|||||||
gl_type,
|
gl_type,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@ -714,6 +714,7 @@ _cogl_driver_gl =
|
|||||||
_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_get_data,
|
_cogl_texture_2d_gl_get_data,
|
||||||
|
_cogl_texture_2d_gl_is_get_data_supported,
|
||||||
_cogl_gl_flush_attributes_state,
|
_cogl_gl_flush_attributes_state,
|
||||||
_cogl_clip_stack_gl_flush,
|
_cogl_clip_stack_gl_flush,
|
||||||
_cogl_buffer_gl_create,
|
_cogl_buffer_gl_create,
|
||||||
|
@ -493,6 +493,7 @@ _cogl_driver_gles =
|
|||||||
_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_get_data */
|
NULL, /* texture_2d_get_data */
|
||||||
|
NULL, /* texture_2d_is_get_data_supported */
|
||||||
_cogl_gl_flush_attributes_state,
|
_cogl_gl_flush_attributes_state,
|
||||||
_cogl_clip_stack_gl_flush,
|
_cogl_clip_stack_gl_flush,
|
||||||
_cogl_buffer_gl_create,
|
_cogl_buffer_gl_create,
|
||||||
|
@ -82,6 +82,7 @@ _cogl_driver_nop =
|
|||||||
_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_get_data */
|
NULL, /* texture_2d_get_data */
|
||||||
|
NULL, /* texture_2d_is_get_data_supported */
|
||||||
_cogl_nop_flush_attributes_state,
|
_cogl_nop_flush_attributes_state,
|
||||||
_cogl_clip_stack_nop_flush,
|
_cogl_clip_stack_nop_flush,
|
||||||
};
|
};
|
||||||
|
@ -1180,5 +1180,6 @@ cogl_texture_pixmap_x11_vtable =
|
|||||||
_cogl_texture_pixmap_x11_get_gl_format,
|
_cogl_texture_pixmap_x11_get_gl_format,
|
||||||
_cogl_texture_pixmap_x11_get_type,
|
_cogl_texture_pixmap_x11_get_type,
|
||||||
NULL, /* is_foreign */
|
NULL, /* is_foreign */
|
||||||
NULL /* set_auto_mipmap */
|
NULL, /* set_auto_mipmap */
|
||||||
|
NULL /* is_get_data_supported */
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user