[gtk+] gdkgl: Change prototype of function



commit 3d8b00600e7da165c47a215ce20533411ec94113
Author: Benjamin Otte <otte redhat com>
Date:   Tue Nov 1 04:47:52 2016 +0100

    gdkgl: Change prototype of function
    
    The function does not upload a cairo surface, it uploads pixel data.
    
    So don't take a cairo surface as an argument, take pixel data.

 gdk/gdkgl.c               |   14 ++++++++++++--
 gdk/gdkglcontext.c        |   15 +++++++--------
 gdk/gdkglcontextprivate.h |    3 ++-
 3 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
index e3594c2..2005cec 100644
--- a/gdk/gdkgl.c
+++ b/gdk/gdkgl.c
@@ -780,7 +780,12 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
       e.height *= sy;
       image = cairo_surface_map_to_image (surface, &e);
 
-      gdk_gl_context_upload_texture (paint_context, image, e.width, e.height, target);
+      gdk_gl_context_upload_texture (paint_context, 
+                                     cairo_image_surface_get_data (image),
+                                     e.width,
+                                     e.height,
+                                     cairo_image_surface_get_stride (image),
+                                     target);
 
       cairo_surface_unmap_image (surface, image);
 
@@ -855,7 +860,12 @@ gdk_cairo_surface_upload_to_gl (cairo_surface_t *surface,
   rect.height = height;
   tmp = cairo_surface_map_to_image (surface, &rect);
 
-  gdk_gl_context_upload_texture (context, tmp, rect.width, rect.height, target);
+  gdk_gl_context_upload_texture (context,
+                                 cairo_image_surface_get_data (tmp),
+                                 rect.width,
+                                 rect.height,
+                                 cairo_image_surface_get_stride (tmp),
+                                 target);
 
   cairo_surface_unmap_image (surface, tmp);
 }
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index f822fa8..0dd3c57 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -237,9 +237,10 @@ gdk_gl_context_get_property (GObject    *gobject,
 
 void
 gdk_gl_context_upload_texture (GdkGLContext    *context,
-                               cairo_surface_t *image_surface,
+                               const guchar    *data,
                                int              width,
                                int              height,
+                               int              stride,
                                guint            texture_target)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
@@ -253,21 +254,19 @@ gdk_gl_context_upload_texture (GdkGLContext    *context,
       (priv->use_es && (priv->gl_version >= 30 || priv->has_unpack_subimage)))
     {
       glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
-      glPixelStorei (GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride (image_surface) / 4);
+      glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4);
 
       if (priv->use_es)
         glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
-                      cairo_image_surface_get_data (image_surface));
+                      data);
       else
         glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
-                      cairo_image_surface_get_data (image_surface));
+                      data);
 
       glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
     }
   else
     {
-      GLvoid *data = cairo_image_surface_get_data (image_surface);
-      int stride = cairo_image_surface_get_stride (image_surface);
       int i;
 
       if (priv->use_es)
@@ -275,14 +274,14 @@ gdk_gl_context_upload_texture (GdkGLContext    *context,
           glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
 
           for (i = 0; i < height; i++)
-            glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*) 
data + (i * stride));
+            glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, data + (i * 
stride));
         }
       else
         {
           glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 
NULL);
 
           for (i = 0; i < height; i++)
-            glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 
(unsigned char*) data + (i * stride));
+            glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data + 
(i * stride));
         }
     }
 }
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index cb0b767..1d0b9ff 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -77,9 +77,10 @@ void                    gdk_gl_context_set_is_legacy            (GdkGLContext
                                                                  gboolean         is_legacy);
 
 void                    gdk_gl_context_upload_texture           (GdkGLContext    *context,
-                                                                 cairo_surface_t *image_surface,
+                                                                 const guchar    *data,
                                                                  int              width,
                                                                  int              height,
+                                                                 int              stride,
                                                                  guint            texture_target);
 GdkGLContextPaintData * gdk_gl_context_get_paint_data           (GdkGLContext    *context);
 gboolean                gdk_gl_context_use_texture_rectangle    (GdkGLContext    *context);


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