add vitrual function invalidate_preview().

2008-11-04  Michael Natterer  <mitch@gimp.org>

	* 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
This commit is contained in:
Michael Natterer 2008-11-04 20:13:12 +00:00 committed by Michael Natterer
parent 716e00f88b
commit 7d8b7f5534
6 changed files with 67 additions and 42 deletions

View File

@ -1,3 +1,15 @@
2008-11-04 Michael Natterer <mitch@gimp.org>
* 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 <mitch@gimp.org>
Unfinished first step to make the projection independent of

View File

@ -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

View File

@ -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);
}

View File

@ -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__ */

View File

@ -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

View File

@ -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;