[gtk+/wip/baedert/gl: 81/95] gl renderer: Don't render opacity nodes offscreen



commit bbfc50a834374db511e3bca964669212854d59db
Author: Timm Bäder <mail baedert org>
Date:   Thu Dec 7 17:30:02 2017 +0100

    gl renderer: Don't render opacity nodes offscreen
    
    We already drag a u_alpha uniform around in every shader, so use that
    one.

 gsk/gl/gskglrenderer.c         |   30 +++---------------------------
 gsk/gl/gskglrenderops.c        |   11 +++++++++++
 gsk/gl/gskglrenderopsprivate.h |    1 +
 3 files changed, 15 insertions(+), 27 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index fb98de3..0555da7 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -1029,37 +1029,13 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer   *self,
 
     case GSK_OPACITY_NODE:
       {
-        int texture_id;
-        gboolean is_offscreen;
         float prev_opacity;
 
+        prev_opacity = ops_set_opacity (builder,
+                                        builder->current_opacity * gsk_opacity_node_get_opacity (node));
 
-        add_offscreen_ops (self, builder, min_x, max_x, min_y, max_y,
-                           gsk_opacity_node_get_child (node),
-                           &texture_id, &is_offscreen);
-
-        /* Now draw the texture with the node's opacity */
-        ops_set_program (builder, &self->blit_program);
-        prev_opacity = ops_set_opacity (builder, gsk_opacity_node_get_opacity (node));
-        ops_set_texture (builder, texture_id);
-
-        if (is_offscreen)
-          {
-            GskQuadVertex vertex_data[GL_N_VERTICES] = {
-              { { min_x, min_y }, { 0, 1 }, },
-              { { min_x, max_y }, { 0, 0 }, },
-              { { max_x, min_y }, { 1, 1 }, },
+        gsk_gl_renderer_add_render_ops (self, gsk_opacity_node_get_child (node), builder);
 
-              { { max_x, max_y }, { 1, 0 }, },
-              { { min_x, max_y }, { 0, 0 }, },
-              { { max_x, min_y }, { 1, 1 }, },
-            };
-            ops_draw (builder, vertex_data);
-          }
-        else
-          {
-            ops_draw (builder, vertex_data);
-          }
         ops_set_opacity (builder, prev_opacity);
       }
     break;
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index 8e96888..d3fa195 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -65,6 +65,14 @@ ops_set_program (RenderOpBuilder *builder,
       g_array_append_val (builder->render_ops, op);
       builder->program_state[program->index].clip = builder->current_clip;
     }
+
+  if (builder->program_state[program->index].opacity != builder->current_opacity)
+    {
+      op.op = OP_CHANGE_OPACITY;
+      op.opacity = builder->current_opacity;
+      g_array_append_val (builder->render_ops, op);
+      builder->program_state[program->index].opacity = builder->current_opacity;
+    }
 }
 
 GskRoundedRect
@@ -244,6 +252,9 @@ ops_set_opacity (RenderOpBuilder *builder,
   prev_opacity = builder->current_opacity;
   builder->current_opacity = opacity;
 
+  if (builder->current_program != NULL)
+    builder->program_state[builder->current_program->index].opacity = opacity;
+
   return prev_opacity;
 }
 
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index 7e35373..7a7ed39 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -174,6 +174,7 @@ typedef struct
     graphene_matrix_t projection;
     int source_texture;
     graphene_rect_t viewport;
+    float opacity;
     /* Per-program state */
     union {
       GdkRGBA color;


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