Improves the unit test to verify more awkward scaling and some corresponding fixes
authorRobert Bragg <robert@linux.intel.com>
Mon, 19 Jan 2009 19:11:00 +0000 (19:11 +0000)
committerRobert Bragg <robert@linux.intel.com>
Tue, 20 Jan 2009 11:03:50 +0000 (11:03 +0000)
This simplifies the mucking about with the model-view matrix that was previously
done which improves its efficiency when scaling is necessary.

Notably: There should now be no performance advantage to using
ClutterCloneTexture as a special case clone actor since this method is just as
efficient.

The unit test was renamed to test-actor-clone.

clutter/clutter-actor-clone.c
tests/interactive/Makefile.am
tests/interactive/test-actor-clone.c [moved from tests/interactive/test-actors2.c with 97% similarity]

index 0e5b2b8..c70aef6 100644 (file)
@@ -99,10 +99,6 @@ clutter_actor_clone_paint (ClutterActor *self)
   ClutterGeometry           clone_source_geom;
   float                     x_scale;
   float                     y_scale;
-  ClutterActor             *stage;
-  ClutterPerspective        perspective;
-  guint                     stage_width;
-  guint                     stage_height;
 
   CLUTTER_NOTE (PAINT,
                 "painting clone actor '%s'",
@@ -115,40 +111,11 @@ clutter_actor_clone_paint (ClutterActor *self)
 
   /* We need to scale what the clone-source actor paints to fill our own
    * allocation... */
-  x_scale = geom.width / clone_source_geom.width;
-  y_scale = geom.height / clone_source_geom.height;
 
-  /* Once we have calculated the scale factors it's a case of pushing
-   * the scale factors to the bottom of the current model view stack...
-   */
-  if (x_scale != 1.0 || y_scale != 1.0)
-    {
-      /*
-       * FIXME - this is quite expensive, it would be good it clutter kept
-       * the model view matrix changes made by cogl_setup_viewport seperate
-       * from those made while painting actors so we could simply replace the
-       * later by multiplying it with the scale avoiding the call to
-       * _clutter_actor_apply_modelview_transform_recursive.
-       */
-
-      stage = clutter_actor_get_stage (self);
-      if (!stage)
-        return;
-
-      clutter_actor_get_size (stage, &stage_width, &stage_height);
-      clutter_stage_get_perspectivex (CLUTTER_STAGE (stage), &perspective);
-
-      cogl_setup_viewport (stage_width, stage_height,
-                           perspective.fovy,
-                           perspective.aspect,
-                           perspective.z_near,
-                           perspective.z_far);
-
-      cogl_scale (COGL_FIXED_FROM_FLOAT (x_scale),
-                  COGL_FIXED_FROM_FLOAT (y_scale));
-
-      _clutter_actor_apply_modelview_transform_recursive (self, NULL);
-    }
+  x_scale = (float)geom.width / clone_source_geom.width;
+  y_scale = (float)geom.height / clone_source_geom.height;
+
+  cogl_scale (COGL_FIXED_FROM_FLOAT (x_scale), COGL_FIXED_FROM_FLOAT (y_scale));
 
   /* The final bits of magic:
    * - We need to make sure that when the clone-source actor's paint method
index 54b6c48..e10e1cf 100644 (file)
@@ -5,7 +5,7 @@ UNIT_TESTS = \
        test-offscreen.c \
        test-scale.c \
         test-actors.c \
-        test-actors2.c \
+        test-actor-clone.c \
        test-behave.c \
        test-project.c \
        test-perspective.c \
similarity index 97%
rename from tests/interactive/test-actors2.c
rename to tests/interactive/test-actor-clone.c
index ed06ff1..159d10e 100644 (file)
@@ -124,7 +124,7 @@ frame_cb (ClutterTimeline *timeline,
 }
 
 G_MODULE_EXPORT int
-test_actors2_main (int argc, char *argv[])
+test_actor_clone_main (int argc, char *argv[])
 {
   ClutterTimeline *timeline;
   ClutterAlpha     *alpha;
@@ -187,11 +187,13 @@ test_actors2_main (int argc, char *argv[])
       g_error ("image load failed: %s", error->message);
       exit (1);
     }
+  clutter_actor_set_size (tmp, 300, 500);
   real_hand = clutter_group_new ();
   clutter_container_add_actor (CLUTTER_CONTAINER (real_hand), tmp);
   tmp = clutter_rectangle_new_with_color (&clr);
   clutter_actor_set_size (tmp, 100, 100);
   clutter_container_add_actor (CLUTTER_CONTAINER (real_hand), tmp);
+  clutter_actor_set_scale (real_hand, 0.5, 0.5);
 
   /* Now stick the group we want to clone into another group with a custom
    * opacity to verify that the clones don't traverse this parent when
@@ -211,6 +213,7 @@ test_actors2_main (int argc, char *argv[])
 
       /* Create a texture from file, then clone in to same resources */
       oh->hand[i] = clutter_actor_clone_new (real_hand);
+      clutter_actor_set_size (oh->hand[i], 200, 213);
 
       /* Place around a circle */
       w = clutter_actor_get_width (oh->hand[0]);