mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 23:28:07 +02:00
Query the backend to see if we can repaint the solid pattern.
If we are dithering on the Xlib backend we can not simply repaint the surface used for a solid pattern and must recreate it from scratch. However, for ordinary XRender usage we do not want to have to pay that price - so query the backend to see if we can reuse the surface.
This commit is contained in:
parent
0df43251d4
commit
ce0b136a44
10 changed files with 48 additions and 18 deletions
|
|
@ -749,6 +749,7 @@ static const cairo_surface_backend_t cairo_analysis_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
_cairo_analysis_surface_has_show_text_glyphs,
|
||||
_cairo_analysis_surface_show_text_glyphs
|
||||
};
|
||||
|
|
@ -966,6 +967,7 @@ static const cairo_surface_backend_t cairo_null_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
NULL, /* has_show_text_glyphs */
|
||||
NULL /* show_text_glyphs */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -678,6 +678,7 @@ static const cairo_surface_backend_t cairo_meta_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
|
||||
_cairo_meta_surface_has_show_text_glyphs,
|
||||
_cairo_meta_surface_show_text_glyphs
|
||||
|
|
|
|||
|
|
@ -701,6 +701,7 @@ static const cairo_surface_backend_t cairo_paginated_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
_cairo_paginated_surface_has_show_text_glyphs,
|
||||
_cairo_paginated_surface_show_text_glyphs
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5335,6 +5335,7 @@ static const cairo_surface_backend_t cairo_pdf_surface_backend = {
|
|||
NULL, /* reset */
|
||||
_cairo_pdf_surface_fill_stroke,
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
_cairo_pdf_surface_has_show_text_glyphs,
|
||||
_cairo_pdf_surface_show_text_glyphs,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2452,6 +2452,7 @@ _cairo_script_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
|
||||
/* The alternate high-level text operation */
|
||||
_cairo_script_surface_has_show_text_glyphs,
|
||||
|
|
|
|||
|
|
@ -334,19 +334,19 @@ cairo_surface_t *
|
|||
_cairo_surface_create_solid_pattern_surface (cairo_surface_t *other,
|
||||
const cairo_solid_pattern_t *solid_pattern)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
if (other->backend->create_solid_pattern_surface != NULL) {
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (other->backend->create_solid_pattern_surface) {
|
||||
surface = other->backend->create_solid_pattern_surface (other, solid_pattern);
|
||||
surface = other->backend->create_solid_pattern_surface (other,
|
||||
solid_pattern);
|
||||
if (surface)
|
||||
return surface;
|
||||
}
|
||||
|
||||
surface = _cairo_surface_create_similar_solid (other,
|
||||
solid_pattern->content,
|
||||
1, 1,
|
||||
&solid_pattern->color);
|
||||
return surface;
|
||||
return _cairo_surface_create_similar_solid (other,
|
||||
solid_pattern->content,
|
||||
1, 1,
|
||||
&solid_pattern->color);
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
|
|
@ -354,17 +354,24 @@ _cairo_surface_repaint_solid_pattern_surface (cairo_surface_t *other,
|
|||
cairo_surface_t *solid_surface,
|
||||
const cairo_solid_pattern_t *solid_pattern)
|
||||
{
|
||||
if (other->backend->create_solid_pattern_surface)
|
||||
/* Solid pattern surface for this backend are not trivial to make.
|
||||
* Skip repainting.
|
||||
*
|
||||
* This does not work optimally with things like analysis surface that
|
||||
* are proxies. But returning UNSUPPORTED is *safe* as it only
|
||||
* disables some caching.
|
||||
*/
|
||||
/* Solid pattern surface for these backends are special and not trivial
|
||||
* to repaint. Skip repainting.
|
||||
*
|
||||
* This does not work optimally with things like analysis surface that
|
||||
* are proxies. But returning UNSUPPORTED is *safe* as it only
|
||||
* disables some caching.
|
||||
*/
|
||||
if (other->backend->create_solid_pattern_surface != NULL &&
|
||||
! other->backend->can_repaint_solid_pattern_surface (solid_surface,
|
||||
solid_pattern))
|
||||
{
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return _cairo_surface_paint (solid_surface, CAIRO_OPERATOR_SOURCE, &solid_pattern->base, NULL);
|
||||
return _cairo_surface_paint (solid_surface,
|
||||
CAIRO_OPERATOR_SOURCE,
|
||||
&solid_pattern->base,
|
||||
NULL);
|
||||
}
|
||||
|
||||
cairo_clip_mode_t
|
||||
|
|
|
|||
|
|
@ -1310,6 +1310,15 @@ _cairo_xlib_surface_create_solid_pattern_surface (void *abstrac
|
|||
return &surface->base;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_xlib_surface_can_repaint_solid_pattern_surface (void *abstract_surface,
|
||||
const cairo_solid_pattern_t *solid_pattern)
|
||||
{
|
||||
cairo_xlib_surface_t *other = abstract_surface;
|
||||
return CAIRO_SURFACE_RENDER_HAS_COMPOSITE (other);
|
||||
}
|
||||
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_xlib_surface_set_matrix (cairo_xlib_surface_t *surface,
|
||||
cairo_matrix_t *matrix,
|
||||
|
|
@ -2469,7 +2478,8 @@ static const cairo_surface_backend_t cairo_xlib_surface_backend = {
|
|||
_cairo_xlib_surface_is_similar,
|
||||
_cairo_xlib_surface_reset,
|
||||
NULL, /* fill_stroke */
|
||||
_cairo_xlib_surface_create_solid_pattern_surface
|
||||
_cairo_xlib_surface_create_solid_pattern_surface,
|
||||
_cairo_xlib_surface_can_repaint_solid_pattern_surface
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -822,6 +822,11 @@ struct _cairo_surface_backend {
|
|||
(void *surface,
|
||||
const cairo_solid_pattern_t *solid_pattern);
|
||||
|
||||
cairo_bool_t
|
||||
(*can_repaint_solid_pattern_surface)
|
||||
(void *surface,
|
||||
const cairo_solid_pattern_t *solid_pattern);
|
||||
|
||||
cairo_bool_t
|
||||
(*has_show_text_glyphs) (void *surface);
|
||||
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ static const cairo_surface_backend_t test_meta_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
_test_meta_surface_has_show_text_glyphs,
|
||||
_test_meta_surface_show_text_glyphs
|
||||
};
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ static const cairo_surface_backend_t test_paginated_surface_backend = {
|
|||
NULL, /* reset */
|
||||
NULL, /* fill_stroke */
|
||||
NULL, /* create_solid_pattern_surface */
|
||||
NULL, /* can_repaint_solid_pattern_surface */
|
||||
|
||||
_test_paginated_surface_has_show_text_glyphs,
|
||||
_test_paginated_surface_show_text_glyphs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue