Commit Graph

28 Commits

Author SHA1 Message Date
Jehan ef8ddd7e30 app: rename the new gimp_drawable_*_undo() functions.
These are not generic undo function, but specific to the resize case (and even
more particularly when calling the GimpItem's resize() class method).

Also the variable was wrongly named no_undo when it actually was meant for the
opposite meaning, i.e. when we want to push an undo for a resize() call. This
made the call harder to understand. Furthermore the usage of double negation did
not help with understanding the code.
2023-11-25 21:43:08 +01:00
Shubham df9d1f54f8 app: Fix inefficient method of preventing pushing undo
When resizing drawable for dynamic layers, the resize drawable function
would push Modified Layer/Channel item to undo stack. Initially, I was
checking if the drawable is being painted upon and used it to disable
the undo, but this when using resizing layers with layer mask, even if
mask is being painted upon, we still want to resize the main layer and
vice versa. But the main layer is not being painted upon so it would
push the undo to stack. To prevent this, I was using
gimp_drawable_paint_start before resizing, but this method is very
inefficient, as this function duplicates buffers. So added a new member
to drawable->private that will store weather to push undo or not.
2023-11-25 16:19:43 +00:00
Ell 153cb33eec app: maintain drawable bounding box separately from its logical boundary
Maintain the bounding box of drawables (i.e., the bounds of their
actual rendered content) separately from their logical boundary (as
shown in the UI).

The bounding box is calculated through the new
GimpDrawable::get_bounding_box() virtual function, which has a
corresponding gimp_drawable_get_bounding_box() function; the
default implementation simply returns the drawable's logical
boundary.  The bounding box is specified in drawable coordinates,
i.e., it's not affected by the drawable's offset.

The bounding box is recalculated through
gimp_drawable_update_bounding_box(), which should be called
whenever a change may affect the bounding box (for example, when
setting a new buffer, as done implicitly by GimpDrawable's
::set_buffer() implementation, or when a drawable filter's
properties change, as will be done by GimpDrawableFilter in a
following commit).  When the bounding box changes, the affected
regions of the drawable are updated, and the
GimpDrawable::bounding-box-changed signal is emitted.

When gimp_drawable_update() is called with negative width/height
values, the entire drawable's bounding box is updated, rather than
only its logical boundary.

Likewise, GimpDrawableStack and GimpLayerStack are adapted to use
the bounding box, instead of the logical bounds, when updating the
drawable's area.
2019-08-02 00:40:01 +03:00
Ell 95393722cc Revert "Bug 796090 - (wrong) true-color preview of GEGL filter ops, ..."
We now perform the conversion of filter output to the drawable
format as part of the individual filter nodes (see the last few
commits), so there's no need for another conversion after the
filter stack.

This reverts commit d6e0ca5054.
2018-12-28 03:56:31 -05:00
Michael Natterer e09e563a70 Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.

libgimp:

- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
  as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
  NON_LINEAR and PERCPTUAL for each encoding, matching the babl
  encoding variants RGB, R'G'B' and R~G~B~.

- gimp_color_transform_can_gegl_copy() now returns TRUE if both
  profiles can return a babl space, increasing the amount of fast babl
  color conversions significantly.

- TODO: no solution yet for getting libgimp drawable proxy buffers in
  the right format with space.

plug-ins:

- follow the GimpPrecision change.

- TODO: everything else unchanged and partly broken or sub-optimal,
  like setting a new image's color profile too late.

app:

- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
  replacement for all "linear" booleans.

- change gimp-babl functions to take babl spaces and GimpTRCType
  parameters and support all sorts of new perceptual ~ formats.

- a lot of places changed in the early days of goat invasion didn't
  take advantage of gimp-babl utility functions and constructed
  formats manually. They all needed revisiting and many now use much
  simpler code calling gimp-babl API.

- change gimp_babl_format_get_color_profile() to really extract a
  newly allocated color profile from the format, and add
  gimp_babl_get_builtin_color_profile() which does the same as
  gimp_babl_format_get_color_profile() did before. Visited all callers
  to decide whether they are looking for the format's actual profile,
  or for one of the builtin profiles, simplifying code that only needs
  builtin profiles.

- drawables have a new get_space_api(), get_linear() is now get_trc().

- images now have a "layer space" and an API to get it,
  gimp_image_get_layer_format() returns formats in that space.

- an image's layer space is created from the image's color profile,
  change gimpimage-color-profile to deal with that correctly

- change many babl_format() calls to babl_format_with_space() and take
  the space from passed formats or drawables

- add function gimp_layer_fix_format_space() which replaces the
  layer's buffer with one that has the image's layer format, but
  doesn't change pixel values

- use gimp_layer_fix_format_space() to make sure layers loaded from
  XCF and created by plug-ins have the right space when added to the
  image, because it's impossible to always assign the right space upon
  layer creation

- "assign color profile" and "discard color profile" now require use
  of gimp_layer_fix_format_space() too because the profile is now
  embedded in all formats via the space.  Add
  gimp_image_assign_color_profile() which does all that and call it
  instead of a simple gimp_image_set_color_profile(), also from the
  PDB set-color-profile functions, which are essentially "assign" and
  "discard" calls.

- generally, make sure a new image's color profile is set before
  adding layers to it, gimp_image_set_color_profile() is more than
  before considered know-what-you-are-doing API.

- take special precaution in all places that call
  gimp_drawable_convert_type(), we now must pass a new_profile from
  all callers that convert layers within the same image (such as
  image_convert_type, image_convert_precision), because the layer's
  new space can't be determined from the image's layer format during
  the call.

- change all "linear" properties to "trc", in all config objects like
  for levels and curves, in the histogram, in the widgets. This results
  in some GUI that now has three choices instead of two.
  TODO: we might want to reduce that back to two later.

- keep "linear" boolean properties around as compat if needed for file
  pasring, but always convert the parsed parsed boolean to
  GimpTRCType.

- TODO: the image's "enable color management" switch is currently
  broken, will fix that in another commit.
2018-07-21 16:42:57 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer d6e0ca5054 Bug 796090 - (wrong) true-color preview of GEGL filter ops, ...
...like gaussian blur in indexed mode

In GimpDrawable's source node, after the filter stack, insert a node
that converts the pixels back to the drawable's format if the drawable
is indexed.
2018-05-16 02:09:19 +02:00
Ell ce9ca03ed4 app: add gimp_drawable_{start,end,flush}_paint()
gimp_drawable_start/end_paint() are used to enter/exit paint mode
for a given drawable.  While the drawable is in paint mode,
gimp_drawable_get_buffer() returns a copy of the real drawable's
buffer, referred to as the paint buffer, so that modifications to
the returned buffer don't immediately affect the projection, and
calls to gimp_drawable_update() queue the updated region, instead
of emitting an "update" signal.

gimp_drawable_flush_paint() can be called while the drawable is in
paint mode, in order to copy the updated region of the paint buffer
back to the drawable's real buffer, and to emit "update" signals
for the queued region.

We use these functions in the next commit, to move painting to a
separate thread in the paint tools.
2018-04-08 09:42:47 -04:00
Michael Natterer 8bfb1769b7 app: use a GimpApplicator for floating selection compositing 2013-04-15 01:44:18 +02:00
Michael Natterer 38e983c724 app: fix regression: make the selection clip the FS again 2013-04-12 18:26:34 +02:00
Michael Natterer 538e3813be app: make floating selection compositing honor the image's active components
This was a regression from 2.8
2013-04-12 15:54:05 +02:00
Michael Natterer f3308e6ba3 app: add a GimpFilterStack to each GimpDrawable
which is part of the drawable's source_node, so we can generically
filter a drawable's pixels. Reading from the source_node will
transparently give the filtered results.

Turn floating selection compositing into a GimpFilter and add it to
the filter stack while we have a floating selection on the drawable.
2013-04-11 19:06:23 +02:00
Michael Natterer 4ca746eab7 app: move the "is-last-node" property and API from drawable to filter 2013-04-11 12:25:11 +02:00
Michael Natterer c914aa805d Bug 675747 - Layers with some modes get hidden in layer groups
Add a boolean "is-last-node" property to GimpDrawable and set it from
GimpDrawableStack, which is the place that easily has the information.
In GimpLayer, connect to "notify" and make sure we use NORMAL mode
unless the layer is in NORMAL or DISSOLVE mode.
2012-11-12 10:55:41 +01:00
Michael Natterer 373a4e7469 app: completely remove TileManager and friends (base/ and paint-funcs/)
And along with it a lot of stuff like the drawable preview cache, the
gegl tile manager backend, temporary gimp_gegl_buffer_foo() stuff, and
the remaining bits of performance.

The projection is in an evil semi-ported state which makes it work
ok-ish for stuff like layer moving, but absolutely unbearable for
painting, there is also an off-by-one rendering glitch at some zoom
levels.
2012-06-20 21:44:09 +02:00
Michael Natterer 4699725821 app: port floating selection blending to the new mode ops
Also, remove the fallback layer mode code from GimpOperationPointLayerMode,
and pass premultiplied = FALSE to gimp_gegl_node_set_layer_mode().
2012-05-18 23:37:56 +02:00
Michael Natterer 87b7af7fa5 app: remove drawable->private->format, its buffer has a format already
Also, make group layer type conversion much less hackish by using the
same kind of temporary states that are used for reallocating its
projection on size change.
2012-05-02 17:50:42 +02:00
Michael Natterer 99ae46b4ed app: turn the drawable's shadow tiles into a shadow buffer 2012-05-02 17:46:10 +02:00
Michael Natterer 153f56655a app: rename the buffer's tile_source_node to buffer_source_node 2012-05-02 17:46:08 +02:00
Michael Natterer d5795c0081 app: use a GeglBuffer instead of TileManager as storage in drawables \o/ 2012-05-02 17:46:06 +02:00
Michael Natterer 765c2cfea2 app: replace GimpDraable's type by a Babl format
and change gimp_drawable_new() and all gimp_layer_new() variants to
take formats instead of types.
2012-05-02 17:46:06 +02:00
Michael Natterer 0bcae125b5 app: merge gimp_drawable_get_read_buffer() and get_write_buffer()
into get_buffer(). The loss of zero copy will be compensated soon.
2012-05-02 17:46:04 +02:00
Michael Natterer 4d18bda0c7 app: cache readable and writable buffers in the drawable
As API, replace gimp_drawable_create_buffer() by
gimp_drawable_get_read_buffer() and gimp_drawable_get_write_buffer().
2012-05-02 17:45:48 +02:00
Michael Natterer 5c8ded8960 app: let the drawable keep around a pointer to its floating selection
Instead of getting the floating selection from the image. Change
gimp_drawable_has_floating_sel() to get_floating_sel() and remove the
"floating_sel" parameter from gimp_drawable_deatch_floating_sel().
This cleanup is one more step towards sanitizing floating selections,
and makes the crash fix in the next commit much much simpler.
2011-09-23 19:31:50 +02:00
Michael Natterer 9f30550f9a app: move drawable->type to private 2011-03-16 02:02:47 +01:00
Michael Natterer 4897f4841c need to rip the floating selection's source node out of its layer's graph
2009-02-13  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable.c (gimp_drawable_sync_source_node): need
	to rip the floating selection's source node out of its layer's
	graph before using it in the floating selection sub-graph, and
	need to plug it back there when it's not a floating selection any
	longer.

	Unrelated:

	Also introduce a "fs_crop_node" that makes sure the floating
	selection stops at the drawable's boundaries.

	(gimp_drawable_visibility_changed): use item->node instead of
	gimp_item_get_node() because the latter creates the node on
	demand.

	* app/core/gimpdrawable-private.h: add fs_crop_node member.


svn path=/trunk/; revision=28022
2009-02-13 15:35:13 +00:00
Michael Natterer d2a716d37f app/core/gimpdrawable.h move the preview related members to the private
2009-02-05  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable.h
	* app/core/gimpdrawable-preview.c: move the preview related
	members to the private struct.

	* app/core/gimpdrawable.c
	* app/core/gimpdrawable-private.h
	* app/core/gimpselection.c: changed accordingly.


svn path=/trunk/; revision=27986
2009-02-05 20:27:09 +00:00
Michael Natterer a1fd84119c app/core/Makefile.am new file which contains struct GimpDrawablePrivate.
2009-02-04  Michael Natterer  <mitch@gimp.org>

	* app/core/Makefile.am
	* app/core/gimpdrawable-private.h: new file which contains struct
	GimpDrawablePrivate. Move some stuff from GimpDrawable here.

	* app/core/gimpdrawable.[ch]
	* app/core/gimpdrawable-shadow.c: changed accordingly.

	* app/text/gimptextlayer-xcf.c
	* app/xcf/xcf-load.c: include the private struct for these ugly
	corner cases.


svn path=/trunk/; revision=27982
2009-02-03 23:57:11 +00:00