Commit Graph

203 Commits

Author SHA1 Message Date
Jehan f9c97aeb72 app: mask colors are GeglColor. 2024-02-11 23:28:03 +01:00
Jehan aab73ae3a4 app: fix a crash when converting to higher precision.
gimp_display_shell_render() writes to a GeglBuffer backed by allocated memory
(shell->profile_data). Unfortunately while converting prevision in
gimp_image_convert_precision(), we change the "precision" property (hence the
source format) first, hence end up trying to write data in a too small buffer.
This crash was hard to find as it was not showing up on my machine (though it
did produce rendering artifacts!), unless I built both GIMP and babl with
`b_sanitize=address`.

Note that an alternate fix was to make sure that the profile_data buffer is big
enough (by calling gimp_display_shell_profile_update() before rendering), but
anyway the image is in an inconsistent state while conversion is in progress:
whereas the `src_format` is the new one, the `src_profile` is still the old one
(and cannot be changed before we finish converting).

Moreover the render happen regularly on progress signals, once after each
converted drawable. So each of these rendering step happens in an inconsistent
state, with the wrong profile set, some of the drawables converted and others
not yet.
We could still render properly if each drawable's buffer used space-aware format
(thus allowing different drawables to use different profiles/spaces), but it
feels over-engineering the problem. It might be much better to ignore rendering
steps while converting the image precision. Moreover it would obviously make a
faster conversion.

See discussions in #9136 for this crash, which didn't have dedicated report
AFAIK.

(cherry picked from commit de25be9210)

Note: on the `master` branch, even with sanitized code, I don't get the crash.
Yet this change seems relevant enough that I'm adding it.
2023-02-19 18:46:31 +01:00
Ell d710e96d81 Issue #3781 - Display artifacts on HiDPI when render cache is invalidated
In GimpDisplayShell, scale the render cache by the window's scale
factor, and render its content in device pixels, instead of scaled
application pixels.  When painting the cache to the screen, unscale
the cairo context by the same factor, so that it's painted in the
native resolution.  Note that the various
gimp_display_shell_render_foo() functions still speak in
application pixels, and the scaling happens internally in
gimp_display_shell_render().

Aside from rendering at native resolution on HiDPI, this also fixes
an issue where grid-like display artifacts would appear when the
render cache was not fully validated due to the non-native scaling.
2019-09-11 21:19:26 +03:00
Ell 86dc451bce app, menus: add "show all" mode to GimpDisplayShell; "View -> Show All" toggle
Add a "show all" mode to GimpDisplayShell, controlled through a
corresponding "View -> Show All" menu item.  When enabled, the
entire image content is displayed, instead of cropping the image
to the canvas size.  More generally, the display behaves as if the
canvas were infinite.  The following commits improve the overall
behavior in this mode.

Add a prefernces option to control the default "show all" state.
2019-09-04 20:47:21 +03:00
Michael Natterer 2061cc0077 app: fix gimp_display_shell_render() to draw alpha correctly
Drawing the image needs to replace the render cache's alpha, so draw
with CAIRO_OPERATOR_SOURCE.
2019-07-16 23:16:27 +02:00
Øyvind Kolås 85cf3630c2 app: make use of display_config->zoom_quality
When set to FAST we do nearest neighbor from the next bigger mipmap
level instead of linear or box filtering - this gives a slight and
permanent boost to painting, and all updates, having one that combines
best of both worlds and reblits in high quality after a timeout would
be even more desirable.
2019-07-16 19:03:06 +02:00
Michael Natterer 9aa6aa1f04 app: make display update much faster again
Introduce a render cache that keeps the result of scaling, color
management, display filters and shell mask (for tools like fuzzy
select).

Change gimpdisplayshell-render.[ch] to only render to the cache and
manage a cairo region of the cache's valid area. Call cache
invalidation functions form various places. Change the API of all
render functions to be in display coordinates.

