optimized to reallocate the projection TileManager only if it does not

2003-12-04  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-projection.c (gimp_image_projection_allocate):
	optimized to reallocate the projection TileManager only if it does
	not match the required width, height and depth.

	* app/core/gimpimage.c (gimp_image_size_changed): call
	gimp_image_projection_allocate().

	* app/core/gimpimage-crop.c
	* app/core/gimpimage-resize.c
	* app/core/gimpimage-rotate.c
	* app/core/gimpimage-scale.c
	* app/core/gimpimage-undo-push.c: removed calls to
	gimp_image_projection_allocate(), since "size_changed" does it
	automatically now.
This commit is contained in:
Michael Natterer 2003-12-04 12:18:41 +00:00 committed by Michael Natterer
parent 533c533fb0
commit 797665dee0
9 changed files with 83 additions and 41 deletions

View File

@ -1,3 +1,20 @@
2003-12-04 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-projection.c (gimp_image_projection_allocate):
optimized to reallocate the projection TileManager only if it does
not match the required width, height and depth.
* app/core/gimpimage.c (gimp_image_size_changed): call
gimp_image_projection_allocate().
* app/core/gimpimage-crop.c
* app/core/gimpimage-resize.c
* app/core/gimpimage-rotate.c
* app/core/gimpimage-scale.c
* app/core/gimpimage-undo-push.c: removed calls to
gimp_image_projection_allocate(), since "size_changed" does it
automatically now.
2003-12-04 Michael Natterer <mitch@gimp.org>
* plug-ins/helpbrowser/dialog.c

View File

@ -249,9 +249,6 @@ gimp_image_crop (GimpImage *gimage,
gimp_image_move_guide (gimage, guide, new_position, TRUE);
}
/* Make sure the projection matches the gimage size */
gimp_image_projection_allocate (gimage);
/* rigor the floating layer */
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);

View File

@ -94,8 +94,10 @@ static void project_channel (GimpImage *gimage,
void
gimp_image_projection_allocate (GimpImage *gimage)
{
if (gimage->projection)
gimp_image_projection_free (gimage);
GimpImageType proj_type = 0;
gint proj_bytes = 0;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* Find the number of bytes required for the projection.
* This includes the intensity channels and an alpha channel
@ -105,23 +107,41 @@ gimp_image_projection_allocate (GimpImage *gimage)
{
case GIMP_RGB:
case GIMP_INDEXED:
gimage->proj_bytes = 4;
gimage->proj_type = GIMP_RGBA_IMAGE;
proj_bytes = 4;
proj_type = GIMP_RGBA_IMAGE;
break;
case GIMP_GRAY:
gimage->proj_bytes = 2;
gimage->proj_type = GIMP_GRAYA_IMAGE;
proj_bytes = 2;
proj_type = GIMP_GRAYA_IMAGE;
break;
default:
g_assert_not_reached ();
}
/* allocate the new projection */
gimage->projection = tile_manager_new (gimage->width, gimage->height,
gimage->proj_bytes);
tile_manager_set_user_data (gimage->projection, (void *) gimage);
tile_manager_set_validate_proc (gimage->projection,
gimp_image_projection_validate_tile);
if (gimage->projection)
{
if (proj_type != gimage->proj_type ||
proj_bytes != gimage->proj_bytes ||
gimage->width != tile_manager_width (gimage->projection) ||
gimage->height != tile_manager_height (gimage->projection))
{
gimp_image_projection_free (gimage);
}
}
if (! gimage->projection)
{
gimage->proj_type = proj_type;
gimage->proj_bytes = proj_bytes;
gimage->projection = tile_manager_new (gimage->width, gimage->height,
gimage->proj_bytes);
tile_manager_set_user_data (gimage->projection, gimage);
tile_manager_set_validate_proc (gimage->projection,
gimp_image_projection_validate_tile);
}
}
void

View File

@ -25,7 +25,6 @@
#include "gimp.h"
#include "gimpimage.h"
#include "gimpimage-guides.h"
#include "gimpimage-projection.h"
#include "gimpimage-resize.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
@ -157,9 +156,6 @@ gimp_image_resize (GimpImage *gimage,
gimp_image_move_guide (gimage, guide, new_position, TRUE);
}
/* Make sure the projection matches the gimage size */
gimp_image_projection_allocate (gimage);
/* Rigor the floating selection */
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);

