mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-07 20:18:02 +02:00
[cairo-gstate] Avoid copying untransformed glyphs.
Skip the memory duplication of the incoming glyphs if we do not need to transform them into the backend coordinate system. As a consequence we need to constify the glyphs passed to the backend functions.
This commit is contained in:
parent
62377cbac1
commit
919bea6dbb
21 changed files with 68 additions and 47 deletions
|
|
@ -393,7 +393,7 @@ static cairo_int_status_t
|
|||
_cairo_analysis_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1451,7 +1451,7 @@ static cairo_int_status_t
|
|||
_cairo_directfb_surface_show_glyphs ( void *abstract_dst,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *pattern,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2086,7 +2086,7 @@ _cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
int dst_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs)
|
||||
{
|
||||
cairo_glitz_surface_attributes_t attributes;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ _cairo_gstate_transform_glyphs_to_backend (cairo_gstate_t *gstate,
|
|||
int num_glyphs,
|
||||
cairo_glyph_t *transformed_glyphs);
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_gstate_transform_glyphs_to_backend_required (cairo_gstate_t *gstate);
|
||||
|
||||
cairo_status_t
|
||||
_cairo_gstate_init (cairo_gstate_t *gstate,
|
||||
cairo_surface_t *target)
|
||||
|
|
@ -1567,16 +1570,19 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
|
|||
if (status)
|
||||
return status;
|
||||
|
||||
if (num_glyphs <= STACK_GLYPHS_LEN) {
|
||||
transformed_glyphs = stack_transformed_glyphs;
|
||||
} else {
|
||||
transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
|
||||
if (transformed_glyphs == NULL)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
if (_cairo_gstate_transform_glyphs_to_backend_required (gstate)) {
|
||||
if (num_glyphs <= STACK_GLYPHS_LEN) {
|
||||
transformed_glyphs = stack_transformed_glyphs;
|
||||
} else {
|
||||
transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
|
||||
if (transformed_glyphs == NULL)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
_cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
|
||||
transformed_glyphs);
|
||||
_cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
|
||||
transformed_glyphs);
|
||||
} else
|
||||
transformed_glyphs = (cairo_glyph_t *) glyphs;
|
||||
|
||||
status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
|
||||
if (status)
|
||||
|
|
@ -1592,7 +1598,8 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
|
|||
_cairo_pattern_fini (&source_pattern.base);
|
||||
|
||||
CLEANUP_GLYPHS:
|
||||
if (transformed_glyphs != stack_transformed_glyphs)
|
||||
if (transformed_glyphs != stack_transformed_glyphs &&
|
||||
transformed_glyphs != glyphs)
|
||||
free (transformed_glyphs);
|
||||
|
||||
return status;
|
||||
|
|
@ -1648,6 +1655,20 @@ _cairo_gstate_get_antialias (cairo_gstate_t *gstate)
|
|||
return gstate->antialias;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_gstate_transform_glyphs_to_backend_required (cairo_gstate_t *gstate)
|
||||
{
|
||||
cairo_matrix_t *ctm = &gstate->ctm;
|
||||
cairo_matrix_t *device_transform = &gstate->target->device_transform;
|
||||
|
||||
if (_cairo_matrix_is_identity (ctm) &&
|
||||
_cairo_matrix_is_identity (device_transform) &&
|
||||
gstate->font_matrix.x0 == 0 && gstate->font_matrix.y0 == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* _cairo_gstate_transform_glyphs_to_backend:
|
||||
* @gstate: a #cairo_gstate_t
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ static cairo_int_status_t
|
|||
_cairo_meta_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ static cairo_int_status_t
|
|||
_cairo_paginated_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3880,7 +3880,7 @@ static cairo_int_status_t
|
|||
_cairo_pdf_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2230,7 +2230,7 @@ static cairo_int_status_t
|
|||
_cairo_ps_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1315,7 +1315,7 @@ static cairo_int_status_t
|
|||
_cairo_quartz_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1140,7 +1140,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ cairo_private cairo_status_t
|
|||
_cairo_surface_fallback_show_glyphs (cairo_surface_t *surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
|
|
|
|||
|
|
@ -915,7 +915,7 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface,
|
|||
|
||||
typedef struct {
|
||||
cairo_scaled_font_t *font;
|
||||
cairo_glyph_t *glyphs;
|
||||
const cairo_glyph_t *glyphs;
|
||||
int num_glyphs;
|
||||
} cairo_show_glyphs_info_t;
|
||||
|
||||
|
|
@ -984,7 +984,7 @@ cairo_status_t
|
|||
_cairo_surface_fallback_show_glyphs (cairo_surface_t *surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1901,7 +1901,7 @@ cairo_status_t
|
|||
_cairo_surface_show_glyphs (cairo_surface_t *surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
@ -1986,7 +1986,7 @@ _cairo_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
|
|
|||
|
|
@ -1954,7 +1954,7 @@ static cairo_int_status_t
|
|||
_cairo_svg_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *pattern,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1170,7 +1170,7 @@ _cairo_win32_scaled_font_show_glyphs (void *abstract_font,
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs)
|
||||
{
|
||||
cairo_win32_scaled_font_t *scaled_font = abstract_font;
|
||||
|
|
|
|||
|
|
@ -1497,7 +1497,7 @@ static cairo_int_status_t
|
|||
_cairo_win32_surface_show_glyphs (void *surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1620,11 +1620,11 @@ _cairo_xcb_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
|
|||
|
||||
static cairo_int_status_t
|
||||
_cairo_xcb_surface_show_glyphs (void *abstract_dst,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *src_pattern,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *src_pattern,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_xcb_surface_is_similar (void *surface_a,
|
||||
|
|
@ -2307,11 +2307,11 @@ typedef cairo_status_t (*cairo_xcb_surface_show_glyphs_func_t)
|
|||
|
||||
static cairo_int_status_t
|
||||
_cairo_xcb_surface_show_glyphs (void *abstract_dst,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *src_pattern,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *src_pattern,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
cairo_xcb_surface_t *dst = abstract_dst;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ static cairo_int_status_t
|
|||
_cairo_xlib_surface_show_glyphs (void *abstract_dst,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *src_pattern,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
|
|
@ -2984,7 +2984,7 @@ static cairo_int_status_t
|
|||
_cairo_xlib_surface_show_glyphs (void *abstract_dst,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *src_pattern,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ struct _cairo_scaled_font_backend {
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs);
|
||||
|
||||
cairo_warn cairo_int_status_t
|
||||
|
|
@ -798,7 +798,7 @@ struct _cairo_surface_backend {
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs);
|
||||
|
||||
void
|
||||
|
|
@ -860,7 +860,7 @@ struct _cairo_surface_backend {
|
|||
(*show_glyphs) (void *surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
|
|
@ -1638,7 +1638,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
|
|
@ -1810,7 +1810,7 @@ cairo_private cairo_status_t
|
|||
_cairo_surface_show_glyphs (cairo_surface_t *surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
|
|
@ -1917,7 +1917,7 @@ _cairo_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
int dest_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ static cairo_int_status_t
|
|||
_test_meta_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ static cairo_int_status_t
|
|||
_test_paginated_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
const cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue