The previous commit was not taking into account usages of gimp_cairo_surface_create_buffer(), other than the text layer rendering usage, as it was focused on fixing #14970. In particular, in other pieces of code, we were using a temporary GeglBuffer as a way to edit the original Cairo surface but the syncing back was not happening anymore. So previous commit was breaking all thumbnails of layers or images, as well as PDF export for all raster layers. After some thought, I decided to implement a new function gimp_cairo_surface_get_buffer() which would do what gimp_cairo_surface_create_buffer() was doing, but adding a boolean flag to declare whether or not we were expecting to sync back into the Cairo surface's data. After all, when we don't need to sync back, better avoid the useless work of copying possibly huge data. I also added back the possibility of returning a linear-memory backed buffer, after some discussion with pippin. Because for very small surfaces, and if we are indeed looking to sync back into the source Cairo surface, the advantages of using a linear buffer may still be worth it, even though it's not true for the general case (where tiled buffers will be much more efficient). I used 4096 (64^2 because our current tile dimensions are 64 right now in GIMP), though this number is kinda random and doesn't matter too much (it doesn't have to be the square of the tile's width or height). I don't put any info about this in the new function's documentation because developers should not have any expectations on the type of buffer they get (only whether or not it will sync back to the source). As a consequence of all this, gimp_cairo_surface_create_buffer() has been deprecated as of GIMP 3.2, though it will still work the same. The new function will be recommended as a replacement.
42 lines
1.6 KiB
C
42 lines
1.6 KiB
C
/* LIBGIMP - The GIMP Library
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
*
|
|
* This library is free software: you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see
|
|
* <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef __GIMP_COLOR_PRIVATE_H__
|
|
#define __GIMP_COLOR_PRIVATE_H__
|
|
|
|
#define GIMP_LINEAR_BUFFER_MAX_SIZE 4096
|
|
|
|
/* Legacy definition to calculate luminance from sRGB.
|
|
*
|
|
* These values and macro are specific to a "RGB float" to "Y float"
|
|
* conversion within sRGB space. These should not be used in new code,
|
|
* where converting to "Y float", space aware, may often be what you
|
|
* wanted to do.
|
|
* Once we got rid of all remaining usages in plug-ins and app, we can
|
|
* delete this file as it's not distributed.
|
|
*/
|
|
#define GIMP_RGB_LUMINANCE_RED (0.22248840)
|
|
#define GIMP_RGB_LUMINANCE_GREEN (0.71690369)
|
|
#define GIMP_RGB_LUMINANCE_BLUE (0.06060791)
|
|
|
|
#define GIMP_RGB_LUMINANCE(r,g,b) ((r) * GIMP_RGB_LUMINANCE_RED + \
|
|
(g) * GIMP_RGB_LUMINANCE_GREEN + \
|
|
(b) * GIMP_RGB_LUMINANCE_BLUE)
|
|
|
|
|
|
#endif /* __GIMP_COLOR_PRIVATE_H__ */
|