From 761346ed5a2371b320a39c32c77322c5c4cc0a9b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 13 Jul 2024 02:03:20 +0200 Subject: [PATCH 1/2] gpu: Remove unused macro This is a leftover from the pre-color-managed times --- gsk/gpu/gskgpuclearop.c | 4 ++-- gsk/gpu/gskgpushaderopprivate.h | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/gsk/gpu/gskgpuclearop.c b/gsk/gpu/gskgpuclearop.c index 9dafa674f7..1753a8b762 100644 --- a/gsk/gpu/gskgpuclearop.c +++ b/gsk/gpu/gskgpuclearop.c @@ -4,8 +4,8 @@ #include "gskgpuopprivate.h" #include "gskgpuprintprivate.h" -/* for gsk_gpu_rgba_to_float() */ -#include "gskgpushaderopprivate.h" + +#include "gdk/gdkcolorstateprivate.h" typedef struct _GskGpuClearOp GskGpuClearOp; diff --git a/gsk/gpu/gskgpushaderopprivate.h b/gsk/gpu/gskgpushaderopprivate.h index 492b45fe18..82dc6ed463 100644 --- a/gsk/gpu/gskgpushaderopprivate.h +++ b/gsk/gpu/gskgpushaderopprivate.h @@ -66,16 +66,6 @@ GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuO GskGpuFrame *frame, GskGLCommandState *state); -static inline void -gsk_gpu_rgba_to_float (const GdkRGBA *rgba, - float values[4]) -{ - values[0] = rgba->red; - values[1] = rgba->green; - values[2] = rgba->blue; - values[3] = rgba->alpha; -} - #define GSK_RGBA_TO_VEC4(_color) (float[4]) { (_color)->red, (_color)->green, (_color)->blue, (_color)->alpha } #define GSK_RGBA_TO_VEC4_ALPHA(_color, _alpha) (float[4]) { (_color)->red, (_color)->green, (_color)->blue, (_color)->alpha * (_alpha) } From d54b68b93cc75df23d984cdfc0ff176824368527 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 13 Jul 2024 02:05:41 +0200 Subject: [PATCH 2/2] gpu: Convert values to float[4] from GdkRGBA We need to make sure our clear values are in the right colorstate, not in sRGB. The occluision culling managed to sneak through the big transition for that. --- gsk/gpu/gskgpunodeprocessor.c | 10 ++++++---- gsk/gpu/gskgpurenderpassop.c | 4 ++-- gsk/gpu/gskgpurenderpassopprivate.h | 2 +- gsk/gpu/gskgpushaderopprivate.h | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 1d5a9be21d..c5846cf571 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -384,7 +384,7 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self, gsk_gpu_render_pass_begin_op (frame, image, &area, - &GDK_RGBA_TRANSPARENT, + GSK_VEC4_TRANSPARENT, GSK_RENDER_PASS_OFFSCREEN); return image; @@ -697,7 +697,7 @@ gsk_gpu_copy_image (GskGpuFrame *frame, gsk_gpu_render_pass_begin_op (other.frame, copy, &(cairo_rectangle_int_t) { 0, 0, width, height }, - &GDK_RGBA_TRANSPARENT, + GSK_VEC4_TRANSPARENT, GSK_RENDER_PASS_OFFSCREEN); gsk_gpu_node_processor_sync_globals (&other, 0); @@ -1627,6 +1627,7 @@ gsk_gpu_node_processor_add_first_color_node (GskGpuNodeProcessor *self, GskRenderNode *node) { graphene_rect_t clip_bounds; + float color[4]; if (!node->fully_opaque) return FALSE; @@ -1635,10 +1636,11 @@ gsk_gpu_node_processor_add_first_color_node (GskGpuNodeProcessor *self, if (!gsk_rect_contains_rect (&node->bounds, &clip_bounds)) return FALSE; + gdk_color_state_from_rgba (self->ccs, gsk_color_node_get_color (node), color); gsk_gpu_render_pass_begin_op (self->frame, target, clip, - gsk_color_node_get_color (node), + color, pass_type); return TRUE; @@ -3921,7 +3923,7 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame, gsk_gpu_render_pass_begin_op (frame, target, clip, - &GDK_RGBA_TRANSPARENT, + GSK_VEC4_TRANSPARENT, pass_type); gsk_gpu_node_processor_add_node (&self, node); diff --git a/gsk/gpu/gskgpurenderpassop.c b/gsk/gpu/gskgpurenderpassop.c index ac5d2a1028..ef5b54c2eb 100644 --- a/gsk/gpu/gskgpurenderpassop.c +++ b/gsk/gpu/gskgpurenderpassop.c @@ -330,7 +330,7 @@ void gsk_gpu_render_pass_begin_op (GskGpuFrame *frame, GskGpuImage *image, const cairo_rectangle_int_t *area, - const GdkRGBA *clear_color_or_null, + float clear_color_or_null[4], GskRenderPassType pass_type) { GskGpuRenderPassOp *self; @@ -341,7 +341,7 @@ gsk_gpu_render_pass_begin_op (GskGpuFrame *frame, self->area = *area; self->clear = clear_color_or_null != NULL; if (clear_color_or_null) - gsk_gpu_rgba_to_float (clear_color_or_null, self->clear_color); + gsk_gpu_color_to_float (clear_color_or_null, self->clear_color); self->pass_type = pass_type; } diff --git a/gsk/gpu/gskgpurenderpassopprivate.h b/gsk/gpu/gskgpurenderpassopprivate.h index 174841416e..cdfa3aa5ff 100644 --- a/gsk/gpu/gskgpurenderpassopprivate.h +++ b/gsk/gpu/gskgpurenderpassopprivate.h @@ -11,7 +11,7 @@ G_BEGIN_DECLS void gsk_gpu_render_pass_begin_op (GskGpuFrame *frame, GskGpuImage *image, const cairo_rectangle_int_t *area, - const GdkRGBA *clear_color_or_null, + float clear_color_or_null[4], GskRenderPassType pass_type); void gsk_gpu_render_pass_end_op (GskGpuFrame *frame, GskGpuImage *image, diff --git a/gsk/gpu/gskgpushaderopprivate.h b/gsk/gpu/gskgpushaderopprivate.h index 82dc6ed463..4c80d85b74 100644 --- a/gsk/gpu/gskgpushaderopprivate.h +++ b/gsk/gpu/gskgpushaderopprivate.h @@ -68,6 +68,7 @@ GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuO #define GSK_RGBA_TO_VEC4(_color) (float[4]) { (_color)->red, (_color)->green, (_color)->blue, (_color)->alpha } #define GSK_RGBA_TO_VEC4_ALPHA(_color, _alpha) (float[4]) { (_color)->red, (_color)->green, (_color)->blue, (_color)->alpha * (_alpha) } +#define GSK_VEC4_TRANSPARENT (float[4]) { 0.0f, 0.0f, 0.0f, 0.0f } static inline void gsk_gpu_color_to_float (const float color[4],