app/gimppreviewcache.h app/channel.c put the preview cache priming code

2000-12-16  Sven Neumann  <sven@gimp.org>

	* app/gimppreviewcache.h
	* app/channel.c
	* app/layer.c: put the preview cache priming code back into place,
	but disabled it for small images to avoid unnecessary upscaling.
This commit is contained in:
Sven Neumann 2000-12-16 22:02:10 +00:00 committed by Sven Neumann
parent dfa2bed505
commit 7d0ca8d0fe
10 changed files with 348 additions and 16 deletions

View File

@ -1,3 +1,10 @@
2000-12-16 Sven Neumann <sven@gimp.org>
* app/gimppreviewcache.h
* app/channel.c
* app/layer.c: put the preview cache priming code back into place,
but disabled it for small images to avoid unnecessary upscaling.
2000-12-16 Sven Neumann <sven@gimp.org>
Last-minute cleanup:

View File

@ -58,6 +58,10 @@ static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
static TempBuf * channel_preview_private (Channel *channel,
gint width,
gint height);
static guint channel_signals[LAST_SIGNAL] = { 0 };
static GimpDrawableClass *parent_class = NULL;
@ -501,10 +505,38 @@ channel_preview (Channel *channel,
gint width,
gint height)
{
MaskBuf * preview_buf;
PixelRegion srcPR, destPR;
gint subsample;
TempBuf *ret_buf;
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (channel)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (channel)->gimage &&
GIMP_DRAWABLE (channel)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (channel)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = channel_preview_private (channel,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return channel_preview_private (channel, width, height);
}
static TempBuf *
channel_preview_private (Channel *channel,
gint width,
gint height)
{
MaskBuf *preview_buf;
PixelRegion srcPR;
PixelRegion destPR;
gint subsample;
TempBuf *ret_buf;
g_return_val_if_fail (channel != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);

View File

@ -58,6 +58,10 @@ static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
static TempBuf * channel_preview_private (Channel *channel,
gint width,
gint height);
static guint channel_signals[LAST_SIGNAL] = { 0 };
static GimpDrawableClass *parent_class = NULL;
@ -501,10 +505,38 @@ channel_preview (Channel *channel,
gint width,
gint height)
{
MaskBuf * preview_buf;
PixelRegion srcPR, destPR;
gint subsample;
TempBuf *ret_buf;
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (channel)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (channel)->gimage &&
GIMP_DRAWABLE (channel)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (channel)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = channel_preview_private (channel,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return channel_preview_private (channel, width, height);
}
static TempBuf *
channel_preview_private (Channel *channel,
gint width,
gint height)
{
MaskBuf *preview_buf;
PixelRegion srcPR;
PixelRegion destPR;
gint subsample;
TempBuf *ret_buf;
g_return_val_if_fail (channel != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);

View File

@ -58,6 +58,10 @@ static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
static TempBuf * channel_preview_private (Channel *channel,
gint width,
gint height);
static guint channel_signals[LAST_SIGNAL] = { 0 };
static GimpDrawableClass *parent_class = NULL;
@ -501,10 +505,38 @@ channel_preview (Channel *channel,
gint width,
gint height)
{
MaskBuf * preview_buf;
PixelRegion srcPR, destPR;
gint subsample;
TempBuf *ret_buf;
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (channel)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (channel)->gimage &&
GIMP_DRAWABLE (channel)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (channel)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = channel_preview_private (channel,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return channel_preview_private (channel, width, height);
}
static TempBuf *
channel_preview_private (Channel *channel,
gint width,
gint height)
{
MaskBuf *preview_buf;
PixelRegion srcPR;
PixelRegion destPR;
gint subsample;
TempBuf *ret_buf;
g_return_val_if_fail (channel != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);

View File

@ -63,6 +63,14 @@ static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_destroy (GtkObject *object);
static TempBuf * layer_preview_private (Layer *layer,
gint width,
gint height);
static TempBuf * layer_mask_preview_private (Layer *layer,
gint width,
gint height);
static guint layer_signals[LAST_SIGNAL] = { 0 };
/*
@ -1321,10 +1329,38 @@ layer_linked (Layer *layer)
return layer->linked;
}
TempBuf *
layer_preview (Layer *layer,
gint width,
gint height)
{
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (layer)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (layer)->gimage &&
GIMP_DRAWABLE (layer)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (layer)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = layer_preview_private (layer,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return layer_preview_private (layer, width, height);
}
static TempBuf *
layer_preview_private (Layer *layer,
gint width,
gint height)
{
GImage *gimage;
TempBuf *preview_buf;
@ -1408,6 +1444,33 @@ TempBuf *
layer_mask_preview (Layer *layer,
gint width,
gint height)
{
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (layer)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (layer)->gimage &&
GIMP_DRAWABLE (layer)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (layer)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = layer_preview_private (layer,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return layer_mask_preview_private (layer, width, height);
}
static TempBuf *
layer_mask_preview_private (Layer *layer,
gint width,
gint height)
{
TempBuf *preview_buf;
LayerMask *mask;

View File

@ -23,6 +23,10 @@
#include "temp_buf.h"
#define PREVIEW_CACHE_PRIME_WIDTH 112
#define PREVIEW_CACHE_PRIME_HEIGHT 112
TempBuf * gimp_preview_cache_get (GSList **plist,
gint width,
gint height);

View File

@ -58,6 +58,10 @@ static void gimp_channel_class_init (GimpChannelClass *klass);
static void gimp_channel_init (GimpChannel *channel);
static void gimp_channel_destroy (GtkObject *object);
static TempBuf * channel_preview_private (Channel *channel,
gint width,
gint height);
static guint channel_signals[LAST_SIGNAL] = { 0 };
static GimpDrawableClass *parent_class = NULL;
@ -501,10 +505,38 @@ channel_preview (Channel *channel,
gint width,
gint height)
{
MaskBuf * preview_buf;
PixelRegion srcPR, destPR;
gint subsample;
TempBuf *ret_buf;
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (channel)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (channel)->gimage &&
GIMP_DRAWABLE (channel)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (channel)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = channel_preview_private (channel,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return channel_preview_private (channel, width, height);
}
static TempBuf *
channel_preview_private (Channel *channel,
gint width,
gint height)
{
MaskBuf *preview_buf;
PixelRegion srcPR;
PixelRegion destPR;
gint subsample;
TempBuf *ret_buf;
g_return_val_if_fail (channel != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);

View File

@ -63,6 +63,14 @@ static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_destroy (GtkObject *object);
static TempBuf * layer_preview_private (Layer *layer,
gint width,
gint height);
static TempBuf * layer_mask_preview_private (Layer *layer,
gint width,
gint height);
static guint layer_signals[LAST_SIGNAL] = { 0 };
/*
@ -1321,10 +1329,38 @@ layer_linked (Layer *layer)
return layer->linked;
}
TempBuf *
layer_preview (Layer *layer,
gint width,
gint height)
{
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (layer)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (layer)->gimage &&
GIMP_DRAWABLE (layer)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (layer)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = layer_preview_private (layer,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return layer_preview_private (layer, width, height);
}
static TempBuf *
layer_preview_private (Layer *layer,
gint width,
gint height)
{
GImage *gimage;
TempBuf *preview_buf;
@ -1408,6 +1444,33 @@ TempBuf *
layer_mask_preview (Layer *layer,
gint width,
gint height)
{
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (layer)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (layer)->gimage &&
GIMP_DRAWABLE (layer)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (layer)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = layer_preview_private (layer,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return layer_mask_preview_private (layer, width, height);
}
static TempBuf *
layer_mask_preview_private (Layer *layer,
gint width,
gint height)
{
TempBuf *preview_buf;
LayerMask *mask;

View File

@ -23,6 +23,10 @@
#include "temp_buf.h"
#define PREVIEW_CACHE_PRIME_WIDTH 112
#define PREVIEW_CACHE_PRIME_HEIGHT 112
TempBuf * gimp_preview_cache_get (GSList **plist,
gint width,
gint height);

View File

@ -63,6 +63,14 @@ static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_destroy (GtkObject *object);
static TempBuf * layer_preview_private (Layer *layer,
gint width,
gint height);
static TempBuf * layer_mask_preview_private (Layer *layer,
gint width,
gint height);
static guint layer_signals[LAST_SIGNAL] = { 0 };
/*
@ -1321,10 +1329,38 @@ layer_linked (Layer *layer)
return layer->linked;
}
TempBuf *
layer_preview (Layer *layer,
gint width,
gint height)
{
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (layer)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (layer)->gimage &&
GIMP_DRAWABLE (layer)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (layer)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = layer_preview_private (layer,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return layer_preview_private (layer, width, height);
}
static TempBuf *
layer_preview_private (Layer *layer,
gint width,
gint height)
{
GImage *gimage;
TempBuf *preview_buf;
@ -1408,6 +1444,33 @@ TempBuf *
layer_mask_preview (Layer *layer,
gint width,
gint height)
{
/* Ok prime the cache with a large preview if the cache is invalid */
if (! GIMP_DRAWABLE (layer)->preview_valid &&
width <= PREVIEW_CACHE_PRIME_WIDTH &&
height <= PREVIEW_CACHE_PRIME_HEIGHT &&
GIMP_DRAWABLE (layer)->gimage &&
GIMP_DRAWABLE (layer)->gimage->width > PREVIEW_CACHE_PRIME_WIDTH &&
GIMP_DRAWABLE (layer)->gimage->height > PREVIEW_CACHE_PRIME_HEIGHT)
{
TempBuf * tb = layer_preview_private (layer,
PREVIEW_CACHE_PRIME_WIDTH,
PREVIEW_CACHE_PRIME_HEIGHT);
/* Save the 2nd call */
if (width == PREVIEW_CACHE_PRIME_WIDTH &&
height == PREVIEW_CACHE_PRIME_HEIGHT)
return tb;
}
/* Second call - should NOT visit the tile cache...*/
return layer_mask_preview_private (layer, width, height);
}
static TempBuf *
layer_mask_preview_private (Layer *layer,
gint width,
gint height)
{
TempBuf *preview_buf;
LayerMask *mask;