Commit f029c6b5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/Makefile.am app/apptypes.h new object. Everything that can have a

2001-02-04  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/apptypes.h
	* app/gimpviewable.[ch]: new object. Everything that can have a
	preview will be a GimpViewable. The virtual functions are
	"invalidate_preview", "preview" and "preview_new".

	* app/gimpmarshal.[ch]: new marshaller needed for the viewable.

	* app/gimpdrawable.[ch]
	* app/gimpimage.[ch]: derived from GimpViewable. Removed the
	preview stuff from the public interface.

	Made a single boolean out of GimpImage's "comp_preview_valid"
	array because we have only one copposite preview.

	* app/gimplayer.c: made the preview stuff private.

	* app/gimppreviewcache.[ch]: removed gimp_preview_scale()...

	* app/temp_buf.[ch]: ...and added it as temp_buf_scale() here.

	* app/gimpdrawablepreview.[ch]: is a private method of
	GimpDrawable now.

	* app/channels_dialog.c
	* app/convert.c
	* app/drawable.c
	* app/fileops.c
	* app/floating_sel.c
	* app/gimage.c
	* app/gimage_mask.c
	* app/gimpchannel.c
	* app/gimpcontainer.c
	* app/gimpdnd.c
	* app/layer_select.c
	* app/layers_dialog.c
	* app/lc_dialog.c
	* app/nav_window.c
	* app/palette_import.c
	* app/undo.c
	* app/undo_history.c
	* app/pdb/drawable_cmds.c
	* app/pdb/image_cmds.c
	* app/tools/crop.c
	* app/tools/edit_selection.c
	* app/tools/ink.c
	* app/tools/paint_core.c
	* tools/pdbgen/pdb/drawable.pdb
	* tools/pdbgen/pdb/image.pdb
	* po/POTFILES.in: changed accordingly.
