fixed area_changed handling
authorVladimir Nadvornik <nadvornik@suse.cz>
Fri, 25 Mar 2011 21:09:59 +0000 (22:09 +0100)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 27 Sep 2011 12:30:08 +0000 (14:30 +0200)
src/pixbuf-renderer.c
src/pixbuf-renderer.h
src/renderer-tiles.c

index 5482e12..57203c5 100644 (file)
@@ -2603,38 +2603,17 @@ void pixbuf_renderer_move(PixbufRenderer *pr, PixbufRenderer *source)
 //     pr_tile_free_all(source);
 }
 
-void pixbuf_renderer_area_changed(PixbufRenderer *pr, gint src_x, gint src_y, gint src_w, gint src_h)
+void pixbuf_renderer_area_changed(PixbufRenderer *pr, gint x, gint y, gint w, gint h)
 {
-       gint x, y, width, height,  x1, y1, x2, y2;
-
        g_return_if_fail(IS_PIXBUF_RENDERER(pr));
 
-       pr_coords_map_orientation_reverse(pr->orientation,
-                                    src_x, src_y,
-                                    pr->image_width, pr->image_height,
-                                    src_w, src_h,
-                                    &x, &y,
-                                    &width, &height);
-
        if (pr->source_tiles_enabled)
                {
-               pr_source_tile_changed(pr, x, y, width, height);
-               }
-
-       if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
-               {
-               /* increase region when using a zoom quality that may access surrounding pixels */
-               y -= 1;
-               height += 2;
+               pr_source_tile_changed(pr, x, y, w, h);
                }
 
-       x1 = (gint)floor((gdouble)x * pr->scale);
-       y1 = (gint)floor((gdouble)y * pr->scale * pr->aspect_ratio);
-       x2 = (gint)ceil((gdouble)(x + width) * pr->scale);
-       y2 = (gint)ceil((gdouble)(y + height) * pr->scale * pr->aspect_ratio);
-
-       pr->renderer->queue(pr->renderer, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
-       if (pr->renderer2) pr->renderer2->queue(pr->renderer2, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
+       pr->renderer->area_changed(pr->renderer, x, y, w, h);
+       if (pr->renderer2) pr->renderer2->area_changed(pr->renderer2, x, y, w, h);
 }
 
 void pixbuf_renderer_zoom_adjust(PixbufRenderer *pr, gdouble increment)
index 1c756da..47d42ad 100644 (file)
@@ -78,6 +78,7 @@ struct _RendererFuncs
 {
        void (*queue)(void *renderer, gint x, gint y, gint w, gint h,
                      gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing);
+        void (*area_changed)(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h);
        void (*queue_clear)(void *renderer);
        void (*border_draw)(void *renderer, gint x, gint y, gint w, gint h);
        void (*invalidate_all)(void *renderer);
index c665e49..aaab43c 100644 (file)
@@ -1280,6 +1280,18 @@ static void rt_tile_get_region(gboolean has_alpha,
 }
 
 
+static gint rt_get_orientation(RendererTiles *rt)
+{
+       PixbufRenderer *pr = rt->pr;
+
+       gint orientation = pr->orientation;
+       static const gint mirror[]       = {1,   2, 1, 4, 3, 6, 5, 8, 7};
+       static const gint flip[]         = {1,   4, 3, 2, 1, 8, 7, 6, 5};
+
+       if (rt->stereo_mode & PR_STEREO_MIRROR) orientation = mirror[orientation];
+       if (rt->stereo_mode & PR_STEREO_FLIP) orientation = flip[orientation];
+        return orientation;
+}
 
 
 static void rt_tile_render(RendererTiles *rt, ImageTile *it,
@@ -1290,9 +1302,7 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it,
        GtkWidget *box;
        gboolean has_alpha;
        gboolean draw = FALSE;
-       gint orientation = pr->orientation;
-       static const gint mirror[]       = {1,   2, 1, 4, 3, 6, 5, 8, 7};
-       static const gint flip[]         = {1,   4, 3, 2, 1, 8, 7, 6, 5};
+       gint orientation = rt_get_orientation(rt);
 
        if (it->render_todo == TILE_RENDER_NONE && it->pixmap && !new_data) return;
 
@@ -1317,8 +1327,6 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it,
        rt_tile_prepare(rt, it);
        has_alpha = (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf));
 
-       if (rt->stereo_mode & PR_STEREO_MIRROR) orientation = mirror[orientation];
-       if (rt->stereo_mode & PR_STEREO_FLIP) orientation = flip[orientation];
        box = GTK_WIDGET(pr);
 
        /* FIXME checker colors for alpha should be configurable,
@@ -1981,6 +1989,35 @@ static void rt_scroll(RendererTiles *rt, gint x_off, gint y_off)
                }
 }
 
+static void renderer_area_changed(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h)
+{
+       RendererTiles *rt = (RendererTiles *)renderer;
+       PixbufRenderer *pr = rt->pr;
+       gint x, y, width, height,  x1, y1, x2, y2;
+
+       gint orientation = rt_get_orientation(rt);
+       pr_coords_map_orientation_reverse(orientation,
+                                    src_x - GET_RIGHT_PIXBUF_OFFSET(rt), src_y,
+                                    pr->image_width, pr->image_height,
+                                    src_w, src_h,
+                                    &x, &y,
+                                    &width, &height);
+
+       if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
+               {
+               /* increase region when using a zoom quality that may access surrounding pixels */
+               y -= 1;
+               height += 2;
+               }
+
+       x1 = (gint)floor((gdouble)x * pr->scale);
+       y1 = (gint)floor((gdouble)y * pr->scale * pr->aspect_ratio);
+       x2 = (gint)ceil((gdouble)(x + width) * pr->scale);
+       y2 = (gint)ceil((gdouble)(y + height) * pr->scale * pr->aspect_ratio);
+
+       rt_queue(rt, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
+}
+
 static void renderer_queue(void *renderer, gint x, gint y, gint w, gint h,
                      gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing)
 {
@@ -2083,6 +2120,7 @@ RendererFuncs *renderer_tiles_new(PixbufRenderer *pr)
        rt->pr = pr;
        
        rt->f.queue = renderer_queue;
+       rt->f.area_changed = renderer_area_changed;
        rt->f.queue_clear = renderer_queue_clear;
        rt->f.border_draw = renderer_border_draw;
        rt->f.free = renderer_free;