app: add gimp_cairo_image_surface_create_buffer()
and use it to shrink text layer rendering to even fewer lines.
This commit is contained in:
@ -135,10 +135,12 @@ workaround_that_file_depends_on_plug_in = \
|
||||
# core, vectors and gegl are on the same architectural layer, prevent
|
||||
# the linker from panicing
|
||||
calm_down_linker = \
|
||||
-u $(SYMPREFIX)gimp_vectors_undo_get_type \
|
||||
-u $(SYMPREFIX)gimp_vectors_mod_undo_get_type \
|
||||
-u $(SYMPREFIX)gimp_vectors_prop_undo_get_type \
|
||||
-u $(SYMPREFIX)gimp_curve_map_pixels
|
||||
-u $(SYMPREFIX)gimp_vectors_undo_get_type \
|
||||
-u $(SYMPREFIX)gimp_vectors_mod_undo_get_type \
|
||||
-u $(SYMPREFIX)gimp_vectors_prop_undo_get_type \
|
||||
-u $(SYMPREFIX)gimp_curve_map_pixels \
|
||||
-u $(SYMPREFIX)gimp_cairo_image_surface_create_buffer \
|
||||
-u $(SYMPREFIX)gimp_param_spec_duplicate
|
||||
|
||||
AM_LDFLAGS = \
|
||||
$(munix) \
|
||||
@ -147,8 +149,7 @@ AM_LDFLAGS = \
|
||||
$(workaround_that_core_depends_on_xcf) \
|
||||
$(workaround_that_core_depends_on_pdb) \
|
||||
$(workaround_that_plug_in_depends_on_pdb) \
|
||||
$(workaround_that_file_depends_on_plug_in) \
|
||||
-u $(SYMPREFIX)gimp_param_spec_duplicate
|
||||
$(workaround_that_file_depends_on_plug_in)
|
||||
|
||||
gimpconsoleldadd = \
|
||||
xcf/libappxcf.a \
|
||||
|
@ -36,6 +36,34 @@
|
||||
static cairo_user_data_key_t surface_data_key = { 0, };
|
||||
|
||||
|
||||
GeglBuffer *
|
||||
gimp_cairo_image_surface_create_buffer (cairo_surface_t *surface)
|
||||
{
|
||||
const Babl *format;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
g_return_val_if_fail (cairo_surface_get_type (surface) ==
|
||||
CAIRO_SURFACE_TYPE_IMAGE, NULL);
|
||||
|
||||
width = cairo_image_surface_get_width (surface);
|
||||
height = cairo_image_surface_get_height (surface);
|
||||
|
||||
if (cairo_surface_get_content (surface) == CAIRO_CONTENT_COLOR_ALPHA)
|
||||
format = babl_format ("cairo-ARGB32");
|
||||
else
|
||||
format = babl_format ("cairo-RGB24");
|
||||
|
||||
return
|
||||
gegl_buffer_linear_new_from_data (cairo_image_surface_get_data (surface),
|
||||
format,
|
||||
GEGL_RECTANGLE (0, 0, width, height),
|
||||
cairo_image_surface_get_stride (surface),
|
||||
(GDestroyNotify) cairo_surface_destroy,
|
||||
cairo_surface_reference (surface));
|
||||
}
|
||||
|
||||
cairo_pattern_t *
|
||||
gimp_cairo_stipple_pattern_create (const GimpRGB *fg,
|
||||
const GimpRGB *bg,
|
||||
|
@ -25,19 +25,21 @@
|
||||
#define __GIMP_CAIRO_H__
|
||||
|
||||
|
||||
cairo_pattern_t * gimp_cairo_stipple_pattern_create (const GimpRGB *fg,
|
||||
const GimpRGB *bg,
|
||||
gint index);
|
||||
GeglBuffer * gimp_cairo_image_surface_create_buffer (cairo_surface_t *surface);
|
||||
|
||||
void gimp_cairo_add_arc (cairo_t *cr,
|
||||
gdouble center_x,
|
||||
gdouble center_y,
|
||||
gdouble radius,
|
||||
gdouble start_angle,
|
||||
gdouble slice_angle);
|
||||
void gimp_cairo_add_segments (cairo_t *cr,
|
||||
GimpSegment *segs,
|
||||
gint n_segs);
|
||||
cairo_pattern_t * gimp_cairo_stipple_pattern_create (const GimpRGB *fg,
|
||||
const GimpRGB *bg,
|
||||
gint index);
|
||||
|
||||
void gimp_cairo_add_arc (cairo_t *cr,
|
||||
gdouble center_x,
|
||||
gdouble center_y,
|
||||
gdouble radius,
|
||||
gdouble start_angle,
|
||||
gdouble slice_angle);
|
||||
void gimp_cairo_add_segments (cairo_t *cr,
|
||||
GimpSegment *segs,
|
||||
gint n_segs);
|
||||
|
||||
|
||||
#endif /* __GIMP_CAIRO_H__ */
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimp-cairo.h"
|
||||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
@ -670,18 +671,13 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
|
||||
buffer =
|
||||
gegl_buffer_linear_new_from_data (cairo_image_surface_get_data (surface),
|
||||
babl_format ("cairo-ARGB32"),
|
||||
GEGL_RECTANGLE (0, 0, width, height),
|
||||
cairo_image_surface_get_stride (surface),
|
||||
(GDestroyNotify) cairo_surface_destroy,
|
||||
surface);
|
||||
buffer = gimp_cairo_image_surface_create_buffer (surface);
|
||||
|
||||
gegl_buffer_copy (buffer, NULL,
|
||||
gimp_drawable_get_buffer (drawable), NULL);
|
||||
|
||||
g_object_unref (buffer);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
gimp_drawable_update (drawable, 0, 0, width, height);
|
||||
}
|
||||
|
Reference in New Issue
Block a user