summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-05-08 14:55:24 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-09-30 14:42:03 -0400
commit80bf2336c9ecd4d206a94b9062682a42c18105b7 (patch)
treeef3c8882c2e6e582a1e7e7205d6a761206d9786d
parent55179c450bc66f83977e98bf700a1a4d4f5d88c5 (diff)
downloadgtk+-80bf2336c9ecd4d206a94b9062682a42c18105b7.tar.gz
gsk: Use GL texture information
Use the flags and color space information from GL textures to figure out what conversions we need to do on them.
-rw-r--r--gsk/gl/gskgldriver.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index 51f367fb61..1795e3044f 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -42,6 +42,7 @@
#include <gdk/gdkdisplayprivate.h>
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkmemorytextureprivate.h>
+#include <gdk/gdkcolorspaceprivate.h>
#include <gdk/gdkprofilerprivate.h>
#include <gdk/gdktextureprivate.h>
@@ -883,28 +884,40 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
if (gdk_gl_context_is_shared (context, texture_context))
{
+ GdkColorSpace *color_space;
guint gl_texture_id;
+ GdkGLTextureFlags flags;
gl_texture_id = gdk_gl_texture_get_id (gl_texture);
+ color_space = gdk_texture_get_color_space (texture);
+ flags = gdk_gl_texture_get_flags (gl_texture);
/* A GL texture from the same GL context is a simple task... */
- if (gdk_color_space_is_linear (gdk_texture_get_color_space (texture)))
+ if (color_space == gdk_color_space_get_srgb_linear () &&
+ flags == GDK_GL_TEXTURE_PREMULTIPLIED)
{
return gl_texture_id;
}
- else
+ else if (color_space == gdk_color_space_get_srgb () ||
+ color_space == gdk_color_space_get_srgb_linear ())
{
- /* The GL texture isn't linear sRGB, so we need to convert
- * it before we can use it. For now, we just assume that it
- * is nonlinear sRGB. Eventually, we should figure out how
- * to convert from other color spaces to linear sRGB
- */
+ conversion = 0;
+
+ if (color_space == gdk_color_space_get_srgb ())
+ conversion |= GSK_CONVERSION_LINEARIZE;
+
+ if ((flags & GDK_GL_TEXTURE_PREMULTIPLIED) == 0)
+ conversion |= GSK_CONVERSION_PREMULTIPLY;
+
+ if ((flags & GDK_GL_TEXTURE_FLIPPED) != 0)
+ conversion |= GSK_CONVERSION_FLIP;
+
t = gsk_gl_driver_convert_texture (self,
gl_texture_id,
width, height,
format,
min_filter, mag_filter,
- GSK_CONVERSION_LINEARIZE);
+ conversion);
if (gdk_texture_set_render_data (texture, self, t, gsk_gl_texture_destroyed))
t->user = texture;