View File

@ -24,7 +24,6 @@
#include "gimp.h"
#include "gimpimage.h"
#include "gimpimage-projection.h"
#include "gimpimage-rotate.h"
#include "gimpimage-guides.h"
#include "gimpimage-undo.h"
@ -193,9 +192,6 @@ gimp_image_rotate (GimpImage *gimage,
}
}
/* Make sure the projection matches the gimage size */
gimp_image_projection_allocate (gimage);
/* Rigor the floating selection */
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);

View File

@ -25,7 +25,6 @@
#include "gimp.h"
#include "gimpimage.h"
#include "gimpimage-guides.h"
#include "gimpimage-projection.h"
#include "gimpimage-scale.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
@ -179,9 +178,6 @@ gimp_image_scale (GimpImage *gimage,
}
}
/* Make sure the projection matches the gimage size */
gimp_image_projection_allocate (gimage);
/* Rigor the floating selection */
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);

View File

@ -45,7 +45,6 @@
#include "gimpimage-colormap.h"
#include "gimpimage-grid.h"
#include "gimpimage-guides.h"
#include "gimpimage-projection.h"
#include "gimpimage-undo.h"
#include "gimpimage.h"
#include "gimpitemundo.h"
@ -444,7 +443,6 @@ undo_pop_image_size (GimpUndo *undo,
undo->gimage->width = width;
undo->gimage->height = height;
gimp_image_projection_allocate (undo->gimage);
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (gimp_image_get_mask (undo->gimage)));
if (undo->gimage->width != isu->width ||

View File

@ -785,6 +785,8 @@ gimp_image_size_changed (GimpViewable *viewable)
}
gimp_viewable_size_changed (GIMP_VIEWABLE (gimp_image_get_mask (gimage)));
gimp_image_projection_allocate (gimage);
}
static gchar *

View File

@ -94,8 +94,10 @@ static void project_channel (GimpImage *gimage,
void
gimp_image_projection_allocate (GimpImage *gimage)
{
if (gimage->projection)
gimp_image_projection_free (gimage);
GimpImageType proj_type = 0;
gint proj_bytes = 0;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* Find the number of bytes required for the projection.
* This includes the intensity channels and an alpha channel
@ -105,23 +107,41 @@ gimp_image_projection_allocate (GimpImage *gimage)
{
case GIMP_RGB:
case GIMP_INDEXED:
gimage->proj_bytes = 4;
gimage->proj_type = GIMP_RGBA_IMAGE;
proj_bytes = 4;
proj_type = GIMP_RGBA_IMAGE;
break;
case GIMP_GRAY:
gimage->proj_bytes = 2;
gimage->proj_type = GIMP_GRAYA_IMAGE;
proj_bytes = 2;
proj_type = GIMP_GRAYA_IMAGE;
break;
default:
g_assert_not_reached ();
}
/* allocate the new projection */
gimage->projection = tile_manager_new (gimage->width, gimage->height,
gimage->proj_bytes);
tile_manager_set_user_data (gimage->projection, (void *) gimage);
tile_manager_set_validate_proc (gimage->projection,
gimp_image_projection_validate_tile);
if (gimage->projection)
{
if (proj_type != gimage->proj_type ||
proj_bytes != gimage->proj_bytes ||
gimage->width != tile_manager_width (gimage->projection) ||
gimage->height != tile_manager_height (gimage->projection))
{
gimp_image_projection_free (gimage);
}
}
if (! gimage->projection)
{
gimage->proj_type = proj_type;
gimage->proj_bytes = proj_bytes;
gimage->projection = tile_manager_new (gimage->width, gimage->height,
gimage->proj_bytes);
tile_manager_set_user_data (gimage->projection, gimage);
tile_manager_set_validate_proc (gimage->projection,
gimp_image_projection_validate_tile);
}
}
void