[gtk/wip/baedert/css-values: 2/31] gl renderer: Look at shadow color in the outset shadow cache



commit dd39bd438126707d576daa4051ac204d2ab0e646
Author: Timm Bäder <mail baedert org>
Date:   Sat Jan 11 11:26:27 2020 +0100

    gl renderer: Look at shadow color in the outset shadow cache
    
    It would probably be better to not do this and always render the outline
    in plain white, then later recolor it but do this for no, just for
    correctness.

 gsk/gl/gskglrenderer.c           |  5 ++++-
 gsk/gl/gskglshadowcache.c        | 14 ++++++++++----
 gsk/gl/gskglshadowcacheprivate.h |  2 ++
 3 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index fc13695654..91de970cac 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -1652,6 +1652,7 @@ render_outset_shadow_node (GskGLRenderer   *self,
 {
   const float scale = ops_get_scale (builder);
   const GskRoundedRect *outline = gsk_outset_shadow_node_peek_outline (node);
+  const GdkRGBA *color = gsk_outset_shadow_node_peek_color (node);
   const float blur_radius = gsk_outset_shadow_node_get_blur_radius (node);
   const float blur_extra = blur_radius * 3; /* 3 Because we use that in the shader as well */
   const float spread = gsk_outset_shadow_node_get_spread (node);
@@ -1696,6 +1697,7 @@ render_outset_shadow_node (GskGLRenderer   *self,
   cached_tid = gsk_gl_shadow_cache_get_texture_id (&self->shadow_cache,
                                                    self->gl_driver,
                                                    &scaled_outline,
+                                                   color,
                                                    blur_radius);
 
   if (cached_tid == 0)
@@ -1727,7 +1729,7 @@ render_outset_shadow_node (GskGLRenderer   *self,
       /* Draw outline */
       ops_set_program (builder, &self->color_program);
       ops_push_clip (builder, &scaled_outline);
-      ops_set_color (builder, gsk_outset_shadow_node_peek_color (node));
+      ops_set_color (builder, color);
       ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
         { { 0,                            }, { 0, 1 }, },
         { { 0,             texture_height }, { 0, 0 }, },
@@ -1754,6 +1756,7 @@ render_outset_shadow_node (GskGLRenderer   *self,
       gsk_gl_driver_mark_texture_permanent (self->gl_driver, blurred_texture_id);
       gsk_gl_shadow_cache_commit (&self->shadow_cache,
                                   &scaled_outline,
+                                  color,
                                   blur_radius,
                                   blurred_texture_id);
     }
diff --git a/gsk/gl/gskglshadowcache.c b/gsk/gl/gskglshadowcache.c
index 537989b805..57ef600403 100644
--- a/gsk/gl/gskglshadowcache.c
+++ b/gsk/gl/gskglshadowcache.c
@@ -7,12 +7,14 @@ typedef struct
 {
   GskRoundedRect outline;
   float blur_radius;
+  GdkRGBA color;
 } CacheKey;
 
 typedef struct
 {
   GskRoundedRect outline;
   float blur_radius;
+  GdkRGBA color;
 
   int texture_id;
   int unused_frames;
@@ -25,12 +27,13 @@ key_equal (const void *x,
   const CacheKey *a = x;
   const CacheKey *b = y;
 
-  return graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
+  return a->blur_radius == b->blur_radius &&
+         graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
          graphene_size_equal (&a->outline.corner[1], &b->outline.corner[1]) &&
          graphene_size_equal (&a->outline.corner[2], &b->outline.corner[2]) &&
          graphene_size_equal (&a->outline.corner[3], &b->outline.corner[3]) &&
          graphene_rect_equal (&a->outline.bounds, &b->outline.bounds) &&
-         a->blur_radius == b->blur_radius;
+         gdk_rgba_equal (&a->color, &b->color);
 }
 
 void
@@ -88,6 +91,7 @@ int
 gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache     *self,
                                     GskGLDriver          *gl_driver,
                                     const GskRoundedRect *shadow_rect,
+                                    const GdkRGBA        *color,
                                     float                 blur_radius)
 {
   CacheItem *item= NULL;
@@ -101,8 +105,8 @@ gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache     *self,
     {
       CacheItem *k = &g_array_index (self->textures, CacheItem, i);
 
-      if (key_equal (&(CacheKey){*shadow_rect, blur_radius},
-                     &(CacheKey){k->outline, k->blur_radius}))
+      if (key_equal (&(CacheKey){*shadow_rect, blur_radius, *color},
+                     &(CacheKey){k->outline, k->blur_radius, k->color}))
         {
           item = k;
           break;
@@ -122,6 +126,7 @@ gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache     *self,
 void
 gsk_gl_shadow_cache_commit (GskGLShadowCache     *self,
                             const GskRoundedRect *shadow_rect,
+                            const GdkRGBA        *color,
                             float                 blur_radius,
                             int                   texture_id)
 {
@@ -135,6 +140,7 @@ gsk_gl_shadow_cache_commit (GskGLShadowCache     *self,
   item = &g_array_index (self->textures, CacheItem, self->textures->len - 1);
 
   item->outline = *shadow_rect;
+  item->color = *color;
   item->blur_radius = blur_radius;
   item->unused_frames = 0;
   item->texture_id = texture_id;
diff --git a/gsk/gl/gskglshadowcacheprivate.h b/gsk/gl/gskglshadowcacheprivate.h
index 6623f16235..d4b03cc2a9 100644
--- a/gsk/gl/gskglshadowcacheprivate.h
+++ b/gsk/gl/gskglshadowcacheprivate.h
@@ -21,9 +21,11 @@ void gsk_gl_shadow_cache_begin_frame    (GskGLShadowCache     *self,
 int  gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache     *self,
                                          GskGLDriver          *gl_driver,
                                          const GskRoundedRect *shadow_rect,
+                                         const GdkRGBA        *color,
                                          float                 blur_radius);
 void gsk_gl_shadow_cache_commit         (GskGLShadowCache     *self,
                                          const GskRoundedRect *shadow_rect,
+                                         const GdkRGBA        *color,
                                          float                 blur_radius,
                                          int                   texture_id);
 


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