gimp/app/core/gimpprojection-construct.c

509 lines
16 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 14:53:55 +00:00
#include <glib-object.h>
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-23 18:49:44 +00:00
#include "libgimpcolor/gimpcolor.h"
#include "core-types.h"
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * configure.in: new directory app/base/ * app/Makefile.am * app/boundary.[ch] * app/brush_scale.[ch] * app/gimpchecks.h * app/gimplut.[ch] * app/pixel_processor.[ch] * app/pixel_region.[ch] * app/pixel_surround.[ch] * app/temp_buf.[ch] * app/tile.[ch] * app/tile_cache.[ch] * app/tile_manager.[ch] * app/tile_manager_pvt.h * app/tile_pvt.h * app/tile_swap.[ch]: moved to base/ * app/base/Makefile.am * app/base/base-types.h * app/base/*: new directory for the sub-object pixel maniplation and storage stuff. Does not include Gtk+ or anything outside base/. Did some cleanup in all files. * app/appenums.h * app/apptypes.h * app/core/gimpimage.h: removed types which are now in base/base-types.h. * app/base/base-config.[ch] * app/gimprc.[ch]: put the config variables for base/ to their own file so base/ doesn not have to include gimprc.h (does not yet work, i.e. the variables are un-configurable right now) * app/main.c: set a log handler for "Gimp-Base". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs.[ch]: removed the color hash which maps RGB to color indices because it's a totally standalone system which has nothing to do with the paint-funcs and introduced a GimpImage dependency. paint-funcs/ should be considered on the same sub-object (glib-only) level as base/, only in a different directory. * app/core/Makefile.am * app/core/gimpimage-colorhash.[ch]: put the color hash here. * app/gimage.c: don't invalidate the color hash here... * app/core/gimpimage.c: ... but in the colormap_changed() default inplementation. Initialize the hash in class_init(). * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. * tools/pdbgen/enums.pl: regenerated. * app/[lots] * app/core/[of] * app/gui/[files] * app/pdb/[all] * app/tools/[over] * app/widgets/[the] * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use base_config->value instead of the stuff from gimprc.h.
2001-05-15 11:25:25 +00:00
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 15:22:01 +00:00
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimplayermask.h"
#include "gimplist.h"
2004-07-13 16:36:29 +00:00
#include "gimpprojection.h"
#include "gimpprojection-construct.h"
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-04 19:31:35 +00:00
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * configure.in: new directory app/base/ * app/Makefile.am * app/boundary.[ch] * app/brush_scale.[ch] * app/gimpchecks.h * app/gimplut.[ch] * app/pixel_processor.[ch] * app/pixel_region.[ch] * app/pixel_surround.[ch] * app/temp_buf.[ch] * app/tile.[ch] * app/tile_cache.[ch] * app/tile_manager.[ch] * app/tile_manager_pvt.h * app/tile_pvt.h * app/tile_swap.[ch]: moved to base/ * app/base/Makefile.am * app/base/base-types.h * app/base/*: new directory for the sub-object pixel maniplation and storage stuff. Does not include Gtk+ or anything outside base/. Did some cleanup in all files. * app/appenums.h * app/apptypes.h * app/core/gimpimage.h: removed types which are now in base/base-types.h. * app/base/base-config.[ch] * app/gimprc.[ch]: put the config variables for base/ to their own file so base/ doesn not have to include gimprc.h (does not yet work, i.e. the variables are un-configurable right now) * app/main.c: set a log handler for "Gimp-Base". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs.[ch]: removed the color hash which maps RGB to color indices because it's a totally standalone system which has nothing to do with the paint-funcs and introduced a GimpImage dependency. paint-funcs/ should be considered on the same sub-object (glib-only) level as base/, only in a different directory. * app/core/Makefile.am * app/core/gimpimage-colorhash.[ch]: put the color hash here. * app/gimage.c: don't invalidate the color hash here... * app/core/gimpimage.c: ... but in the colormap_changed() default inplementation. Initialize the hash in class_init(). * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. * tools/pdbgen/enums.pl: regenerated. * app/[lots] * app/core/[of] * app/gui/[files] * app/pdb/[all] * app/tools/[over] * app/widgets/[the] * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use base_config->value instead of the stuff from gimprc.h.
2001-05-15 11:25:25 +00:00
/* local function prototypes */
2004-07-13 16:36:29 +00:00
static void gimp_projection_construct_layers (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h);
static void gimp_projection_construct_channels (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h);
static void gimp_projection_initialize (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h);
static void project_intensity (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask);
static void project_intensity_alpha (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask);
static void project_indexed (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest);
static void project_indexed_alpha (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask);
static void project_channel (GimpProjection *proj,
GimpChannel *channel,
PixelRegion *src,
PixelRegion *src2);
/* public functions */
void
2004-07-13 16:36:29 +00:00
gimp_projection_construct (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h)
{
2004-07-13 16:36:29 +00:00
g_return_if_fail (GIMP_IS_PROJECTION (proj));
2004-07-13 16:36:29 +00:00
#if 0
gint xoff;
gint yoff;
2004-07-13 16:36:29 +00:00
/* set the construct flag, used to determine if anything
* has been written to the gimage raw image yet.
*/
2004-07-13 16:36:29 +00:00
gimage->construct_flag = FALSE;
2004-07-13 16:36:29 +00:00
if (gimage->layers)
{
2004-07-13 16:36:29 +00:00
gimp_item_offsets (GIMP_ITEM (gimage->layers->data), &xoff, &yoff);
}
2004-07-13 16:36:29 +00:00
if ((gimage->layers) && /* There's a layer. */
(! g_slist_next (gimage->layers)) && /* It's the only layer. */
(gimp_drawable_has_alpha (GIMP_DRAWABLE (gimage->layers->data))) &&
/* It's !flat. */
(gimp_item_get_visible (GIMP_ITEM (gimage->layers->data))) &&
/* It's visible. */
(gimp_item_width (GIMP_ITEM (gimage->layers->data)) ==
gimage->width) &&
(gimp_item_height (GIMP_ITEM (gimage->layers->data)) ==
gimage->height) && /* Covers all. */
(!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) &&
/* Not indexed. */
(((GimpLayer *)(gimage->layers->data))->opacity == GIMP_OPACITY_OPAQUE)
/* Opaque */
)
{
2004-07-13 16:36:29 +00:00
gint xoff;
gint yoff;
2004-07-13 16:36:29 +00:00
gimp_item_offsets (GIMP_ITEM (gimage->layers->data), &xoff, &yoff);
2004-07-13 16:36:29 +00:00
if ((xoff==0) && (yoff==0)) /* Starts at 0,0 */
{
PixelRegion srcPR, destPR;
gpointer pr;
comment typo fix, plus add %D* to default image-title-format string, so Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org> * gimprc.in: comment typo fix, plus add %D* to default image-title-format string, so people get a '*' in the titlebar if their image is dirty. * app/fileops.c: initialise filename before using it. * app/gdisplay.c: empty parameter list () is K&R - should be stronger (void) in ANSI C. * app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions removed - no one uses them anyway. Parasite undo type is proper parasite undo type, not MISC_UNDO. * app/gimpdrawableP.h: drawable dirty bit removed. * app/gimpimage.c: don't change the resolution if there's no difference from the old one. Call gdisplay_shrink_wrap() to re-calculate scale factors and refresh the display on resolution change. Layer undo doesn't have sub-types anymore, uses main UndoType instead. * app/layer.h: Remove LayerUndoType * app/qmask.c: fix qmask undo so it actually works. * app/undo.h: new types for undo_push_layer{,_mask} and undo_push_qmask. * app/undo.c: change way group boundaries are represented: each Undo has a group_boundary boolean set to TRUE if this is the start or the end of a group, and the type of the Undo is the group's type. Within a group, each Undo keeps its own type. This allows pop funcs and free funcs to do type-specific things (eg needed by layer and channel stuff). Don't maintain per-drawable dirty flags anymore. Floating sel to layer and layer rename now uses meaningful undo types. * app/undo_types.h: more specific undo types: LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO, LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO. * app/undo_history.c: oops - undo stack was being placed into gtk list in wrong order. * app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO rather than MISC_UNDO. * app/layers_dialog.c: better tagging of undo types
1999-10-01 18:43:24 +00:00
2004-07-13 16:36:29 +00:00
g_warning("Can use cow-projection hack. Yay!");
2004-07-13 16:36:29 +00:00
pixel_region_init (&srcPR, gimp_drawable_data
(GIMP_DRAWABLE (gimage->layers->data)),
x, y, w,h, FALSE);
pixel_region_init (&destPR,
gimp_image_projection (gimage),
x, y, w,h, TRUE);
2004-07-13 16:36:29 +00:00
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr != NULL;
pr = pixel_regions_process (pr))
{
tile_manager_map_over_tile (destPR.tiles,
destPR.curtile, srcPR.curtile);
}
2004-07-13 16:36:29 +00:00
gimage->construct_flag = TRUE;
gimp_image_construct_channels (gimage, x, y, w, h);
2004-07-13 16:36:29 +00:00
return;
}
}
#else
proj->construct_flag = FALSE;
#endif
2004-07-13 16:36:29 +00:00
/* First, determine if the projection image needs to be
* initialized--this is the case when there are no visible
* layers that cover the entire canvas--either because layers
* are offset or only a floating selection is visible
*/
2004-07-13 16:36:29 +00:00
gimp_projection_initialize (proj, x, y, w, h);
2004-07-13 16:36:29 +00:00
/* call functions which process the list of layers and
* the list of channels
*/
2004-07-13 16:36:29 +00:00
gimp_projection_construct_layers (proj, x, y, w, h);
gimp_projection_construct_channels (proj, x, y, w, h);
}
/* private functions */
static void
2004-07-13 16:36:29 +00:00
gimp_projection_construct_layers (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h)
{
GimpLayer *layer;
gint x1, y1, x2, y2;
PixelRegion src1PR, src2PR, maskPR;
PixelRegion * mask;
GList *list;
GList *reverse_list;
gint off_x;
gint off_y;
/* composite the floating selection if it exists */
2004-07-13 16:36:29 +00:00
if ((layer = gimp_image_floating_sel (proj->gimage)))
floating_sel_composite (layer, x, y, w, h, FALSE);
reverse_list = NULL;
2004-07-13 16:36:29 +00:00
for (list = GIMP_LIST (proj->gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
/* only add layers that are visible and not floating selections
* to the list
*/
if (! gimp_layer_is_floating_sel (layer) &&
gimp_item_get_visible (GIMP_ITEM (layer)))
{
reverse_list = g_list_prepend (reverse_list, layer);
}
}
for (list = reverse_list; list; list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
removed gimp_drawable_offsets(). 2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_offsets(). * app/core/gimpitem.[ch]: added gimp_item_offsets(). * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-histogram.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask-select.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-pick-color.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimppaintcore.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c: regenerated.
2003-05-08 14:06:03 +00:00
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
x1 = CLAMP (off_x, x, x + w);
y1 = CLAMP (off_y, y, y + h);
removed gimp_drawable_width,height(). 2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_width,height(). * app/core/gimpitem.[ch]: added gimp_item_width,height(). * app/core/gimpchannel.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-offset.c * app/core/gimpdrawable-preview.c * app/core/gimpdrawable-transform.c * app/core/gimpimage-contiguous-region.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimpimagemap.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/core/gimplayermask.c * app/core/gimpscanconvert.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimpclone.c * app/paint/gimpconvolve.c * app/paint/gimpdodgeburn.c * app/paint/gimppaintcore.c * app/paint/gimpsmudge.c * app/text/gimptextlayer.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimphistogramtool.c * app/tools/gimpinktool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/selection.pdb: changed accordingly. * app/pdb/drawable_cmds.c * app/pdb/selection_cmds.c: regenerated.
2003-05-08 13:12:46 +00:00
x2 = CLAMP (off_x + gimp_item_width (GIMP_ITEM (layer)), x, x + w);
y2 = CLAMP (off_y + gimp_item_height (GIMP_ITEM (layer)), y, y + h);
/* configure the pixel regions */
2004-07-13 16:36:29 +00:00
pixel_region_init (&src1PR, gimp_projection_get_tiles (proj),
x1, y1, (x2 - x1), (y2 - y1),
TRUE);
/* If we're showing the layer mask instead of the layer... */
if (layer->mask && layer->mask->show_mask)
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
copy_gray_to_region (&src2PR, &src1PR);
}
/* Otherwise, normal */
else
{
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (layer)),
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
if (layer->mask && layer->mask->apply_mask)
{
pixel_region_init (&maskPR,
gimp_drawable_data (GIMP_DRAWABLE (layer->mask)),
(x1 - off_x), (y1 - off_y),
(x2 - x1), (y2 - y1), FALSE);
mask = &maskPR;
}
else
mask = NULL;
/* Based on the type of the layer, project the layer onto the
* projection image...
*/
switch (gimp_drawable_type (GIMP_DRAWABLE (layer)))
{
case GIMP_RGB_IMAGE: case GIMP_GRAY_IMAGE:
/* no mask possible */
2004-07-13 16:36:29 +00:00
project_intensity (proj, layer, &src2PR, &src1PR, mask);
break;
case GIMP_RGBA_IMAGE: case GIMP_GRAYA_IMAGE:
2004-07-13 16:36:29 +00:00
project_intensity_alpha (proj, layer, &src2PR, &src1PR, mask);
break;
case GIMP_INDEXED_IMAGE:
/* no mask possible */
2004-07-13 16:36:29 +00:00
project_indexed (proj, layer, &src2PR, &src1PR);
break;
case GIMP_INDEXEDA_IMAGE:
2004-07-13 16:36:29 +00:00
project_indexed_alpha (proj, layer, &src2PR, &src1PR, mask);
break;
default:
break;
}
}
2004-07-13 16:36:29 +00:00
proj->construct_flag = TRUE; /* something was projected */
}
g_list_free (reverse_list);
}
static void
2004-07-13 16:36:29 +00:00
gimp_projection_construct_channels (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h)
{
GimpChannel *channel;
PixelRegion src1PR;
PixelRegion src2PR;
GList *list;
GList *reverse_list = NULL;
/* reverse the channel list */
2004-07-13 16:36:29 +00:00
for (list = GIMP_LIST (proj->gimage->channels)->list;
list;
list = g_list_next (list))
{
reverse_list = g_list_prepend (reverse_list, list->data);
}
for (list = reverse_list; list; list = g_list_next (list))
{
channel = (GimpChannel *) list->data;
if (gimp_item_get_visible (GIMP_ITEM (channel)))
{
/* configure the pixel regions */
pixel_region_init (&src1PR,
2004-07-13 16:36:29 +00:00
gimp_projection_get_tiles (proj),
x, y, w, h,
TRUE);
pixel_region_init (&src2PR,
gimp_drawable_data (GIMP_DRAWABLE (channel)),
x, y, w, h,
FALSE);
2004-07-13 16:36:29 +00:00
project_channel (proj, channel, &src1PR, &src2PR);
2004-07-13 16:36:29 +00:00
proj->construct_flag = TRUE;
}
}
g_list_free (reverse_list);
}
static void
2004-07-13 16:36:29 +00:00
gimp_projection_initialize (GimpProjection *proj,
gint x,
gint y,
gint w,
gint h)
{
2004-07-13 16:36:29 +00:00
GList *list;
gboolean coverage = FALSE;
/* this function determines whether a visible layer
* provides complete coverage over the image. If not,
* the projection is initialized to transparent
*/
2004-07-13 16:36:29 +00:00
for (list = GIMP_LIST (proj->gimage->layers)->list;
list;
list = g_list_next (list))
{
2004-07-13 16:36:29 +00:00
GimpItem *item = list->data;
removed gimp_drawable_offsets(). 2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_offsets(). * app/core/gimpitem.[ch]: added gimp_item_offsets(). * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-histogram.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask-select.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-pick-color.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimppaintcore.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c: regenerated.
2003-05-08 14:06:03 +00:00
gint off_x, off_y;
removed gimp_drawable_offsets(). 2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_offsets(). * app/core/gimpitem.[ch]: added gimp_item_offsets(). * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-histogram.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask-select.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-pick-color.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimppaintcore.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c: regenerated.
2003-05-08 14:06:03 +00:00
gimp_item_offsets (item, &off_x, &off_y);
2004-07-13 16:36:29 +00:00
if (gimp_item_get_visible (item) &&
removed gimp_drawable_offsets(). 2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_offsets(). * app/core/gimpitem.[ch]: added gimp_item_offsets(). * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-histogram.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask-select.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-pick-color.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimppaintcore.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c: regenerated.
2003-05-08 14:06:03 +00:00
! gimp_drawable_has_alpha (GIMP_DRAWABLE (item)) &&
(off_x <= x) &&
(off_y <= y) &&
(off_x + gimp_item_width (item) >= x + w) &&
removed gimp_drawable_offsets(). 2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_offsets(). * app/core/gimpitem.[ch]: added gimp_item_offsets(). * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-histogram.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask-select.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-pick-color.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimppaintcore.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c: regenerated.
2003-05-08 14:06:03 +00:00
(off_y + gimp_item_height (item) >= y + h))
{
2004-07-13 16:36:29 +00:00
coverage = TRUE;
break;
}
}
if (!coverage)
{
2004-07-13 16:36:29 +00:00
PixelRegion PR;
guchar clear[4] = { 0, 0, 0, 0 };
pixel_region_init (&PR, gimp_projection_get_tiles (proj),
x, y, w, h, TRUE);
color_region (&PR, clear);
}
}
static void
2004-07-13 16:36:29 +00:00
project_intensity (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask)
{
2004-07-13 16:36:29 +00:00
if (! proj->construct_flag)
initial_region (src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
INITIAL_INTENSITY);
else
combine_regions (dest, src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
COMBINE_INTEN_A_INTEN);
}
static void
2004-07-13 16:36:29 +00:00
project_intensity_alpha (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask)
{
2004-07-13 16:36:29 +00:00
if (! proj->construct_flag)
initial_region (src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
INITIAL_INTENSITY_ALPHA);
else
combine_regions (dest, src, dest, mask, NULL,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
COMBINE_INTEN_A_INTEN_A);
}
static void
2004-07-13 16:36:29 +00:00
project_indexed (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest)
{
2004-07-13 16:36:29 +00:00
g_return_if_fail (proj->gimage->cmap != NULL);
2004-07-13 16:36:29 +00:00
if (! proj->construct_flag)
initial_region (src, dest, NULL, proj->gimage->cmap,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
INITIAL_INDEXED);
else
g_warning ("%s: unable to project indexed image.", G_STRFUNC);
}
static void
2004-07-13 16:36:29 +00:00
project_indexed_alpha (GimpProjection *proj,
GimpLayer *layer,
PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask)
{
2004-07-13 16:36:29 +00:00
g_return_if_fail (proj->gimage->cmap != NULL);
2004-07-13 16:36:29 +00:00
if (! proj->construct_flag)
initial_region (src, dest, mask, proj->gimage->cmap,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
INITIAL_INDEXED_ALPHA);
else
2004-07-13 16:36:29 +00:00
combine_regions (dest, src, dest, mask, proj->gimage->cmap,
layer->opacity * 255.999,
layer->mode,
2004-07-13 16:36:29 +00:00
proj->gimage->visible,
COMBINE_INTEN_A_INDEXED_A);
}
static void
2004-07-13 16:36:29 +00:00
project_channel (GimpProjection *proj,
GimpChannel *channel,
PixelRegion *src,
PixelRegion *src2)
{
guchar col[3];
guchar opacity;
gint type;
gimp_rgba_get_uchar (&channel->color,
&col[0], &col[1], &col[2], &opacity);
2004-07-13 16:36:29 +00:00
if (! proj->construct_flag)
{
type = (channel->show_masked) ?
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
initial_region (src2, src, NULL, col,
opacity,
GIMP_NORMAL_MODE,
NULL,
type);
}
else
{
type = (channel->show_masked) ?
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
combine_regions (src, src2, src, NULL, col,
opacity,
GIMP_NORMAL_MODE,
NULL,
type);
}
}