[gtk/wip/chergert/glproto: 634/920] add alpha location




commit 39c4560667d411b7e89741295170388a37a26324
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jan 2 17:22:08 2021 -0800

    add alpha location

 gsk/next/gskglprogram.c        | 12 +++++++++++-
 gsk/next/gskglprogramprivate.h |  4 +++-
 gsk/next/gskglrenderjob.c      | 26 ++++++++++++++++++--------
 3 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/gsk/next/gskglprogram.c b/gsk/next/gskglprogram.c
index 4585e8548f..f61a870a74 100644
--- a/gsk/next/gskglprogram.c
+++ b/gsk/next/gskglprogram.c
@@ -78,6 +78,7 @@ gsk_gl_program_init (GskGLProgram *self)
   self->projection_location = -1;
   self->modelview_location = -1;
   self->clip_rect_location = -1;
+  self->alpha_location = -1;
 }
 
 /**
@@ -134,6 +135,8 @@ gsk_gl_program_add_uniform (GskGLProgram *self,
     self->viewport_location = location;
   else if (key == UNIFORM_SHARED_CLIP_RECT)
     self->clip_rect_location = location;
+  else if (key == UNIFORM_SHARED_ALPHA)
+    self->alpha_location = location;
 
   return TRUE;
 }
@@ -162,7 +165,8 @@ gsk_gl_program_begin_draw (GskGLProgram            *self,
                            const graphene_rect_t   *viewport,
                            const graphene_matrix_t *projection,
                            const graphene_matrix_t *modelview,
-                           const GskRoundedRect    *clip)
+                           const GskRoundedRect    *clip,
+                           float                    alpha)
 {
   g_assert (GSK_IS_GL_PROGRAM (self));
   g_assert (viewport != NULL);
@@ -208,6 +212,12 @@ gsk_gl_program_begin_draw (GskGLProgram            *self,
                                                                                viewport->size.height));
     }
 
+  if (self->alpha_location > -1)
+    gsk_gl_command_queue_set_uniform1f (self->command_queue,
+                                        self->id,
+                                        self->alpha_location,
+                                        alpha);
+
   gsk_gl_command_queue_begin_draw (self->command_queue, self->id, viewport);
 }
 
diff --git a/gsk/next/gskglprogramprivate.h b/gsk/next/gskglprogramprivate.h
index 0539d39726..73f313d121 100644
--- a/gsk/next/gskglprogramprivate.h
+++ b/gsk/next/gskglprogramprivate.h
@@ -42,6 +42,7 @@ struct _GskGLProgram
   int                modelview_location;
   int                viewport_location;
   int                clip_rect_location;
+  int                alpha_location;
 };
 
 GskGLProgram *gsk_gl_program_new         (GskGLCommandQueue       *command_queue,
@@ -55,7 +56,8 @@ void          gsk_gl_program_begin_draw  (GskGLProgram            *self,
                                           const graphene_rect_t   *viewport,
                                           const graphene_matrix_t *projection,
                                           const graphene_matrix_t *modelview,
-                                          const GskRoundedRect    *clip);
+                                          const GskRoundedRect    *clip,
+                                          float                    alpha);
 void          gsk_gl_program_end_draw    (GskGLProgram            *self);
 
 static inline int
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index 1430db7cfc..e13109d019 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -70,6 +70,7 @@ struct _GskGLRenderJob
   graphene_matrix_t  projection;
   GArray            *modelview;
   GArray            *clip;
+  float              alpha;
   float              offset_x;
   float              offset_y;
   float              scale_x;
@@ -547,6 +548,7 @@ gsk_gl_render_job_new (GskNextDriver         *driver,
   job->viewport = *viewport;
   job->region = region ? cairo_region_copy (region) : NULL;
   job->flip_y = !!flip_y;
+  job->alpha = 1.0;
 
   init_projection_matrix (&job->projection, viewport, flip_y);
   gsk_gl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_factor, scale_factor));
@@ -717,7 +719,8 @@ gsk_gl_render_job_visit_color_node (GskGLRenderJob *job,
                              &job->viewport,
                              &job->projection,
                              &modelview->matrix,
-                             gsk_gl_render_job_get_clip (job));
+                             gsk_gl_render_job_get_clip (job),
+                             job->alpha);
   gsk_gl_program_set_uniform_color (job->driver->color,
                                     UNIFORM_COLOR_COLOR,
                                     gsk_color_node_get_color (node));
@@ -741,7 +744,8 @@ gsk_gl_render_job_visit_linear_gradient_node (GskGLRenderJob *job,
                              &job->viewport,
                              &job->projection,
                              &modelview->matrix,
-                             gsk_gl_render_job_get_clip (job));
+                             gsk_gl_render_job_get_clip (job),
+                             job->alpha);
   gsk_gl_program_set_uniform1i (job->driver->linear_gradient,
                                 UNIFORM_LINEAR_GRADIENT_NUM_COLOR_STOPS,
                                 n_color_stops);
@@ -775,7 +779,8 @@ gsk_gl_render_job_visit_conic_gradient_node (GskGLRenderJob *job,
                              &job->viewport,
                              &job->projection,
                              &modelview->matrix,
-                             gsk_gl_render_job_get_clip (job));
+                             gsk_gl_render_job_get_clip (job),
+                             job->alpha);
   gsk_gl_program_set_uniform1i (job->driver->conic_gradient,
                                 UNIFORM_CONIC_GRADIENT_NUM_COLOR_STOPS,
                                 n_color_stops);
@@ -848,7 +853,8 @@ gsk_gl_render_job_visit_clipped_child (GskGLRenderJob       *job,
                                  &job->viewport,
                                  &job->projection,
                                  &modelview->matrix,
-                                 &clip->bounds);
+                                 &clip->bounds,
+                                 job->alpha);
       gsk_gl_program_set_uniform_texture (job->driver->blit,
                                           UNIFORM_SHARED_SOURCE,
                                           GL_TEXTURE_2D,
@@ -1026,7 +1032,8 @@ gsk_gl_render_job_visit_uniform_border_node (GskGLRenderJob *job,
                              &job->viewport,
                              &job->projection,
                              &modelview->matrix,
-                             gsk_gl_render_job_get_clip (job));
+                             gsk_gl_render_job_get_clip (job),
+                             job->alpha);
   gsk_gl_program_set_uniform_rounded_rect (job->driver->inset_shadow,
                                            UNIFORM_INSET_SHADOW_OUTLINE_RECT,
                                            rounded_outline);
@@ -1175,7 +1182,8 @@ gsk_gl_render_job_visit_border_node (GskGLRenderJob *job,
                                    &job->viewport,
                                    &job->projection,
                                    &modelview->matrix,
-                                   gsk_gl_render_job_get_clip (job));
+                                   gsk_gl_render_job_get_clip (job),
+                                   job->alpha);
         gsk_gl_program_set_uniform4fv (job->driver->border,
                                        UNIFORM_BORDER_COLOR,
                                        1,
@@ -1242,7 +1250,8 @@ gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
                              &job->viewport,
                              &job->projection,
                              &modelview->matrix,
-                             gsk_gl_render_job_get_clip (job));
+                             gsk_gl_render_job_get_clip (job),
+                             job->alpha);
   gsk_gl_program_set_uniform_rounded_rect (job->driver->inset_shadow,
                                            UNIFORM_INSET_SHADOW_OUTLINE_RECT,
                                            gsk_inset_shadow_node_get_outline (node));
@@ -1294,7 +1303,8 @@ gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
                              &job->viewport,
                              &job->projection,
                              &modelview->matrix,
-                             gsk_gl_render_job_get_clip (job));
+                             gsk_gl_render_job_get_clip (job),
+                             job->alpha);
   gsk_gl_program_set_uniform_rounded_rect (job->driver->unblurred_outset_shadow,
                                            UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT,
                                            outline);


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