Also get rid of gimpdisplayxfer.[ch] because we now have a
canvas-sized cairo surface which is a surface similar to the
destination surface.
2019-07-16 17:15:34 +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 69d5201d59 app: fix formatting in previous commit 2018-03-28 00:44:33 +02:00
Øyvind Kolås a7b0d55fc5 app: only create GeglBuffer wrapper for cairo-data when used
As suggested by massimo in bug #694917, move unconditional creation/destruction
of a wrapper GeglBuffer object from top-level scope of the function to the
single conditional scope where it is used.
2018-03-28 00:37:06 +02:00
Jehan 21cb905dad Revert "app: use FAST filter when painting xfer surface"
This reverts commit 36258a671a.
This commit was making the rotated canvas rendering quite horrible to
the point that I think it would make the canvas rotation feature barely
usable. See bug 759287, comments 13 to 18.
I think we will need to find other ways to accelerate rendering.
Compromise on quality is possible, but I think that in this case, this
was more than just a compromise. It was more like completely abandonning
quality. We could even see the lines "spiking" while you were rotating!
Like your drawing was alive!
2018-01-10 03:52:54 +01:00
Ell 09e1c7f9b5 app: fix mask overlay position when zoom != 100%
... and the mask offset != (0, 0)

Thanks tmanni!
2017-12-31 11:57:22 -05:00
Ell 36258a671a app: use FAST filter when painting xfer surface
Use CAIRO_FILTER_FAST when painting the xfer surface to the
screen.  This notably improves performance when the canvas is
rotated, at the cost of lower filtering quality.
2017-12-09 10:41:16 -05:00
Ell 8029508fbe Bug 759287 - Canvas Tearing While in Rotated Canvas View
Based on a patch by Massimo.

Move the entire image-space/screen-space transformation logic from
gimp_display_shell_render() to gimp_display_shell_draw_image(), so
that the former works entirely in image space, and do the chunking
and clipping in screen-space, making sure that image-space chunks
are never larger than
GIMP_DISPLAY_RENDER_BUF_WIDTH x GIMP_DISPLAY_RENDER_BUF_HEIGHT,
even when the window's scale factor is greater than 1.

Add a GIMP_BRICK_WALL environment variable, which, when set, shows
the screen-space chunk bounds.
2017-12-09 05:01:30 -05:00
Ell 9cd8e7f9c6 app: apply display filters in sRGB, not monitor profile
When we have display filters, break the color profile transform in
two: first, convert from the image profile to sRGB, then apply the
filters, then convert from sRGB to the monitor profile.
2017-11-03 04:24:49 -04:00
Ell a5a2b56850 app: use actual render area when processing display filters
When processing display filters, shift the filter buffer to the
top-left corner of the render area, and pass the actual render
area, instead of an area whose top-left coords are (0, 0), to the
display filter.  This allows for position-dependent display
filters.
2017-11-02 16:12:33 -04:00
Ell 1c68617302 app: use {begin,end}_render() and GimpTileHandlerProjectable ...
... in GimpProjection and gimp_display_shell_render() (the latter
is not really necessary, but whatever.)
2017-08-08 15:39:27 -04:00
Michael Natterer e33b2e77a7 app: remove gimp_display_shell_profile_convert_buffer()
It's exactly the same as calling gimp_color_transform_process_buffer()
directly.
2016-05-30 01:26:50 +02:00
Michael Natterer cc92887908 libgimpcolor: add new object GimpColorTransform
which encapsulates a cmsHTRANSFORM and does all the pixel format
conversion magic. It has API to create transforms and proofing
transforms, and to convert pixels arrays and GeglBuffers.

Before, each place which has a transform had to keep around the
transform and its input and output Babl formats, and had to implement
lots of stuff itself. Now all that lives in GimpColorTransform,
removing lots of logic from many places, and pretty much removing lcms
from the public API entirely.

This removes including <lcms2.h>, LCMS_LIBS and LCMS_CFLAGS from
almost all directories and potentially allows to replace lcms by
something else.
2016-05-26 22:15:54 +02:00
Michael Natterer 46da951b85 app: add an offset to GimpDisplayShell's mask
and set that offset in GimpRegionSelectTool when not in sample_merged
mode. Fixes live selection mask display for layers with a non-zero
offset.
2016-02-05 21:21:52 +01:00
Michael Natterer c876e281b1 Bug 750874 - Displayed colors look clipped after profile conversion...
but they aren't clipped

