[mutter/gbsneto/graphene-matrix: 32/39] cogl: Use graphene APIs




commit 73e3ccb2bd54bc1b9d9c89995574f5bdc4ded4e1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Sep 11 18:45:25 2020 -0300

    cogl: Use graphene APIs
    
    These are the easy, trivial ones.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 cogl/cogl/cogl-clip-stack.c                      |  4 +---
 cogl/cogl/cogl-context.c                         |  6 +++---
 cogl/cogl/cogl-framebuffer.c                     |  3 +--
 cogl/cogl/cogl-pipeline-layer-state.c            |  6 +++---
 cogl/cogl/cogl-pipeline-layer.c                  |  2 +-
 cogl/cogl/cogl-pipeline-state.h                  |  2 +-
 cogl/cogl/driver/gl/cogl-clip-stack-gl.c         | 16 +++++++++-------
 cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c | 20 +++++++++-----------
 8 files changed, 28 insertions(+), 31 deletions(-)
---
diff --git a/cogl/cogl/cogl-clip-stack.c b/cogl/cogl/cogl-clip-stack.c
index 0deb576b10..e39f5b9096 100644
--- a/cogl/cogl/cogl-clip-stack.c
+++ b/cogl/cogl/cogl-clip-stack.c
@@ -193,9 +193,7 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
   cogl_matrix_entry_get (modelview_entry, &modelview);
   cogl_matrix_entry_get (projection_entry, &projection);
 
-  cogl_matrix_multiply (&modelview_projection,
-                        &projection,
-                        &modelview);
+  graphene_matrix_multiply (&modelview, &projection, &modelview_projection);
 
   /* Technically we could avoid the viewport transform at this point
    * if we want to make this a bit faster. */
diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c
index 1275439b65..85002cdec2 100644
--- a/cogl/cogl/cogl-context.c
+++ b/cogl/cogl/cogl-context.c
@@ -221,9 +221,9 @@ cogl_context_new (CoglDisplay *display,
 
   context->legacy_backface_culling_enabled = FALSE;
 
-  cogl_matrix_init_identity (&context->identity_matrix);
-  cogl_matrix_init_identity (&context->y_flip_matrix);
-  cogl_matrix_scale (&context->y_flip_matrix, 1, -1, 1);
+  graphene_matrix_init_identity (&context->identity_matrix);
+  graphene_matrix_init_identity (&context->y_flip_matrix);
+  graphene_matrix_scale (&context->y_flip_matrix, 1, -1, 1);
 
   context->opaque_color_pipeline = cogl_pipeline_new (context);
 
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 82ef0aad3c..21fdf2e978 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -1585,8 +1585,7 @@ cogl_framebuffer_orthographic (CoglFramebuffer *framebuffer,
    * so we need to flush all journaled primitives first... */
   _cogl_framebuffer_flush_journal (framebuffer);
 
-  cogl_matrix_init_identity (&ortho);
-  cogl_matrix_orthographic (&ortho, x_1, y_1, x_2, y_2, near, far);
+  graphene_matrix_init_ortho (&ortho, x_1, x_2, y_2, y_1, near, far);
   cogl_matrix_stack_set (projection_stack, &ortho);
 
   if (framebuffer->context->current_draw_buffer == framebuffer)
diff --git a/cogl/cogl/cogl-pipeline-layer-state.c b/cogl/cogl/cogl-pipeline-layer-state.c
index 894270d5dd..0260f90db0 100644
--- a/cogl/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl/cogl-pipeline-layer-state.c
@@ -789,7 +789,7 @@ _cogl_pipeline_layer_user_matrix_equal (CoglPipelineLayer *authority0,
   CoglPipelineLayerBigState *big_state0 = authority0->big_state;
   CoglPipelineLayerBigState *big_state1 = authority1->big_state;
 
-  if (!cogl_matrix_equal (&big_state0->matrix, &big_state1->matrix))
+  if (!graphene_matrix_equal (&big_state0->matrix, &big_state1->matrix))
     return FALSE;
 
   return TRUE;
@@ -1164,7 +1164,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
    * state we want to change */
   authority = _cogl_pipeline_layer_get_authority (layer, state);
 
-  if (cogl_matrix_equal (matrix, &authority->big_state->matrix))
+  if (graphene_matrix_equal (matrix, &authority->big_state->matrix))
     return;
 
   new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state);
@@ -1183,7 +1183,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
           CoglPipelineLayer *old_authority =
             _cogl_pipeline_layer_get_authority (parent, state);
 
-          if (cogl_matrix_equal (matrix, &old_authority->big_state->matrix))
+          if (graphene_matrix_equal (matrix, &old_authority->big_state->matrix))
             {
               layer->differences &= ~state;
 
diff --git a/cogl/cogl/cogl-pipeline-layer.c b/cogl/cogl/cogl-pipeline-layer.c
index 18d0140abe..32133352a4 100644
--- a/cogl/cogl/cogl-pipeline-layer.c
+++ b/cogl/cogl/cogl-pipeline-layer.c
@@ -768,7 +768,7 @@ _cogl_pipeline_init_default_layers (void)
 
   big_state->point_sprite_coords = FALSE;
 
-  cogl_matrix_init_identity (&big_state->matrix);
+  graphene_matrix_init_identity (&big_state->matrix);
 
   ctx->default_layer_0 = _cogl_pipeline_layer_object_new (layer);
 
diff --git a/cogl/cogl/cogl-pipeline-state.h b/cogl/cogl/cogl-pipeline-state.h
index 0439041a2d..4387685462 100644
--- a/cogl/cogl/cogl-pipeline-state.h
+++ b/cogl/cogl/cogl-pipeline-state.h
@@ -716,7 +716,7 @@ cogl_pipeline_set_uniform_int (CoglPipeline *pipeline,
  * If @transpose is %FALSE then the matrix is expected to be in
  * column-major order or if it is %TRUE then the matrix is in
  * row-major order. You can pass a #graphene_matrix_t by calling by passing
- * the result of cogl_matrix_to_float() in @value and setting
+ * the result of graphene_matrix_to_float() in @value and setting
  * @transpose to %FALSE.
  *
  * Since: 2.0
diff --git a/cogl/cogl/driver/gl/cogl-clip-stack-gl.c b/cogl/cogl/driver/gl/cogl-clip-stack-gl.c
index ee398f47c6..c528365979 100644
--- a/cogl/cogl/driver/gl/cogl-clip-stack-gl.c
+++ b/cogl/cogl/driver/gl/cogl-clip-stack-gl.c
@@ -137,6 +137,7 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
   int num_rectangles = cairo_region_num_rectangles (region);
   int i;
   CoglVertexP2 *vertices;
+  graphene_point3d_t p;
 
   /* NB: This can be called while flushing the journal so we need
    * to be very conservative with what state we change.
@@ -151,17 +152,18 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
    * make a matrix that translates those across the viewport, and into
    * the default [-1, -1, 1, 1] range.
    */
-  cogl_matrix_init_identity (&matrix);
-  cogl_matrix_translate (&matrix, -1, 1, 0);
-  cogl_matrix_scale (&matrix,
-                     2.0 / framebuffer->viewport_width,
-                     - 2.0 / framebuffer->viewport_height,
-                     1);
-  cogl_matrix_translate (&matrix,
+  graphene_point3d_init (&p,
                          - framebuffer->viewport_x,
                          - framebuffer->viewport_y,
                          0);
 
+  graphene_matrix_init_translate (&matrix, &p);
+  graphene_matrix_scale (&matrix,
+                         2.0 / framebuffer->viewport_width,
+                         - 2.0 / framebuffer->viewport_height,
+                         1);
+  graphene_matrix_translate (&matrix, &GRAPHENE_POINT3D_INIT (-1.f, 1.f, 0.f));
+
   GE( ctx, glColorMask (FALSE, FALSE, FALSE, FALSE) );
   GE( ctx, glDepthMask (FALSE) );
 
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c 
b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c
index 33cc4a634b..88c0adc770 100644
--- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c
@@ -435,7 +435,7 @@ update_constants_cb (CoglPipeline *pipeline,
       float array[16];
 
       matrix = _cogl_pipeline_get_layer_matrix (pipeline, layer_index);
-      cogl_matrix_to_float (matrix, array);
+      graphene_matrix_to_float (matrix, array);
       GE (ctx, glUniformMatrix4fv (unit_state->texture_matrix_uniform,
                                    1, FALSE, array));
       unit_state->dirty_texture_matrix = FALSE;
@@ -1053,9 +1053,9 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline,
             {
               graphene_matrix_t tmp_matrix;
               cogl_matrix_entry_get (projection_entry, &tmp_matrix);
-              cogl_matrix_multiply (&projection,
-                                    &ctx->y_flip_matrix,
-                                    &tmp_matrix);
+              graphene_matrix_multiply (&tmp_matrix,
+                                        &ctx->y_flip_matrix,
+                                        &projection);
             }
           else
             cogl_matrix_entry_get (projection_entry, &projection);
@@ -1063,7 +1063,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline,
 
       if (projection_changed && program_state->projection_uniform != -1)
         {
-          cogl_matrix_to_float (&projection, v);
+          graphene_matrix_to_float (&projection, v);
           GE (ctx, glUniformMatrix4fv (program_state->projection_uniform,
                                        1, /* count */
                                        FALSE, /* transpose */
@@ -1072,7 +1072,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline,
 
       if (modelview_changed && program_state->modelview_uniform != -1)
         {
-          cogl_matrix_to_float (&modelview,v);
+          graphene_matrix_to_float (&modelview,v);
           GE (ctx, glUniformMatrix4fv (program_state->modelview_uniform,
                                        1, /* count */
                                        FALSE, /* transpose */
@@ -1086,7 +1086,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline,
              avoiding the matrix multiplication */
           if (cogl_matrix_entry_is_identity (modelview_entry))
             {
-              cogl_matrix_to_float (&projection, v);
+              graphene_matrix_to_float (&projection, v);
               GE (ctx,
                   glUniformMatrix4fv (program_state->mvp_uniform,
                                       1, /* count */
@@ -1097,10 +1097,8 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline,
             {
               graphene_matrix_t combined;
 
-              cogl_matrix_multiply (&combined,
-                                    &projection,
-                                    &modelview);
-              cogl_matrix_to_float (&combined, v);
+              graphene_matrix_multiply (&modelview, &projection, &combined);
+              graphene_matrix_to_float (&combined, v);
 
               GE (ctx,
                   glUniformMatrix4fv (program_state->mvp_uniform,


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