[cogl] tests: avoid redundant setting of projection/modelview



commit 6c0dd4aab1b5ab34d18639d60193189c136a4898
Author: Robert Bragg <robert linux intel com>
Date:   Sat Oct 1 15:34:24 2011 +0100

    tests: avoid redundant setting of projection/modelview
    
    This removes some redundant initializing of the modelview matrix since
    we can assume the initial state is already the identity matrix. The
    explicit initialization was only really necessary when running as a
    clutter test because there the default matrix isn't the identity matrix.
    
    Also some calls to cogl_orth to change the projection matrix have been
    moved into the test entry point functions instead of calling this in the
    paint function. Again the previous style probably came about because
    with clutter we always had to re-assert the projection but now we are in
    full control of the projection and can assume it doesn't need
    re-asserting once set.
    
    Acked-by: Luca Bruno <lucabru src gnome org>

 tests/conform/test-depth-test.c         |   21 +++++----------------
 tests/conform/test-just-vertex-shader.c |   24 ++++--------------------
 2 files changed, 9 insertions(+), 36 deletions(-)
---
diff --git a/tests/conform/test-depth-test.c b/tests/conform/test-depth-test.c
index 1cbfd96..006cedb 100644
--- a/tests/conform/test-depth-test.c
+++ b/tests/conform/test-depth-test.c
@@ -18,8 +18,7 @@
 
 typedef struct _TestState
 {
-  int width;
-  int height;
+  int dummy;
 } TestState;
 
 typedef struct
@@ -142,16 +141,6 @@ test_depth (TestState *state,
 static void
 paint (TestState *state)
 {
-  CoglMatrix identity;
-
-  cogl_ortho (0, state->width, /* left, right */
-              state->height, 0, /* bottom, top */
-              -1, 100 /* z near, far */);
-
-  cogl_push_matrix ();
-  cogl_matrix_init_identity (&identity);
-  cogl_set_modelview_matrix (&identity);
-
   /* Sanity check a few of the different depth test functions
    * and that depth writing can be disabled... */
 
@@ -270,8 +259,6 @@ paint (TestState *state)
                 &rect0_state, &rect1_state, NULL,
                 0x00ff00ff); /* expected */
   }
-
-  cogl_pop_matrix ();
 }
 
 void
@@ -281,8 +268,10 @@ test_cogl_depth_test (TestUtilsGTestFixture *fixture,
   TestUtilsSharedState *shared_state = data;
   TestState state;
 
-  state.width = cogl_framebuffer_get_width (shared_state->fb);
-  state.height = cogl_framebuffer_get_height (shared_state->fb);
+  cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
+              cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
+              -1, 100 /* z near, far */);
+
   paint (&state);
 
   if (g_test_verbose ())
diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c
index d316b0a..7b809cd 100644
--- a/tests/conform/test-just-vertex-shader.c
+++ b/tests/conform/test-just-vertex-shader.c
@@ -6,8 +6,7 @@
 
 typedef struct _TestState
 {
-  int width;
-  int height;
+  int dummy;
 } TestState;
 
 static void
@@ -17,18 +16,10 @@ paint_legacy (TestState *state)
   CoglColor color;
   GError *error = NULL;
   CoglHandle shader, program;
-  CoglMatrix identity;
-
-  cogl_ortho (0, state->width, /* left, right */
-              state->height, 0, /* bottom, top */
-              -1, 100 /* z near, far */);
 
   cogl_color_init_from_4ub (&color, 0, 0, 0, 255);
   cogl_clear (&color, COGL_BUFFER_BIT_COLOR);
 
-  cogl_matrix_init_identity (&identity);
-  cogl_set_modelview_matrix (&identity);
-
   /* Set the primary vertex color as red */
   cogl_color_set_from_4ub (&color, 0xff, 0x00, 0x00, 0xff);
   cogl_material_set_color (material, &color);
@@ -92,18 +83,10 @@ paint (TestState *state)
   CoglColor color;
   GError *error = NULL;
   CoglHandle shader, program;
-  CoglMatrix identity;
-
-  cogl_ortho (0, state->width, /* left, right */
-              state->height, 0, /* bottom, top */
-              -1, 100 /* z near, far */);
 
   cogl_color_init_from_4ub (&color, 0, 0, 0, 255);
   cogl_clear (&color, COGL_BUFFER_BIT_COLOR);
 
-  cogl_matrix_init_identity (&identity);
-  cogl_set_modelview_matrix (&identity);
-
   /* Set the primary vertex color as red */
   cogl_color_set_from_4ub (&color, 0xff, 0x00, 0x00, 0xff);
   cogl_pipeline_set_color (pipeline, &color);
@@ -197,8 +180,9 @@ test_cogl_just_vertex_shader (TestUtilsGTestFixture *fixture,
   TestUtilsSharedState *shared_state = data;
   TestState state;
 
-  state.width = cogl_framebuffer_get_width (shared_state->fb);
-  state.height = cogl_framebuffer_get_height (shared_state->fb);
+  cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
+              cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
+              -1, 100 /* z near, far */);
 
   /* If shaders aren't supported then we can't run the test */
   if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))



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