parent 78a8bb4c
2001-02-04 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/apptypes.h
* app/gimpviewable.[ch]: new object. Everything that can have a
preview will be a GimpViewable. The virtual functions are
"invalidate_preview", "preview" and "preview_new".
* app/gimpmarshal.[ch]: new marshaller needed for the viewable.
* app/gimpdrawable.[ch]
* app/gimpimage.[ch]: derived from GimpViewable. Removed the
preview stuff from the public interface.
Made a single boolean out of GimpImage's "comp_preview_valid"
array because we have only one copposite preview.
* app/gimplayer.c: made the preview stuff private.
* app/gimppreviewcache.[ch]: removed gimp_preview_scale()...
* app/temp_buf.[ch]: ...and added it as temp_buf_scale() here.
* app/gimpdrawablepreview.[ch]: is a private method of
GimpDrawable now.
* app/channels_dialog.c
* app/convert.c
* app/drawable.c
* app/fileops.c
* app/floating_sel.c
* app/gimage.c
* app/gimage_mask.c
* app/gimpchannel.c
* app/gimpcontainer.c
* app/gimpdnd.c
* app/layer_select.c
* app/layers_dialog.c
* app/lc_dialog.c
* app/nav_window.c
* app/palette_import.c
* app/undo.c
* app/undo_history.c
* app/pdb/drawable_cmds.c
* app/pdb/image_cmds.c
* app/tools/crop.c
* app/tools/edit_selection.c
* app/tools/ink.c
* app/tools/paint_core.c
* tools/pdbgen/pdb/drawable.pdb
* tools/pdbgen/pdb/image.pdb
* po/POTFILES.in: changed accordingly.
2001-02-04 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
......
......@@ -157,6 +157,8 @@ gimp_SOURCES = \
gimpui.c \
gimpui.h \
gimpunit.c \
gimpviewable.c \
gimpviewable.h \
global_edit.c \
global_edit.h \
gradient.c \
......
......@@ -40,6 +40,8 @@ typedef struct _GimpDataList GimpDataList;
typedef struct _GimpContext GimpContext;
typedef struct _GimpViewable GimpViewable;
/* drawable objects */
......
......@@ -68,7 +68,7 @@ temp_buf_allocate (guint size)
/* The conversion routines */
static void
temp_buf_to_color (TempBuf *src_buf,
temp_buf_to_color (TempBuf *src_buf,
TempBuf *dest_buf)
{
guchar *src;
......@@ -92,7 +92,7 @@ temp_buf_to_color (TempBuf *src_buf,
static void
temp_buf_to_gray (TempBuf *src_buf,
temp_buf_to_gray (TempBuf *src_buf,
TempBuf *dest_buf)
{
guchar *src;
......@@ -116,11 +116,11 @@ temp_buf_to_gray (TempBuf *src_buf,
}
TempBuf *
temp_buf_new (gint width,
gint height,
gint bytes,
gint x,
gint y,
temp_buf_new (gint width,
gint height,
gint bytes,
gint x,
gint y,
guchar *col)
{
glong i;
......@@ -191,7 +191,7 @@ temp_buf_new (gint width,
}
TempBuf *
temp_buf_copy (TempBuf *src,
temp_buf_copy (TempBuf *src,
TempBuf *dest)
{
TempBuf *new;
......@@ -274,6 +274,53 @@ temp_buf_resize (TempBuf *buf,
return buf;
}
TempBuf *
temp_buf_scale (TempBuf *src,
gint new_width,
gint new_height)
{
gint loop1;
gint loop2;
gdouble x_ratio;
gdouble y_ratio;
guchar *src_data;
guchar *dest_data;
TempBuf *dest;
dest = temp_buf_new (new_width,
new_height,
src->bytes,
0, 0, NULL);
src_data = temp_buf_data (src);
dest_data = temp_buf_data (dest);
x_ratio = (gdouble) src->width / (gdouble) new_width;
y_ratio = (gdouble) src->height / (gdouble) new_height;
for (loop1 = 0 ; loop1 < new_height ; loop1++)
{
for (loop2 = 0 ; loop2 < new_width ; loop2++)
{
gint i;
guchar *src_pixel;
guchar *dest_pixel;
src_pixel = src_data +
(gint) (loop2 * x_ratio) * src->bytes +
(gint) (loop1 * y_ratio) * src->bytes * src->width;
dest_pixel = dest_data +
(loop2 + loop1 * new_width) * src->bytes;
for (i = 0 ; i < src->bytes; i++)
*dest_pixel++ = *src_pixel++;
}
}
return dest;
}
TempBuf *
temp_buf_copy_area (TempBuf *src,
TempBuf *dest,
......
......@@ -36,44 +36,47 @@ struct _TempBuf
/* The temp buffer functions */
TempBuf * temp_buf_new (gint width,
gint height,
gint bytes,
gint x,
gint y,
guchar *col);
TempBuf * temp_buf_copy (TempBuf *src,
TempBuf *dest);
TempBuf * temp_buf_resize (TempBuf *buf,
gint bytes,
gint x,
gint y,
gint width,
gint height);
TempBuf * temp_buf_copy_area (TempBuf *src,
TempBuf *dest,
gint x,
gint y,
gint width,
gint height,
gint border);
void temp_buf_free (TempBuf *buf);
guchar * temp_buf_data (TempBuf *buf);
guchar * temp_buf_data_clear (TempBuf *buf);
TempBuf * temp_buf_new (gint width,
gint height,
gint bytes,
gint x,
gint y,
guchar *col);
TempBuf * temp_buf_copy (TempBuf *src,
TempBuf *dest);
TempBuf * temp_buf_resize (TempBuf *buf,
gint bytes,
gint x,
gint y,
gint width,
gint height);
TempBuf * temp_buf_scale (TempBuf *buf,
gint width,
gint height);
TempBuf * temp_buf_copy_area (TempBuf *src,
TempBuf *dest,
gint x,
gint y,
gint width,
gint height,
gint border);
void temp_buf_free (TempBuf *buf);
guchar * temp_buf_data (TempBuf *buf);
guchar * temp_buf_data_clear (TempBuf *buf);
/* The mask buffer functions */
MaskBuf * mask_buf_new (gint width,
gint height);
void mask_buf_free (MaskBuf *mask_buf);
guchar * mask_buf_data (MaskBuf *mask_buf);
guchar * mask_buf_data_clear (MaskBuf *mask_buf);
MaskBuf * mask_buf_new (gint width,
gint height);
void mask_buf_free (MaskBuf *mask_buf);
guchar * mask_buf_data (MaskBuf *mask_buf);
guchar * mask_buf_data_clear (MaskBuf *mask_buf);
/* The disk caching functions */
void temp_buf_swap (TempBuf *buf);
void temp_buf_unswap (TempBuf *buf);
void temp_buf_swap_free (TempBuf *buf);
void temp_buf_swap (TempBuf *buf);
void temp_buf_unswap (TempBuf *buf);
void temp_buf_swap_free (TempBuf *buf);
/* Called by app_procs:exit() to free up the cached undo buffer */
......
......@@ -36,8 +36,6 @@
#include "gimage_mask.h"
#include "gimpchannel.h"
#include "gimpdnd.h"
#include "gimpdrawablepreview.h"
#include "gimppreviewcache.h"
#include "gimprc.h"
#include "gimpui.h"
#include "layers_dialogP.h"
......@@ -45,6 +43,7 @@
#include "menus.h"
#include "ops_buttons.h"
#include "paint_funcs.h"
#include "temp_buf.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
......@@ -2044,8 +2043,7 @@ channel_widget_preview_events (GtkWidget *widget,
valid = GIMP_DRAWABLE (channel_widget->channel)->preview_valid;
break;
default:
valid = gimp_image_preview_valid (channel_widget->gimage,
channel_widget->type);
valid = gimp_image_preview_valid (channel_widget->gimage);
break;
}
......@@ -2108,18 +2106,18 @@ channel_widget_preview_redraw (ChannelWidget *channel_widget)
if (channelsD->ratio > 1.0) /* Preview is scaling up! */
{
preview_buf =
gimp_drawable_preview (GIMP_DRAWABLE (channel_widget->channel),
gimp_viewable_preview (GIMP_VIEWABLE (channel_widget->channel),
channelsD->gimage_width,
channelsD->gimage_height);
preview_buf = gimp_preview_scale (preview_buf,
channel_widget->width,
channel_widget->height);
preview_buf = temp_buf_scale (preview_buf,
channel_widget->width,
channel_widget->height);
}
else
{
preview_buf =
gimp_drawable_preview (GIMP_DRAWABLE (channel_widget->channel),
gimp_viewable_preview (GIMP_VIEWABLE (channel_widget->channel),
channel_widget->width,
channel_widget->height);
}
......@@ -2133,20 +2131,21 @@ channel_widget_preview_redraw (ChannelWidget *channel_widget)
if (channelsD->ratio > 1.0) /* Preview is scaling up! */
{
preview_buf = gimp_image_composite_preview (channel_widget->gimage,
channel_widget->type,
width,
height);
preview_buf = gimp_preview_scale (preview_buf,
channel_widget->width,
channel_widget->height);
preview_buf =
gimp_viewable_preview (GIMP_VIEWABLE (channel_widget->gimage),
width,
height);
preview_buf = temp_buf_scale (preview_buf,
channel_widget->width,
channel_widget->height);
}
else
{
preview_buf = gimp_image_composite_preview (channel_widget->gimage,
channel_widget->type,
channel_widget->width,
channel_widget->height);
preview_buf =
gimp_viewable_preview (GIMP_VIEWABLE (channel_widget->gimage),
channel_widget->width,
channel_widget->height);
}
break;
}
......@@ -2457,11 +2456,10 @@ channel_widget_channel_flush (GtkWidget *widget,
switch (channel_widget->type)
{
case AUXILLARY_CHANNEL:
update_preview = !GIMP_DRAWABLE (channel_widget->channel)->preview_valid;
update_preview = ! GIMP_DRAWABLE (channel_widget->channel)->preview_valid;
break;
default:
update_preview = !gimp_image_preview_valid (channel_widget->gimage,
channel_widget->type);
update_preview = ! gimp_image_preview_valid (channel_widget->gimage);
break;
}
......
......@@ -1448,7 +1448,7 @@ convert_image (GImage *gimage,
/* shrink wrap and update all views */
gimp_image_invalidate_layer_previews (gimage);
gimp_image_invalidate_preview (gimage);
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
gdisplays_update_title (gimage);
gdisplays_update_full (gimage);
......
......@@ -35,7 +35,6 @@
#include "gimage_mask.h"
#include "gimpchannel.h"
#include "gimplayer.h"
#include "gimppreviewcache.h"
#include "gimplut.h"
#include "paint_funcs.h"
#include "parasitelist.h"
......
......@@ -35,7 +35,6 @@
#include "gimage_mask.h"
#include "gimpchannel.h"
#include "gimplayer.h"
#include "gimppreviewcache.h"
#include "gimplut.h"
#include "paint_funcs.h"
#include "parasitelist.h"
......
......@@ -323,7 +323,7 @@ gboolean
gimp_container_have (GimpContainer *container,
GimpObject *object)
{
gboolean have;
gboolean have = FALSE;
g_return_val_if_fail (container != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
......
......@@ -32,6 +32,7 @@
#include "gimage_mask.h"
#include "gimpchannel.h"
#include "gimpdrawable.h"
#include "gimpdrawablepreview.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimppreviewcache.h"
......@@ -51,22 +52,22 @@
enum
{
REMOVED,
INVALIDATE_PREVIEW,
LAST_SIGNAL
};
static void gimp_drawable_class_init (GimpDrawableClass *klass);
static void gimp_drawable_init (GimpDrawable *drawable);
static void gimp_drawable_destroy (GtkObject *object);
static void gimp_drawable_name_changed (GimpObject *drawable);
static void gimp_drawable_class_init (GimpDrawableClass *klass);
static void gimp_drawable_init (GimpDrawable *drawable);
static void gimp_drawable_destroy (GtkObject *object);
static void gimp_drawable_name_changed (GimpObject *drawable);
static void gimp_drawable_invalidate_preview (GimpViewable *viewable);
/* private variables */
static guint gimp_drawable_signals[LAST_SIGNAL] = { 0 };
static GimpDrawableClass *parent_class = NULL;
static GimpViewableClass *parent_class = NULL;
static gint global_drawable_ID = 1;
static GHashTable *gimp_drawable_table = NULL;
......@@ -91,7 +92,7 @@ gimp_drawable_get_type (void)
(GtkClassInitFunc) NULL,
};
drawable_type = gtk_type_unique (GIMP_TYPE_OBJECT, &drawable_info);
drawable_type = gtk_type_unique (GIMP_TYPE_VIEWABLE, &drawable_info);
}
return drawable_type;
......@@ -100,13 +101,15 @@ gimp_drawable_get_type (void)
static void
gimp_drawable_class_init (GimpDrawableClass *klass)
{
GtkObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GtkObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
object_class = (GtkObjectClass *) klass;
gimp_object_class = (GimpObjectClass *) klass;
viewable_class = (GimpViewableClass *) klass;
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_drawable_signals[REMOVED] =
gtk_signal_new ("removed",
......@@ -117,15 +120,6 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_drawable_signals[INVALIDATE_PREVIEW] =
gtk_signal_new ("invalidate_preview",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpDrawableClass,
invalidate_preview),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, gimp_drawable_signals,
LAST_SIGNAL);
......@@ -133,8 +127,10 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
gimp_object_class->name_changed = gimp_drawable_name_changed;
klass->removed = NULL;
klass->invalidate_preview = NULL;
viewable_class->invalidate_preview = gimp_drawable_invalidate_preview;
viewable_class->preview = gimp_drawable_preview;
klass->removed = NULL;
}
static void
......@@ -284,6 +280,22 @@ gimp_drawable_name_changed (GimpObject *object)
}
}
static void
gimp_drawable_invalidate_preview (GimpViewable *viewable)
{
GimpDrawable *drawable;
GimpImage *gimage;
drawable = GIMP_DRAWABLE (viewable);
drawable->preview_valid = FALSE;
gimage = gimp_drawable_gimage (drawable);
if (gimage)
gimage->comp_preview_valid = FALSE;
}
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage *gimage,
......@@ -512,30 +524,6 @@ gimp_drawable_mask_bounds (GimpDrawable *drawable,
}
}
void
gimp_drawable_invalidate_preview (GimpDrawable *drawable,
gboolean emit_signal)
{
GimpImage *gimage;
g_return_if_fail (drawable != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
drawable->preview_valid = FALSE;
if (emit_signal)
gtk_signal_emit (GTK_OBJECT (drawable),
gimp_drawable_signals[INVALIDATE_PREVIEW]);
gimage = gimp_drawable_gimage (drawable);
if (gimage)
{
gimage->comp_preview_valid[0] = FALSE;
gimage->comp_preview_valid[1] = FALSE;
gimage->comp_preview_valid[2] = FALSE;
}
}
/* The removed signal is sent out when the layer is no longer
* associcated with an image. It's needed because layers aren't
* destroyed immediately, but kept around for undo purposes. Connect
......
......@@ -20,7 +20,7 @@
#define __GIMP_DRAWABLE_H__
#include "gimpobject.h"
#include "gimpviewable.h"
#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ())
......@@ -34,7 +34,7 @@ typedef struct _GimpDrawableClass GimpDrawableClass;
struct _GimpDrawable
{
GimpObject parent_instance;
GimpViewable parent_instance;
TileManager *tiles; /* tiles for drawable data */
gboolean visible; /* controls visibility */
......@@ -57,10 +57,9 @@ struct _GimpDrawable
struct _GimpDrawableClass
{
GimpObjectClass parent_class;
GimpViewableClass parent_class;
void (* removed) (GimpDrawable *drawable);
void (* invalidate_preview) (GimpDrawable *drawable);
void (* removed) (GimpDrawable *drawable);
};
......@@ -93,8 +92,6 @@ gboolean gimp_drawable_mask_bounds (GimpDrawable *drawable,
gint *x2,
gint *y2);
void gimp_drawable_invalidate_preview (GimpDrawable *drawable,
gboolean emit_signal);
void gimp_drawable_removed (GimpDrawable *drawable);
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
......
......@@ -1448,7 +1448,7 @@ convert_image (GImage *gimage,
/* shrink wrap and update all views */
gimp_image_invalidate_layer_previews (gimage);
gimp_image_invalidate_preview (gimage);
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
gdisplays_update_title (gimage);
gdisplays_update_full (gimage);
......
......@@ -33,7 +33,6 @@
#include "gdisplay.h"
#include "gimage_mask.h"
#include "gimpcontext.h"
#include "gimpdrawablepreview.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimplayermask.h"
......@@ -63,59 +62,68 @@
/* Local function declarations */
static void gimp_image_destroy (GtkObject *object);
static void gimp_image_name_changed (GimpObject *object);
static void gimp_image_free_projection (GimpImage *gimage);
static void gimp_image_allocate_shadow (GimpImage *gimage,
gint width,
gint height,
gint bpp);
static void gimp_image_allocate_projection (GimpImage *gimage);
static void gimp_image_free_layers (GimpImage *gimage);
static void gimp_image_free_channels (GimpImage *gimage);
static void gimp_image_construct_layers (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void gimp_image_construct_channels (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void gimp_image_initialize_projection (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h);
static void gimp_image_get_active_channels (GimpImage *gimage,
GimpDrawable *drawable,