Commit 24032473 authored by BST 1999  Adam D. Moss's avatar BST 1999 Adam D. Moss Committed by Adam D. Moss
Browse files

Preview layers need to be alpha-padded, since they're not on the bottom of

Sat Aug 21 16:53:17 BST 1999  Adam D. Moss  <adam@gimp.org>

	* plug-ins/common/jpeg.c:  Preview layers need to be alpha-padded,
	since they're not on the bottom of the stack.  That's a GIMP rule.

	Plus... use new API functions gimp_image_{freeze,thaw}_undo() to avoid
	the dilemma of either consuming a squillion superfluous tiles or
	clobbering the whole undo stack.

	* app/gimage.h
	* app/gimage_cmds.c
	* app/gimpimage.c
	* libgimp/gimp.h
	* libgimp/gimpimage.c: New API functions
	gimp_image_{freeze,thaw}_undo()	to avoid the above twin	evils.
	Similar to gimp_image_{disable,enable}_undo() but without
	clobbering the undo stack (I would have simply changed the latter,
	but too many plugins seem to rely on that behaviour).  See the PDB
	docs for slightly more information.
parent 0bcaca2f
Sat Aug 21 16:53:17 BST 1999 Adam D. Moss <adam@gimp.org>
* plug-ins/common/jpeg.c: Preview layers need to be alpha-padded,
since they're not on the bottom of the stack. That's a GIMP rule.
Plus... use new API functions gimp_image_{freeze,thaw}_undo() to avoid
the dilemma of either consuming a squillion superfluous tiles or
clobbering the whole undo stack.
* app/gimage.h
* app/gimage_cmds.c
* app/gimpimage.c
* libgimp/gimp.h
* libgimp/gimpimage.c: New API functions
gimp_image_{freeze,thaw}_undo() to avoid the above twin evils.
Similar to gimp_image_{disable,enable}_undo() but without
clobbering the undo stack (I would have simply changed the latter,
but too many plugins seem to rely on that behaviour). See the PDB
docs for slightly more information.
Sat Aug 21 8:47:00 CST 1999 Seth Burgess <sjburges@gimp.org>
* plug-ins/common/jpeg.c : added a patch by Xach for slider
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -98,6 +98,8 @@ void gimage_foreach (GFunc func, gpointer user_data);
#define gimage_filename gimp_image_filename
#define gimage_enable_undo gimp_image_enable_undo
#define gimage_disable_undo gimp_image_disable_undo
#define gimage_thaw_undo gimp_image_thaw_undo
#define gimage_freeze_undo gimp_image_freeze_undo
#define gimage_dirty gimp_image_dirty
#define gimage_clean gimp_image_clean
#define gimage_clean_all gimp_image_clean_all
......
......@@ -63,6 +63,8 @@ static ProcRecord image_get_cmap_proc;
static ProcRecord image_set_cmap_proc;
static ProcRecord image_enable_undo_proc;
static ProcRecord image_disable_undo_proc;
static ProcRecord image_thaw_undo_proc;
static ProcRecord image_freeze_undo_proc;
static ProcRecord image_clean_all_proc;
static ProcRecord image_floating_selection_proc;
static ProcRecord image_floating_sel_attached_to_proc;
......@@ -121,6 +123,8 @@ register_gimage_procs (void)
procedural_db_register (&image_set_cmap_proc);
procedural_db_register (&image_enable_undo_proc);
procedural_db_register (&image_disable_undo_proc);
procedural_db_register (&image_thaw_undo_proc);
procedural_db_register (&image_freeze_undo_proc);
procedural_db_register (&image_clean_all_proc);
procedural_db_register (&image_floating_selection_proc);
procedural_db_register (&image_floating_sel_attached_to_proc);
......@@ -1906,6 +1910,7 @@ static ProcRecord image_set_cmap_proc =
{ { image_set_cmap_invoker } }
};
static Argument *
image_enable_undo_invoker (Argument *args)
{
......@@ -1962,6 +1967,64 @@ static ProcRecord image_enable_undo_proc =
{ { image_enable_undo_invoker } }
};
static Argument *
image_thaw_undo_invoker (Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpImage *gimage;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
if (success)
success = gimage_thaw_undo (gimage);
return_args = procedural_db_return_args (&image_thaw_undo_proc, success);
if (success)
return_args[1].value.pdb_int = success ? TRUE : FALSE;
return return_args;
}
static ProcArg image_thaw_undo_inargs[] =
{
{
PDB_IMAGE,
"image",
"The image"
}
};
static ProcArg image_thaw_undo_outargs[] =
{
{
PDB_INT32,
"thawed",
"True if the image undo has been thawed"
}
};
static ProcRecord image_thaw_undo_proc =
{
"gimp_image_thaw_undo",
"Thaw the image's undo stack.",
"This procedure thaws the image's undo stack, allowing subsequent operations to store their undo steps. This is generally called in conjunction with 'gimp_image_disable_freeze' to temporarily freeze an image undo stack. 'gimp_image_thaw_undo' does NOT free the undo stack as 'gimp_image_enable_undo' does, so is suited for situations where one wishes to leave the undo stack in the same state in which one found it despite non-destructively playing with the image in the meantime. An example would be in-situ plugin previews. Balancing freezes and thaws and ensuring image consistancy is the responsibility of the caller.",
"Adam D. Moss",
"Adam D. Moss",
"1999",
PDB_INTERNAL,
1,
image_thaw_undo_inargs,
1,
image_thaw_undo_outargs,
{ { image_thaw_undo_invoker } }
};
///////////////
static Argument *
image_disable_undo_invoker (Argument *args)
{
......@@ -2018,6 +2081,62 @@ static ProcRecord image_disable_undo_proc =
{ { image_disable_undo_invoker } }
};
static Argument *
image_freeze_undo_invoker (Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpImage *gimage;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
if (success)
success = gimage_freeze_undo (gimage);
return_args = procedural_db_return_args (&image_freeze_undo_proc, success);
if (success)
return_args[1].value.pdb_int = success ? TRUE : FALSE;
return return_args;
}
static ProcArg image_freeze_undo_inargs[] =
{
{
PDB_IMAGE,
"image",
"The image"
}
};
static ProcArg image_freeze_undo_outargs[] =
{
{
PDB_INT32,
"frozen",
"True if the image undo has been frozen"
}
};
static ProcRecord image_freeze_undo_proc =
{
"gimp_image_freeze_undo",
"Freeze the image's undo stack.",
"This procedure freezes the image's undo stack, allowing subsequent operations to ignore their undo steps. This is generally called in conjunction with 'gimp_image_thaw_undo' to temporarily disable an image undo stack. This is advantageous because saving undo steps can be time and memory intensive. 'gimp_image_{freeze,thaw}_undo' and 'gimp_image_{disable,enable}_undo' differ in that the former does not free up all undo steps when undo is thawed, so is more suited to interactive in-situ previews. It is important in this case that the image is back to the same state it was frozen in before thawing, else 'undo' behaviour is undefined.",
"Adam D. Moss",
"Adam D. Moss",
"1999",
PDB_INTERNAL,
1,
image_freeze_undo_inargs,
1,
image_freeze_undo_outargs,
{ { image_freeze_undo_invoker } }
};
static Argument *
image_clean_all_invoker (Argument *args)
{
......
......@@ -3337,11 +3337,16 @@ gimp_image_filename (GimpImage *gimage)
}
int
gimp_image_enable_undo (GimpImage *gimage)
gimp_image_freeze_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
gimage->undo_on = FALSE;
return TRUE;
}
int
gimp_image_thaw_undo (GimpImage *gimage)
{
gimage->undo_on = TRUE;
return TRUE;
......@@ -3350,8 +3355,16 @@ gimp_image_enable_undo (GimpImage *gimage)
int
gimp_image_disable_undo (GimpImage *gimage)
{
gimage->undo_on = FALSE;
return TRUE;
return gimp_image_freeze_undo (gimage);
}
int
gimp_image_enable_undo (GimpImage *gimage)
{
/* Free all undo steps as they are now invalidated */
undo_free (gimage);
return gimp_image_thaw_undo (gimage);
}
int
......@@ -3559,7 +3572,8 @@ gimp_image_construct_composite_preview (GimpImage *gimage,
* composite preview...
* Indexed images are actually already converted to RGB and RGBA,
* so just project them as if they were type "intensity"
* Send in all TRUE for visible since that info doesn't matter for previews
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (drawable_type (GIMP_DRAWABLE(layer)))
{
......
......@@ -439,6 +439,8 @@ void gimp_image_add_layer_mask (gint32 image_ID,
void gimp_image_clean_all (gint32 image_ID);
void gimp_image_disable_undo (gint32 image_ID);
void gimp_image_enable_undo (gint32 image_ID);
void gimp_image_freeze_undo (gint32 image_ID);
void gimp_image_thaw_undo (gint32 image_ID);
void gimp_undo_push_group_start (gint32 image_ID);
void gimp_undo_push_group_end (gint32 image_ID);
void gimp_image_clean_all (gint32 image_ID);
......
......@@ -361,6 +361,34 @@ gimp_image_enable_undo (gint32 image_ID)
gimp_destroy_params (return_vals, nreturn_vals);
}
void
gimp_image_freeze_undo (gint32 image_ID)
{
GParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure ("gimp_image_freeze_undo",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
gimp_destroy_params (return_vals, nreturn_vals);
}
void
gimp_image_thaw_undo (gint32 image_ID)
{
GParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure ("gimp_image_thaw_undo",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
gimp_destroy_params (return_vals, nreturn_vals);
}
void
gimp_undo_push_group_start (gint32 image_ID)
{
......
......@@ -361,6 +361,34 @@ gimp_image_enable_undo (gint32 image_ID)
gimp_destroy_params (return_vals, nreturn_vals);
}
void
gimp_image_freeze_undo (gint32 image_ID)
{
GParam *return_vals;
int nreturn_vals;