diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-03-03 17:11:19 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-03-07 13:40:06 +0100 |
commit | aa5738c777883f270ae9cb3b2988d194792fed75 (patch) | |
tree | 71467b54dc31b1d599abf8f6afe5c2e4ae4ad47e /cogl | |
parent | f7ffb1790fab8778cf525d2b579b130ef377615d (diff) | |
download | mutter-aa5738c777883f270ae9cb3b2988d194792fed75.tar.gz |
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
Diffstat (limited to 'cogl')
-rw-r--r-- | cogl/cogl/cogl-driver.h | 7 | ||||
-rw-r--r-- | cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 29 | ||||
-rw-r--r-- | cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 26 | ||||
-rw-r--r-- | cogl/cogl/driver/nop/cogl-driver-nop.c | 1 |
4 files changed, 52 insertions, 11 deletions
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h index 648228c6f..85aa0d870 100644 --- a/cogl/cogl/cogl-driver.h +++ b/cogl/cogl/cogl-driver.h @@ -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, diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 1cc63e82f..178262ac0 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -96,11 +96,12 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context, } static CoglPixelFormat -_cogl_driver_pixel_format_to_gl (CoglContext *context, - CoglPixelFormat format, - GLenum *out_glintformat, - GLenum *out_glformat, - GLenum *out_gltype) +_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context, + CoglPixelFormat format, + CoglPixelFormat target_format, + GLenum *out_glintformat, + GLenum *out_glformat, + GLenum *out_gltype) { CoglPixelFormat required_format; GLenum glintformat = 0; @@ -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, diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index bf63fcc16..521f6ef3d 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -67,11 +67,12 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context, } static CoglPixelFormat -_cogl_driver_pixel_format_to_gl (CoglContext *context, - CoglPixelFormat format, - GLenum *out_glintformat, - GLenum *out_glformat, - GLenum *out_gltype) +_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context, + CoglPixelFormat format, + CoglPixelFormat target_format, + GLenum *out_glintformat, + GLenum *out_glformat, + GLenum *out_gltype) { CoglPixelFormat required_format; GLenum glintformat; @@ -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, diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c index d9b1d0f1f..6e04e7164 100644 --- a/cogl/cogl/driver/nop/cogl-driver-nop.c +++ b/cogl/cogl/driver/nop/cogl-driver-nop.c @@ -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, |