[gtk/matthiasc/color-profiles: 4/32] ngl: Upload textures in linear sRGB
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profiles: 4/32] ngl: Upload textures in linear sRGB
- Date: Sun, 3 Oct 2021 20:23:25 +0000 (UTC)
commit 93e275c7054e4ec712b2d6acdfab8800947ea977
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Sep 29 17:17:57 2021 -0400
ngl: Upload textures in linear sRGB
We want to do compositing in a linear colorspace,
so convert textures to linear sRGB before uploading.
Currently, this causes images to come out dark, since
we don't have a way to tell the compositor that our
framebuffer is linear, so it assumes a gamma that we
don't provide.
gsk/ngl/gsknglcommandqueue.c | 3 ++-
gsk/ngl/gsknglglyphlibrary.c | 5 +++--
gsk/ngl/gskngliconlibrary.c | 3 ++-
gsk/ngl/gsknglrenderjob.c | 7 ++++++-
4 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gsk/ngl/gsknglcommandqueue.c b/gsk/ngl/gsknglcommandqueue.c
index 877bae383b..e06a5f76f5 100644
--- a/gsk/ngl/gsknglcommandqueue.c
+++ b/gsk/ngl/gsknglcommandqueue.c
@@ -28,6 +28,7 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkmemorytextureprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
#include <gdk/gdkprofilerprivate.h>
#include <gsk/gskdebugprivate.h>
#include <gsk/gskroundedrectprivate.h>
@@ -1361,7 +1362,7 @@ gsk_ngl_command_queue_do_upload_texture (GdkGLContext *context,
memory_texture = gdk_memory_texture_convert (memory_texture,
data_format,
- gdk_color_profile_get_srgb (),
+ gdk_color_profile_get_srgb_linear (),
&(GdkRectangle) { x, y, width, height });
bpp = gdk_memory_format_bytes_per_pixel (data_format);
diff --git a/gsk/ngl/gsknglglyphlibrary.c b/gsk/ngl/gsknglglyphlibrary.c
index df477b05f1..1e67bd098d 100644
--- a/gsk/ngl/gsknglglyphlibrary.c
+++ b/gsk/ngl/gsknglglyphlibrary.c
@@ -23,6 +23,7 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkprofilerprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
#include "gsknglcommandqueueprivate.h"
#include "gskngldriverprivate.h"
@@ -238,11 +239,11 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
gdk_memory_convert (pixel_data,
width * 4,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
- gdk_color_profile_get_srgb (),
+ gdk_color_profile_get_srgb_linear (),
cairo_image_surface_get_data (surface),
width * 4,
GDK_MEMORY_DEFAULT,
- gdk_color_profile_get_srgb (),
+ gdk_color_profile_get_srgb_linear (),
width, height);
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
diff --git a/gsk/ngl/gskngliconlibrary.c b/gsk/ngl/gskngliconlibrary.c
index afe13e1db6..3cdf84927c 100644
--- a/gsk/ngl/gskngliconlibrary.c
+++ b/gsk/ngl/gskngliconlibrary.c
@@ -25,6 +25,7 @@
#include <gdk/gdkmemorytextureprivate.h>
#include <gdk/gdkprofilerprivate.h>
#include <gdk/gdktextureprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
#include "gsknglcommandqueueprivate.h"
#include "gskngldriverprivate.h"
@@ -104,7 +105,7 @@ gsk_ngl_texture_prepare_upload (GdkGLContext *context,
return gdk_memory_texture_convert (memtex,
format,
- gdk_color_profile_get_srgb (),
+ gdk_color_profile_get_srgb_linear (),
NULL);
}
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index baf87f6461..7cfe98fa01 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -29,6 +29,7 @@
#include <gsk/gskrendernodeprivate.h>
#include <gsk/gskglshaderprivate.h>
#include <gdk/gdktextureprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
#include <gsk/gsktransformprivate.h>
#include <gsk/gskroundedrectprivate.h>
#include <math.h>
@@ -1162,6 +1163,9 @@ gsk_ngl_render_job_visit_as_fallback (GskNglRenderJob *job,
surface_width,
surface_height);
+ gdk_cairo_surface_set_color_profile (rendered_surface,
+ gdk_color_profile_get_srgb_linear ());
+
cairo_surface_set_device_scale (rendered_surface, scale_x, scale_y);
cr = cairo_create (rendered_surface);
@@ -3533,7 +3537,8 @@ gsk_ngl_render_job_visit_repeat_node (GskNglRenderJob *job,
/* If the size of the repeat node is smaller than the size of the
* child node, we don't repeat at all and can just draw that part
- * of the child texture... */
+ * of the child texture...
+ */
if (rect_contains_rect (child_bounds, &node->bounds))
{
gsk_ngl_render_job_visit_clipped_child (job, child, &node->bounds);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]