[mutter/wip/nielsdg/remove-gl-alpha: 18/18] cogl: Don't use GL_ALPHA



commit 07fde87fbf4c7659c07a135749e851f255b44997
Author: Niels De Graef <niels degraef barco com>
Date:   Wed Jun 12 09:09:31 2019 +0200

    cogl: Don't use GL_ALPHA
    
    It was deprecated in OpenGL and it isn't even a valid value anymore for
    functions like `glTextImage2D()` in OpenGL 4.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/612

 cogl/cogl/driver/gl/gl/cogl-driver-gl.c         | 46 +++++++++++++++++--------
 cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c |  7 ++--
 cogl/cogl/driver/gl/gles/cogl-driver-gles.c     |  4 +--
 3 files changed, 36 insertions(+), 21 deletions(-)
---
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index fb36df2b8..f7ff3ba66 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -111,20 +111,8 @@ _cogl_driver_pixel_format_to_gl (CoglContext     *context,
   switch (format)
     {
     case COGL_PIXEL_FORMAT_A_8:
-      /* If the driver doesn't natively support alpha textures then we
-       * will use a red component texture with a swizzle to implement
-       * the texture */
-      if (_cogl_has_private_feature
-          (context, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) == 0)
-        {
-          glintformat = GL_RED;
-          glformat = GL_RED;
-        }
-      else
-        {
-          glintformat = GL_ALPHA;
-          glformat = GL_ALPHA;
-        }
+      glintformat = GL_RED;
+      glformat = GL_RED;
       gltype = GL_UNSIGNED_BYTE;
       break;
     case COGL_PIXEL_FORMAT_G_8:
@@ -268,7 +256,37 @@ _cogl_driver_pixel_format_to_gl (CoglContext     *context,
       break;
 
     case COGL_PIXEL_FORMAT_ANY:
+    /* No support for YUV or multi-plane formats */
     case COGL_PIXEL_FORMAT_YUV:
+    case COGL_PIXEL_FORMAT_YUYV:
+    case COGL_PIXEL_FORMAT_YVYU:
+    case COGL_PIXEL_FORMAT_UYVY:
+    case COGL_PIXEL_FORMAT_VYUY:
+    case COGL_PIXEL_FORMAT_AYUV:
+    case COGL_PIXEL_FORMAT_XRGB8888_A8:
+    case COGL_PIXEL_FORMAT_XBGR8888_A8:
+    case COGL_PIXEL_FORMAT_RGBX8888_A8:
+    case COGL_PIXEL_FORMAT_BGRX8888_A8:
+    case COGL_PIXEL_FORMAT_RGB888_A8:
+    case COGL_PIXEL_FORMAT_BGR888_A8:
+    case COGL_PIXEL_FORMAT_RGB565_A8:
+    case COGL_PIXEL_FORMAT_BGR565_A8:
+    case COGL_PIXEL_FORMAT_NV12:
+    case COGL_PIXEL_FORMAT_NV21:
+    case COGL_PIXEL_FORMAT_NV16:
+    case COGL_PIXEL_FORMAT_NV61:
+    case COGL_PIXEL_FORMAT_NV24:
+    case COGL_PIXEL_FORMAT_NV42:
+    case COGL_PIXEL_FORMAT_YUV410:
+    case COGL_PIXEL_FORMAT_YVU410:
+    case COGL_PIXEL_FORMAT_YUV411:
+    case COGL_PIXEL_FORMAT_YVU411:
+    case COGL_PIXEL_FORMAT_YUV420:
+    case COGL_PIXEL_FORMAT_YVU420:
+    case COGL_PIXEL_FORMAT_YUV422:
+    case COGL_PIXEL_FORMAT_YVU422:
+    case COGL_PIXEL_FORMAT_YUV444:
+    case COGL_PIXEL_FORMAT_YVU444:
       g_assert_not_reached ();
       break;
     }
diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c
index c2270124f..026991d97 100644
--- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -98,11 +98,8 @@ _cogl_texture_driver_gen (CoglContext *ctx,
       g_assert_not_reached();
     }
 
-  /* If the driver doesn't support alpha textures directly then we'll
-   * fake them by setting the swizzle parameters */
-  if (internal_format == COGL_PIXEL_FORMAT_A_8 &&
-      !_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) &&
-      _cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE))
+  /* GL_ALPHA is deprecated; instead, use GL_RED with a swizzle mask */
+  if (internal_format == COGL_PIXEL_FORMAT_A_8)
     {
       static const GLint red_swizzle[] = { GL_ZERO, GL_ZERO, GL_ZERO, GL_RED };
 
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index d2769a805..3ae26bd23 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -83,8 +83,8 @@ _cogl_driver_pixel_format_to_gl (CoglContext     *context,
   switch (format)
     {
     case COGL_PIXEL_FORMAT_A_8:
-      glintformat = GL_ALPHA;
-      glformat = GL_ALPHA;
+      glintformat = GL_RED;
+      glformat = GL_RED;
       gltype = GL_UNSIGNED_BYTE;
       break;
     case COGL_PIXEL_FORMAT_G_8:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]