Add gimp_display_shell_profile_can_convert_to_u8() which returns
whether the lcms transform can safely write directly into an u8 buffer
without destroying out-of-gammut pixel values, which we assume is the
case for all integer formats. If the function returns FALSE, always
convert via the R'G'B'A float filter_buffer.

Also connect to the image's "precision-changed" signal and update the
profile transform when it's emitted.
2015-06-13 00:27:21 +02:00
Michael Natterer 460948e068 app: add member GimpDisplayShell.filter_format
and use it where we used to hardcode "R'G'B'A float".
2015-06-02 00:01:28 +02:00
Michael Natterer 08545ad549 app: switch gimpdisplayshell-render.c to the new profile filter code
- disable auto-adding of the lcms display filter module

- change profile convert dest formats to be always R'G'B'A, a display
  profile transform outputs something that can be displayed directly,
  so no additional gamma transform must happen when the pixels are
  copied to a cairo-ARGB32 buffer

- add a medium forest of if() branches to gimpdisplayshell-filter.c
  which cover all combinations of profile and display filter
  transforms

- all of this is still very broken when changing an image to linear,
  because the configured RGB profile from prefs will do horrible
  nonsense (things work fine though with a per-image profile that is
  for linear data)
2015-06-01 23:30:03 +02:00
Michael Natterer 52032961c2 app: add (disabled) code that blits the image directly from the graph
bypassing the projection buffer.
2014-07-03 20:52:02 +02:00
Michael Natterer 2ac5ab7dc3 app: don't use the projection in gimpdisplayshell-render.c
The image implements the GimpPickable interface too.
2014-06-29 23:11:53 +02:00
Michael Natterer 21a8f9c96b app: add boolean "mask_inverted" to GimpDisplayShell
and to gimp_display_shell_set_mask(). It allows to choose whether the
mask is drawn inverted, instead of always drawing it inverted.
2014-06-11 21:33:57 +02:00
Michael Natterer 051a3e4af4 Bug 681968 - Disabling 'Dot for Dot' glitches display
Enhance the existing but unused display scaling (hidpi/retina) support
to work independently in x and y direction, and adjust the scaling
factors accordingly when dot-for-dot is off and xres != yres.

Increase GIMP_DISPLAY_RENDER_MAX_SCALE from 2.0 to 4.0 and adjust the
rendering chunk size dynamically so we never render chunks that do
not fit into the GimpDisplayXfer buffers.
2014-04-20 22:01:57 +02:00
Daniel Sabo 2381bf87c7 app: Use ABYSS_CLAMP for display_shell_render() (bug 709708) 2014-03-14 13:21:47 -07:00
Michael Natterer 57d291e130 app: cache the GeglBuffer used for display filters in GimpDisplayShell
so it is not created and destroyed all the time.
2013-11-02 20:56:25 +01:00
Michael Natterer c7051b4caa app: variable renaming in gimpdisplayshell-render.c for better readability 2013-11-02 03:11:44 +01:00
Michael Natterer c3ae7d587d app: port gimp_display_shell_render() to GimpColorDisplay::convert_buffer()
which means applying a series of nops until the display filters are
ported.
2013-11-02 00:48:02 +01:00
Michael Natterer 5b39be5605 Bug 679195 - Foreground Select Tool Mask Inverted
gimp_display_shell_render(): invert the mask so it masks what is *not*
the foreground object.
2013-07-15 01:57:00 +02:00
Michael Natterer 31e9cc2ad9 Bug 702369 - foreground selection doesnt work with image precision >8 bit
This removes the obsolete check which makes the tool fail from
gimp_display_shell_set_mask(). Also change the foreground select tool
and the display mask from using GimpChannel to GeglBuffer, because
that's what it needs, simply buffers. Most changed files simply newly
include <gegl.h> because a GeglBuffer appeared in two headers.
2013-06-22 22:26:46 +02:00
Michael Natterer c7879266d4 app: fix GimpDisplayShell mask drawing, again 2013-04-29 23:15:37 +02:00
Michael Natterer 915b0f3eec app: re-enable and port the display shell mask rendering code
for the ported foreground select tool. Untested!
2013-04-26 10:33:10 +02:00
Michael Natterer ee2e5fb517 app: fix image rendering atifacts in rotated views
- stroke around the drawn area to work around the impossibility of
  tiling antialiased stuff.
