[gtk/matthiasc/color-profile-rebased: 44/51] gsk: Add color space in gsk_renderer_render_texture




commit 82b45004c2b150696b3136c2e58169dce813b987
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon May 9 17:05:11 2022 -0400

    gsk: Add color space in gsk_renderer_render_texture
    
    Make gsk_renderer_render_texture produce a texture
    that has the correct color space attached. This
    fixes the rendering of node files in the node editor.

 gsk/gl/gskgldriver.c        | 20 ++++++++++++--------
 gsk/gl/gskgldriverprivate.h |  4 +++-
 gsk/gl/gskglrenderer.c      |  6 +++++-
 3 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index 1795e3044f..72e080436f 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -1547,8 +1547,10 @@ create_texture_from_texture_destroy (gpointer data)
 }
 
 GdkTexture *
-gsk_gl_driver_create_gdk_texture (GskGLDriver *self,
-                                  guint        texture_id)
+gsk_gl_driver_create_gdk_texture (GskGLDriver       *self,
+                                  guint              texture_id,
+                                  GdkGLTextureFlags  flags,
+                                  GdkColorSpace     *color_space)
 {
   GskGLTextureState *state;
   GskGLTexture *texture;
@@ -1576,10 +1578,12 @@ gsk_gl_driver_create_gdk_texture (GskGLDriver *self,
   texture->texture_id = 0;
   gsk_gl_texture_free (texture);
 
-  return gdk_gl_texture_new (self->command_queue->context,
-                             texture_id,
-                             width,
-                             height,
-                             create_texture_from_texture_destroy,
-                             state);
+  return gdk_gl_texture_new_with_color_space (self->command_queue->context,
+                                              texture_id,
+                                              width,
+                                              height,
+                                              flags,
+                                              color_space,
+                                              create_texture_from_texture_destroy,
+                                              state);
 }
diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h
index accae5b3bb..e61b29018e 100644
--- a/gsk/gl/gskgldriverprivate.h
+++ b/gsk/gl/gskgldriverprivate.h
@@ -155,7 +155,9 @@ void                gsk_gl_driver_begin_frame            (GskGLDriver         *s
 void                gsk_gl_driver_end_frame              (GskGLDriver         *self);
 void                gsk_gl_driver_after_frame            (GskGLDriver         *self);
 GdkTexture        * gsk_gl_driver_create_gdk_texture     (GskGLDriver         *self,
-                                                          guint                texture_id);
+                                                          guint                texture_id,
+                                                          GdkGLTextureFlags    flags,
+                                                          GdkColorSpace       *color_space);
 void                gsk_gl_driver_cache_texture          (GskGLDriver         *self,
                                                           const GskTextureKey *key,
                                                           guint                texture_id);
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 9ed6a655bc..fe19971f76 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -25,6 +25,7 @@
 #include <gdk/gdkglcontextprivate.h>
 #include <gdk/gdksurfaceprivate.h>
 #include <glib/gi18n-lib.h>
+#include <gdk/gdkcolorspaceprivate.h>
 #include <gsk/gskdebugprivate.h>
 #include <gsk/gskrendererprivate.h>
 #include <gsk/gskrendernodeprivate.h>
@@ -390,7 +391,10 @@ gsk_gl_renderer_render_texture (GskRenderer           *renderer,
 #endif
       gsk_gl_render_job_render_flipped (job, root);
       texture_id = gsk_gl_driver_release_render_target (self->driver, render_target, FALSE);
-      texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id);
+      texture = gsk_gl_driver_create_gdk_texture (self->driver,
+                                                  texture_id,
+                                                  GDK_GL_TEXTURE_PREMULTIPLIED,
+                                                  gdk_color_space_get_srgb_linear ());
       gsk_gl_driver_end_frame (self->driver);
       gsk_gl_render_job_free (job);
 


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