From 7d8b7f55346325e7bb4a28f3cc6f7a09ed9922c1 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 4 Nov 2008 20:13:12 +0000 Subject: [PATCH] add vitrual function invalidate_preview(). 2008-11-04 Michael Natterer * app/core/gimpprojectable.[ch]: add vitrual function invalidate_preview(). * app/core/gimpimage.c: implement it and redirect to gimp_viewable_invalidate_preview(). * app/core/gimpprojection.c: call the new API instead of gimp_viewable_invalidate_preview(). Some cleanup in the disabled cow-projection code. svn path=/trunk/; revision=27553 --- ChangeLog | 12 +++++++ app/core/gimpimage.c | 7 ++-- app/core/gimpprojectable.c | 13 ++++++++ app/core/gimpprojectable.h | 20 ++++++----- app/core/gimpprojection-construct.c | 51 ++++++++++++++--------------- app/core/gimpprojection.c | 6 ++-- 6 files changed, 67 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a58777f3d..b7f8455494 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-11-04 Michael Natterer + + * app/core/gimpprojectable.[ch]: add vitrual function + invalidate_preview(). + + * app/core/gimpimage.c: implement it and redirect to + gimp_viewable_invalidate_preview(). + + * app/core/gimpprojection.c: call the new API instead of + gimp_viewable_invalidate_preview(). Some cleanup in the disabled + cow-projection code. + 2008-11-04 Michael Natterer Unfinished first step to make the projection independent of diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 054a48e820..0db9cbcfcd 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -560,9 +560,10 @@ gimp_color_managed_iface_init (GimpColorManagedInterface *iface) static void gimp_projectable_iface_init (GimpProjectableInterface *iface) { - iface->flush = gimp_image_projectable_flush; - iface->get_image = gimp_image_get_image; - iface->get_graph = gimp_image_get_graph; + iface->flush = gimp_image_projectable_flush; + iface->get_image = gimp_image_get_image; + iface->get_graph = gimp_image_get_graph; + iface->invalidate_preview = (void (*) (GimpProjectable *p)) gimp_viewable_invalidate_preview; } static void diff --git a/app/core/gimpprojectable.c b/app/core/gimpprojectable.c index f88b2f2e56..6ec791ea29 100644 --- a/app/core/gimpprojectable.c +++ b/app/core/gimpprojectable.c @@ -161,3 +161,16 @@ gimp_projectable_get_graph (GimpProjectable *projectable) return NULL; } + +void +gimp_projectable_invalidate_preview (GimpProjectable *projectable) +{ + GimpProjectableInterface *iface; + + g_return_if_fail (GIMP_IS_PROJECTABLE (projectable)); + + iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable); + + if (iface->invalidate_preview) + iface->invalidate_preview (projectable); +} diff --git a/app/core/gimpprojectable.h b/app/core/gimpprojectable.h index 86e8587a29..9330c2fb21 100644 --- a/app/core/gimpprojectable.h +++ b/app/core/gimpprojectable.h @@ -36,17 +36,18 @@ struct _GimpProjectableInterface GTypeInterface base_iface; /* signals */ - void (* update) (GimpProjectable *projectable, - gint x, - gint y, - gint width, - gint height); - void (* flush) (GimpProjectable *projectable, - gboolean invalidate_preview); + void (* update) (GimpProjectable *projectable, + gint x, + gint y, + gint width, + gint height); + void (* flush) (GimpProjectable *projectable, + gboolean invalidate_preview); /* virtual functions */ - GimpImage * (* get_image) (GimpProjectable *projectable); - GeglNode * (* get_graph) (GimpProjectable *projectable); + GimpImage * (* get_image) (GimpProjectable *projectable); + GeglNode * (* get_graph) (GimpProjectable *projectable); + void (* invalidate_preview) (GimpProjectable *projectable); }; @@ -62,6 +63,7 @@ void gimp_projectable_flush (GimpProjectable *projectable, GimpImage * gimp_projectable_get_image (GimpProjectable *projectable); GeglNode * gimp_projectable_get_graph (GimpProjectable *projectable); +void gimp_projectable_invalidate_preview (GimpProjectable *projectable); #endif /* __GIMP_PROJECTABLE_H__ */ diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 18c711b696..d41fb64cf6 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -103,45 +103,42 @@ gimp_projection_construct (GimpProjection *proj, #if 0 GimpImage *image = gimp_projectable_get_image (proj->projectable); - if ((gimp_container_num_children (image->layers) == 1)) /* a single layer */ + if (gimp_container_num_children (image->layers) == 1) /* a single layer */ { GimpDrawable *layer; + gint off_x, off_y; layer = GIMP_DRAWABLE (gimp_image_get_layer_by_index (image, 0)); - if (gimp_drawable_has_alpha (layer) && - (gimp_item_get_visible (GIMP_ITEM (layer))) && - (gimp_item_get_width (GIMP_ITEM (layer)) == image->width) && - (gimp_item_get_height (GIMP_ITEM (layer)) == image->height) && - (! gimp_drawable_is_indexed (layer)) && - (gimp_layer_get_opacity (GIMP_LAYER (layer)) == GIMP_OPACITY_OPAQUE)) + gimp_item_get_offset (GIMP_ITEM (layer), &off_x, &off_y); + + if (gimp_drawable_has_alpha (layer) && + gimp_item_get_visible (GIMP_ITEM (layer)) && + gimp_item_get_width (GIMP_ITEM (layer)) == image->width && + gimp_item_get_height (GIMP_ITEM (layer)) == image->height && + ! gimp_drawable_is_indexed (layer) && + gimp_layer_get_opacity (GIMP_LAYER (layer)) == GIMP_OPACITY_OPAQUE && + off_x == 0 && + off_y == 0) { - gint xoff; - gint yoff; + PixelRegion srcPR, destPR; - gimp_item_get_offset (GIMP_ITEM (layer), &xoff, &yoff); + g_printerr ("cow-projection!"); - if (xoff == 0 && yoff == 0) - { - PixelRegion srcPR, destPR; + pixel_region_init (&srcPR, + gimp_drawable_get_tiles (layer), + x, y, w,h, FALSE); + pixel_region_init (&destPR, + gimp_pickable_get_tiles (GIMP_PICKABLE (proj)), + x, y, w,h, TRUE); - g_printerr ("cow-projection!"); + copy_region (&srcPR, &destPR); - pixel_region_init (&srcPR, - gimp_drawable_get_tiles (layer), - x, y, w,h, FALSE); - pixel_region_init (&destPR, - gimp_pickable_get_tiles (GIMP_PICKABLE (proj)), - x, y, w,h, TRUE); + proj->construct_flag = TRUE; - copy_region (&srcPR, &destPR); + gimp_projection_construct_channels (proj, x, y, w, h); - proj->construct_flag = TRUE; - - gimp_projection_construct_channels (proj, x, y, w, h); - - return; - } + return; } } #endif diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 1ef73a4371..4af0dbb294 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -270,7 +270,7 @@ gimp_projection_pickable_flush (GimpPickable *pickable) */ proj->invalidate_preview = FALSE; - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->projectable)); + gimp_projectable_invalidate_preview (proj->projectable); } } @@ -561,7 +561,7 @@ gimp_projection_flush_whenever (GimpProjection *proj, */ proj->invalidate_preview = FALSE; - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->projectable)); + gimp_projectable_invalidate_preview (proj->projectable); } } @@ -678,7 +678,7 @@ gimp_projection_idle_render_callback (gpointer data) */ proj->invalidate_preview = FALSE; - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->projectable)); + gimp_projectable_invalidate_preview (proj->projectable); } return FALSE;