cogl: Add pixel_format_to_gl_with_target driver vfunc

This is used by the GL driver in order to determine whether swizzling
actually applies given the bitmap and target texture internal format.
If both agree that they store BGRA, then swizzling may apply.

https://bugzilla.gnome.org/show_bug.cgi?id=779234
This commit is contained in:
Carlos Garnacho 2017-03-03 17:11:19 +01:00
parent f7ffb1790f
commit aa5738c777
4 changed files with 52 additions and 11 deletions

View File

@ -55,6 +55,13 @@ struct _CoglDriverVtable
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype);
CoglPixelFormat
(* pixel_format_to_gl_with_target) (CoglContext *context,
CoglPixelFormat format,
CoglPixelFormat target_format,
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype);
CoglBool
(* update_features) (CoglContext *context,

View File

@ -96,8 +96,9 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
}
static CoglPixelFormat
_cogl_driver_pixel_format_to_gl (CoglContext *context,
_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
CoglPixelFormat format,
CoglPixelFormat target_format,
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype)
@ -178,7 +179,8 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
* and buffer format are the same here, the pixels
* will be flipped through this extension.
*/
if (_cogl_has_private_feature
if (target_format == format &&
_cogl_has_private_feature
(context, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE))
glformat = GL_RGBA;
else
@ -297,6 +299,20 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
return required_format;
}
static CoglPixelFormat
_cogl_driver_pixel_format_to_gl (CoglContext *context,
CoglPixelFormat format,
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype)
{
return _cogl_driver_pixel_format_to_gl_with_target (context,
format, format,
out_glintformat,
out_glformat,
out_gltype);
}
static CoglBool
_cogl_get_gl_version (CoglContext *ctx,
int *major_out,
@ -677,6 +693,7 @@ _cogl_driver_gl =
{
_cogl_driver_pixel_format_from_gl_internal,
_cogl_driver_pixel_format_to_gl,
_cogl_driver_pixel_format_to_gl_with_target,
_cogl_driver_update_features,
_cogl_offscreen_gl_allocate,
_cogl_offscreen_gl_free,

View File

@ -67,8 +67,9 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
}
static CoglPixelFormat
_cogl_driver_pixel_format_to_gl (CoglContext *context,
_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
CoglPixelFormat format,
CoglPixelFormat target_format,
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype)
@ -219,6 +220,20 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
return required_format;
}
static CoglPixelFormat
_cogl_driver_pixel_format_to_gl (CoglContext *context,
CoglPixelFormat format,
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype)
{
return _cogl_driver_pixel_format_to_gl_with_target (context,
format, format,
out_glintformat,
out_glformat,
out_gltype);
}
static CoglBool
_cogl_get_gl_version (CoglContext *ctx,
int *major_out,
@ -457,6 +472,7 @@ _cogl_driver_gles =
{
_cogl_driver_pixel_format_from_gl_internal,
_cogl_driver_pixel_format_to_gl,
_cogl_driver_pixel_format_to_gl_with_target,
_cogl_driver_update_features,
_cogl_offscreen_gl_allocate,
_cogl_offscreen_gl_free,

View File

@ -61,6 +61,7 @@ _cogl_driver_nop =
{
NULL, /* pixel_format_from_gl_internal */
NULL, /* pixel_format_to_gl */
NULL, /* pixel_format_to_gl_with_target */
_cogl_driver_update_features,
_cogl_offscreen_nop_allocate,
_cogl_offscreen_nop_free,