[gtk/wip/baedert/for-master: 13/13] gl renderer: Cache current scale in RenderNodeBuilder



commit 175559973a92a190515f432dae75e0368121d468
Author: Timm Bäder <mail baedert org>
Date:   Fri Nov 29 14:40:20 2019 +0100

    gl renderer: Cache current scale in RenderNodeBuilder
    
    We call ops_get_scale a lot, so this should be better. It will also make
    a later x/y split for the scaling easier.

 gsk/gl/gskglrenderops.c        | 15 +++++++++------
 gsk/gl/gskglrenderopsprivate.h |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index 4c6e2a7b35..1c4f679e43 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -30,6 +30,8 @@ ops_finish (RenderOpBuilder *builder)
 
   builder->dx = 0;
   builder->dy = 0;
+  builder->scale_x = 1;
+  builder->scale_y = 1;
   builder->current_modelview = NULL;
   builder->current_clip = NULL;
   builder->current_render_target = 0;
@@ -84,16 +86,11 @@ ops_pop_debug_group (RenderOpBuilder *builder)
 float
 ops_get_scale (const RenderOpBuilder *builder)
 {
-  const MatrixStackEntry *head;
-
   g_assert (builder->mv_stack != NULL);
   g_assert (builder->mv_stack->len >= 1);
 
-  head = &g_array_index (builder->mv_stack, MatrixStackEntry, builder->mv_stack->len - 1);
-
   /* TODO: Use two separate values */
-  return MAX (head->metadata.scale_x,
-              head->metadata.scale_y);
+  return MAX (builder->scale_x, builder->scale_y);
 }
 
 static void
@@ -400,6 +397,8 @@ ops_set_modelview (RenderOpBuilder *builder,
   builder->dx = 0;
   builder->dy = 0;
   builder->current_modelview = entry->transform;
+  builder->scale_x = entry->metadata.scale_x;
+  builder->scale_y = entry->metadata.scale_y;
   ops_set_modelview_internal (builder, entry->transform);
 }
 
@@ -443,6 +442,8 @@ ops_push_modelview (RenderOpBuilder *builder,
 
   builder->dx = 0;
   builder->dy = 0;
+  builder->scale_x = entry->metadata.scale_x;
+  builder->scale_y = entry->metadata.scale_y;
   builder->current_modelview = entry->transform;
   ops_set_modelview_internal (builder, entry->transform);
 }
@@ -465,6 +466,8 @@ ops_pop_modelview (RenderOpBuilder *builder)
 
   if (builder->mv_stack->len >= 1)
     {
+      builder->scale_x = head->metadata.scale_x;
+      builder->scale_y = head->metadata.scale_y;
       builder->current_modelview = head->transform;
       ops_set_modelview_internal (builder, head->transform);
     }
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index 93f504f287..75ae2ac5fd 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -152,6 +152,7 @@ typedef struct
   graphene_rect_t current_viewport;
   float current_opacity;
   float dx, dy;
+  float scale_x, scale_y;
 
   OpBuffer render_ops;
   GArray *vertices;


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