changeset 2082:a1fb3d7ce2ee

clutter drawing improvement use clutter_actor_set_scale instead of clutter_actor_set_size clip to the initialized part of texture during loading
author Vladimir Nadvornik <nadvornik@suse.cz>
date Wed, 15 Aug 2012 22:28:02 +0200
parents 2d6efc3deb26
children 496a6c7314c4
files src/renderer-clutter.c
diffstat 1 files changed, 35 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/renderer-clutter.c	Wed Aug 15 21:30:56 2012 +0200
+++ b/src/renderer-clutter.c	Wed Aug 15 22:28:02 2012 +0200
@@ -123,6 +123,10 @@
 	printf("scale %d %d\n", rc->pr->width, rc->pr->height);
 	printf("pos   %d %d\n", rc->pr->x_offset, rc->pr->y_offset);
 	
+	clutter_actor_set_scale(CLUTTER_ACTOR(rc->texture), 
+			        (gfloat)pr->width / pr->image_width,
+			        (gfloat)pr->height / pr->image_height);
+			        
 	switch (pr->orientation)
 		{
 		case EXIF_ORIENTATION_TOP_LEFT:
@@ -133,7 +137,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						0, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->width, pr->height);
 			anchor_x = 0;
 			anchor_y = 0;
 			break;
@@ -145,7 +148,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						180, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->width, pr->height);
 			anchor_x = pr->width;
 			anchor_y = 0;
 			break;
@@ -157,7 +159,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						0, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->width, pr->height);
 			anchor_x = pr->width;
 			anchor_y = pr->height;
 			break;
@@ -169,7 +170,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						180, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->width, pr->height);
 			anchor_x = 0;
 			anchor_y = pr->height;
 			break;
@@ -180,7 +180,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						180, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->height, pr->width);
 			anchor_x = 0;
 			anchor_y = 0;
 			break;
@@ -192,7 +191,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						0, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->height, pr->width);
 			anchor_x = 0;
 			anchor_y = pr->height;
 			break;
@@ -203,7 +201,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						180, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->height, pr->width);
 			anchor_x = pr->width;
 			anchor_y = pr->height;
 			break;
@@ -215,7 +212,6 @@
 			clutter_actor_set_rotation(CLUTTER_ACTOR(rc->texture),
 						CLUTTER_Y_AXIS,
 						0, 0, 0, 0);
-			clutter_actor_set_size(CLUTTER_ACTOR(rc->texture), pr->height, pr->width);
 			anchor_x = pr->width;
 			anchor_y = 0;
 			break;
@@ -230,7 +226,34 @@
 
 }
 
-#define MAX_REGION_AREA (8192 * 1024)
+
+static void renderer_area_clip_add(RendererClutter *rc, gfloat x, gfloat y, gfloat w, gfloat h)
+{
+	PixbufRenderer *pr = rc->pr;
+	gfloat x2, y2;
+	gfloat clip_x, clip_y, clip_w, clip_h, clip_x2, clip_y2;
+	
+	x2 = x + w;
+	y2 = y + h;
+	
+	clutter_actor_get_clip(rc->texture, &clip_x, &clip_y, &clip_w, &clip_h);
+	
+	clip_x2 = clip_x + clip_w;
+	clip_y2 = clip_y + clip_h;
+	
+	if (clip_x > x) clip_x = x;
+	if (clip_x2 < x2) clip_x2 = x2;
+	if (clip_y > y) clip_y = y;
+	if (clip_y2 < y2) clip_y2 = y2;
+	
+	clip_w = clip_x2 - clip_x;
+	clip_h = clip_y2 - clip_y;
+	
+	printf("clip %f %f %f %f\n", clip_x, clip_y, clip_w, clip_h);
+	clutter_actor_set_clip(rc->texture, clip_x, clip_y, clip_w, clip_h);
+}
+
+#define MAX_REGION_AREA (32768 * 1024)
 
 static gboolean renderer_area_changed_cb(gpointer data)
 {
@@ -262,6 +285,8 @@
 					gdk_pixbuf_get_rowstride(pr->pixbuf),
 					gdk_pixbuf_get_pixels(pr->pixbuf));
 		}
+	renderer_area_clip_add(rc, par->x, par->y, par->w, h);
+
 		
 	par->y += h;
 	par->h -= h;
@@ -362,6 +387,7 @@
 				cogl_handle_unref(texture);
 				}
 			}
+		clutter_actor_set_clip(rc->texture, 0, 0, 0, 0); /* visible area is extended as area_changed events arrive */
 		if (!lazy)
 			{
 			renderer_area_changed(renderer, GET_RIGHT_PIXBUF_OFFSET(rc), 0, width, height);