- don't use the display xfer stuff because if we overdraw we must
  not have anything in the source pattern outside the drawn region
2013-04-21 02:10:36 +02:00
Michael Natterer b8e96c7141 app: rename gimpdisplay-transport.[ch] to gimpdisplayxfer.[ch]
so it matches the name of the stuff it implements.
2013-02-03 13:26:32 +01:00
Michael Natterer d0a5879f28 app: some GIMP-style cleanup to the last commit 2013-02-02 17:07:03 +01:00
Chris Wilson 4a81849e36 app: Use SHM transport for data transfer for display
Recent Cairo uses SHM transports when available, and exposes the ability
for its users to manage images shared between it and the display.
This allows us to eliminate copies, and if the architecture supports it
even to upload directly into GPU addressable memory without any copies
(all in normal system memory so we suffer no performance penalty when
applying the filters). The caveat is that we need to be aware of the
synchronize requirements, the cairo_surface_flush and
cairo_surface_mark_dirty, around access to the transport image. To
reduce the frequency of these barriers, we can subdivide the transport
image into small chunks as to satisfy individual updates and delay the
synchronisation barrier until we are forced to reuse earlier pixels.

Note this bumps the required Cairo version to 1.12, and please be aware
that the XSHM transport requires bug fixes from cairo.git (will be
1.12.12)

v2: After further reflections with Mitch, we realized we can share the
transport surface between all canvases by attaching it to the common
screen.

v3: Fix a couple of typos in insert_node() introduced when switching
variables names.

v4: Encapsulating within an image surface rather than a subsurface was
hiding the backing SHM segment from cairo, causing it to allocate
further SHM resources to stream the upload. We should be able to use a
sub-surface here, but it is more convenient to wrap the pixels in an
image surface for rendering the filters (and conveniently masking the
callee flushes from invalidating our parent transport surface).

Cc: Michael Natterer <mitch@gimp.org>
2013-02-02 13:59:59 +01:00
Michael Natterer 2491a3a088 app: add (disabled) support for rendering the image at high resolution
for what Apple calls "Retina". Disabled because the GDK API to figure
the scale factor doesn't exist yet.
2013-01-18 16:36:22 +01:00
Michael Natterer 6b6d39fc64 app: add GimpTileHandlerProjection and use it to validate the projection
as the projection buffer is being read from. Projection performance is
now back at its old speed.
2012-07-05 21:42:26 +02: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
Massimo Valentini 1338bba7db Bug 645345: 'Color Management' display filter causes performance problems 2012-06-09 15:36:53 +02:00
Michael Natterer 010418d874 app: remove gimp_drawable_get_tiles() 2012-05-06 04:39:23 +02:00
Michael Natterer 37c895ba68 app: have the display renderer ask for the projection's format not image_type 2012-05-02 17:50:40 +02:00
Mukund Sivaraman e79f90d3b6 app: Fix assignment (may be confused as compound assignment) 2011-10-02 19:15:08 +05:30
Massimo Valentini 8b8e67ffe2 Bug 656129: Warnings: render_image_tile_fault: assertion `tile[4]... 2011-09-08 18:37:28 +02:00
Massimo Valentini 3efa2062c5 Bug 650426 - Missing call to cairo_surface_flush
app: before drawing directly on the surface.
2011-05-18 08:41:10 +02:00
Michael Natterer cc47b2a600 libgimpwidgets/color: move the cairo color utility functions to libgimpcolor
Add CAIRO_CFLAGS to a lot of Makefiles to make this possible, and
because they pull in cairo via the libgimp headers.
2011-04-28 15:50:39 +02:00
Omari Stephens 5cae0bf65c Bug 630748 - display filters do not work
Create and use Cairo-compatible API for display filters. Also
includes logic changes to the display filters to deal with cairo's
ARGB32 pre-multiplied buffer format.
2011-01-25 20:24:42 +01:00