spans+image: Fix clipping with polygons and spans
Fixes: clip-source, random-clip Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
@ -195,6 +195,7 @@ cairo_sources = \
|
|||
cairo-region.c \
|
||||
cairo-rtree.c \
|
||||
cairo-scaled-font.c \
|
||||
cairo-shape-mask-compositor.c \
|
||||
cairo-slope.c \
|
||||
cairo-spans.c \
|
||||
cairo-spans-compositor.c \
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ _cairo_clip_copy (const cairo_clip_t *clip);
|
|||
cairo_private cairo_clip_t *
|
||||
_cairo_clip_copy_region (const cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_clip_t *
|
||||
_cairo_clip_copy_path (const cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_clip_t *
|
||||
_cairo_clip_translate (cairo_clip_t *clip, int tx, int ty);
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,24 @@ _cairo_clip_copy (const cairo_clip_t *clip)
|
|||
return copy;
|
||||
}
|
||||
|
||||
cairo_clip_t *
|
||||
_cairo_clip_copy_path (const cairo_clip_t *clip)
|
||||
{
|
||||
cairo_clip_t *copy;
|
||||
|
||||
if (clip == NULL || _cairo_clip_is_all_clipped (clip))
|
||||
return (cairo_clip_t *) clip;
|
||||
|
||||
assert (clip->num_boxes);
|
||||
|
||||
copy = _cairo_clip_create ();
|
||||
copy->extents = clip->extents;
|
||||
if (clip->path)
|
||||
copy->path = _cairo_clip_path_reference (clip->path);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
cairo_clip_t *
|
||||
_cairo_clip_copy_region (const cairo_clip_t *clip)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -300,6 +300,10 @@ cairo_private void
|
|||
_cairo_mask_compositor_init (cairo_mask_compositor_t *compositor,
|
||||
const cairo_compositor_t *delegate);
|
||||
|
||||
cairo_private void
|
||||
_cairo_shape_mask_compositor_init (cairo_compositor_t *compositor,
|
||||
const cairo_compositor_t *delegate);
|
||||
|
||||
cairo_private void
|
||||
_cairo_traps_compositor_init (cairo_traps_compositor_t *compositor,
|
||||
const cairo_compositor_t *delegate);
|
||||
|
|
|
|||
|
|
@ -1597,27 +1597,31 @@ span_renderer_fini (cairo_abstract_span_renderer_t *_r,
|
|||
const cairo_compositor_t *
|
||||
_cairo_image_spans_compositor_get (void)
|
||||
{
|
||||
static cairo_spans_compositor_t compositor;
|
||||
static cairo_spans_compositor_t spans;
|
||||
static cairo_compositor_t shape;
|
||||
|
||||
if (compositor.base.delegate == NULL) {
|
||||
_cairo_spans_compositor_init (&compositor,
|
||||
_cairo_image_traps_compositor_get());
|
||||
if (spans.base.delegate == NULL) {
|
||||
_cairo_shape_mask_compositor_init (&shape,
|
||||
_cairo_image_traps_compositor_get());
|
||||
shape.glyphs = NULL;
|
||||
|
||||
compositor.flags = 0;
|
||||
_cairo_spans_compositor_init (&spans, &shape);
|
||||
|
||||
spans.flags = 0;
|
||||
#if PIXMAN_HAS_OP_LERP
|
||||
compositor.flags |= CAIRO_SPANS_COMPOSITOR_HAS_LERP;
|
||||
spans.flags |= CAIRO_SPANS_COMPOSITOR_HAS_LERP;
|
||||
#endif
|
||||
|
||||
//compositor.acquire = acquire;
|
||||
//compositor.release = release;
|
||||
compositor.fill_boxes = fill_boxes;
|
||||
compositor.pattern_to_surface = _cairo_image_source_create_for_pattern;
|
||||
//compositor.check_composite_boxes = check_composite_boxes;
|
||||
compositor.composite_boxes = composite_boxes;
|
||||
//compositor.check_span_renderer = check_span_renderer;
|
||||
compositor.renderer_init = span_renderer_init;
|
||||
compositor.renderer_fini = span_renderer_fini;
|
||||
//spans.acquire = acquire;
|
||||
//spans.release = release;
|
||||
spans.fill_boxes = fill_boxes;
|
||||
spans.pattern_to_surface = _cairo_image_source_create_for_pattern;
|
||||
//spans.check_composite_boxes = check_composite_boxes;
|
||||
spans.composite_boxes = composite_boxes;
|
||||
//spans.check_span_renderer = check_span_renderer;
|
||||
spans.renderer_init = span_renderer_init;
|
||||
spans.renderer_fini = span_renderer_fini;
|
||||
}
|
||||
|
||||
return &compositor.base;
|
||||
return &spans.base;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,131 +0,0 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2003 University of Southern California
|
||||
* Copyright © 2009,2010,2011 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is University of Southern
|
||||
* California.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Carl D. Worth <cworth@cworth.org>
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-compositor-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
#include "cairo-spans-compositor-private.h"
|
||||
|
||||
typedef struct _cairo_image_span_renderer {
|
||||
cairo_span_renderer_t base;
|
||||
|
||||
pixman_image_compositor_t *compositor;
|
||||
pixman_image_t *src;
|
||||
float opacity;
|
||||
cairo_rectangle_int_t extents;
|
||||
} cairo_image_span_renderer_t;
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_image_span_renderer_init (cairo_abstract_span_renderer_t *_r,
|
||||
cairo_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
cairo_surface_t *src,
|
||||
int src_x, int src_y;
|
||||
float opacity,
|
||||
const cairo_composite_rectangles_t *composite,
|
||||
cairo_bool_t needs_clip)
|
||||
{
|
||||
cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *)_r;
|
||||
cairo_pixman_source_t *src = (cairo_pixman_source_t *)_src;
|
||||
int src_x, src_y;
|
||||
|
||||
if (op == CAIRO_OPERATOR_CLEAR) {
|
||||
op = CAIRO_OPERATOR_DEST_OUT;
|
||||
pattern = NULL;
|
||||
}
|
||||
|
||||
r->src = ((cairo_pixman_source_t *) src)->pixman_image;
|
||||
r->opacity = opacity;
|
||||
|
||||
if (composite->is_bounded) {
|
||||
if (opacity == 1.)
|
||||
r->base.render_rows = _cairo_image_bounded_opaque_spans;
|
||||
else
|
||||
r->base.render_rows = _cairo_image_bounded_spans;
|
||||
r->base.finish = NULL;
|
||||
} else {
|
||||
if (needs_clip)
|
||||
r->base.render_rows = _cairo_image_clipped_spans;
|
||||
else
|
||||
r->base.render_rows = _cairo_image_unbounded_spans;
|
||||
r->base.finish = _cairo_image_finish_unbounded_spans;
|
||||
r->extents = composite->unbounded;
|
||||
r->extents.height += r->extents.y;
|
||||
|
||||
}
|
||||
r->compositor =
|
||||
pixman_image_create_compositor (_pixman_operator (op),
|
||||
r->src, NULL, dst->pixman_image,
|
||||
composite->bounded.x + src_x,
|
||||
composite->bounded.y + src_y,
|
||||
0, 0,
|
||||
composite->bounded.x,
|
||||
composite->bounded.y,
|
||||
composite->bounded.width,
|
||||
composite->bounded.height);
|
||||
if (unlikely (r->compositor == NULL))
|
||||
return CAIRO_INT_STATUS_NOTHING_TO_DO;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_image_span_renderer_fini (cairo_abstract_span_renderer_t *_r)
|
||||
{
|
||||
cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *) r;
|
||||
pixman_image_compositor_destroy (r->compositor);
|
||||
}
|
||||
|
||||
const cairo_compositor_t *
|
||||
_cairo_image_spans_compositor_get (void)
|
||||
{
|
||||
static cairo_spans_compositor_t compositor;
|
||||
|
||||
if (compositor.base.delegate == NULL) {
|
||||
/* Can't fallback to the mask compositor as that will simply
|
||||
* call the spans-compositor again to render the mask!
|
||||
*/
|
||||
_cairo_spans_compositor_init (&compositor,
|
||||
_cairo_image_traps_compositor_get());
|
||||
|
||||
}
|
||||
|
||||
return &compositor.base;
|
||||
}
|
||||
337
src/cairo-shape-mask-compositor.c
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2012 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is University of Southern
|
||||
* California.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-compositor-private.h"
|
||||
#include "cairo-clip-private.h"
|
||||
#include "cairo-pattern-private.h"
|
||||
#include "cairo-surface-private.h"
|
||||
#include "cairo-surface-offset-private.h"
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_shape_mask_compositor_stroke (const cairo_compositor_t *_compositor,
|
||||
cairo_composite_rectangles_t *extents,
|
||||
const cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias)
|
||||
{
|
||||
cairo_surface_t *mask;
|
||||
cairo_surface_pattern_t pattern;
|
||||
cairo_int_status_t status;
|
||||
cairo_clip_t *clip;
|
||||
|
||||
if (! extents->is_bounded)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
TRACE ((stderr, "%s\n", __FUNCTION__));
|
||||
mask = _cairo_surface_create_similar_scratch (extents->surface,
|
||||
CAIRO_CONTENT_ALPHA,
|
||||
extents->bounded.width,
|
||||
extents->bounded.height);
|
||||
if (unlikely (mask->status))
|
||||
return mask->status;
|
||||
|
||||
clip = extents->clip;
|
||||
if (! _cairo_clip_is_region (clip))
|
||||
clip = _cairo_clip_copy_region (clip);
|
||||
|
||||
if (! mask->is_clear) {
|
||||
status = _cairo_surface_offset_paint (mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
CAIRO_OPERATOR_CLEAR,
|
||||
&_cairo_pattern_clear.base,
|
||||
clip);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = _cairo_surface_offset_stroke (mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
&_cairo_pattern_white.base,
|
||||
path, style, ctm, ctm_inverse,
|
||||
tolerance, antialias,
|
||||
clip);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
|
||||
if (clip != extents->clip) {
|
||||
status = _cairo_clip_combine_with_surface (extents->clip, mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
_cairo_pattern_init_for_surface (&pattern, mask);
|
||||
cairo_matrix_init_translate (&pattern.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
pattern.base.filter = CAIRO_FILTER_NEAREST;
|
||||
pattern.base.extend = CAIRO_EXTEND_NONE;
|
||||
if (extents->op == CAIRO_OPERATOR_SOURCE) {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
CAIRO_OPERATOR_DEST_OUT,
|
||||
&_cairo_pattern_white.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
if ((status == CAIRO_INT_STATUS_SUCCESS)) {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
&extents->source_pattern.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
}
|
||||
} else {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
extents->op,
|
||||
&extents->source_pattern.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
}
|
||||
_cairo_pattern_fini (&pattern.base);
|
||||
|
||||
error:
|
||||
cairo_surface_destroy (mask);
|
||||
if (clip != extents->clip)
|
||||
_cairo_clip_destroy (clip);
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_shape_mask_compositor_fill (const cairo_compositor_t *_compositor,
|
||||
cairo_composite_rectangles_t *extents,
|
||||
const cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias)
|
||||
{
|
||||
cairo_surface_t *mask;
|
||||
cairo_surface_pattern_t pattern;
|
||||
cairo_int_status_t status;
|
||||
cairo_clip_t *clip;
|
||||
|
||||
TRACE ((stderr, "%s\n", __FUNCTION__));
|
||||
|
||||
if (! extents->is_bounded)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
mask = _cairo_surface_create_similar_scratch (extents->surface,
|
||||
CAIRO_CONTENT_ALPHA,
|
||||
extents->bounded.width,
|
||||
extents->bounded.height);
|
||||
if (unlikely (mask->status))
|
||||
return mask->status;
|
||||
|
||||
clip = extents->clip;
|
||||
if (! _cairo_clip_is_region (clip))
|
||||
clip = _cairo_clip_copy_region (clip);
|
||||
|
||||
if (! mask->is_clear) {
|
||||
status = _cairo_surface_offset_paint (mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
CAIRO_OPERATOR_CLEAR,
|
||||
&_cairo_pattern_clear.base,
|
||||
clip);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = _cairo_surface_offset_fill (mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
&_cairo_pattern_white.base,
|
||||
path, fill_rule, tolerance, antialias,
|
||||
clip);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
|
||||
if (clip != extents->clip) {
|
||||
status = _cairo_clip_combine_with_surface (extents->clip, mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
_cairo_pattern_init_for_surface (&pattern, mask);
|
||||
cairo_matrix_init_translate (&pattern.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
pattern.base.filter = CAIRO_FILTER_NEAREST;
|
||||
pattern.base.extend = CAIRO_EXTEND_NONE;
|
||||
if (extents->op == CAIRO_OPERATOR_SOURCE) {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
CAIRO_OPERATOR_DEST_OUT,
|
||||
&_cairo_pattern_white.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
if ((status == CAIRO_INT_STATUS_SUCCESS)) {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
&extents->source_pattern.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
}
|
||||
} else {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
extents->op,
|
||||
&extents->source_pattern.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
}
|
||||
_cairo_pattern_fini (&pattern.base);
|
||||
|
||||
error:
|
||||
if (clip != extents->clip)
|
||||
_cairo_clip_destroy (clip);
|
||||
cairo_surface_destroy (mask);
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_shape_mask_compositor_glyphs (const cairo_compositor_t *_compositor,
|
||||
cairo_composite_rectangles_t *extents,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_bool_t overlap)
|
||||
{
|
||||
cairo_surface_t *mask;
|
||||
cairo_surface_pattern_t pattern;
|
||||
cairo_int_status_t status;
|
||||
cairo_clip_t *clip;
|
||||
|
||||
if (! extents->is_bounded)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
TRACE ((stderr, "%s\n", __FUNCTION__));
|
||||
mask = _cairo_surface_create_similar_scratch (extents->surface,
|
||||
CAIRO_CONTENT_ALPHA,
|
||||
extents->bounded.width,
|
||||
extents->bounded.height);
|
||||
if (unlikely (mask->status))
|
||||
return mask->status;
|
||||
|
||||
clip = extents->clip;
|
||||
if (! _cairo_clip_is_region (clip))
|
||||
clip = _cairo_clip_copy_region (clip);
|
||||
|
||||
if (! mask->is_clear) {
|
||||
status = _cairo_surface_offset_paint (mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
CAIRO_OPERATOR_CLEAR,
|
||||
&_cairo_pattern_clear.base,
|
||||
clip);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = _cairo_surface_offset_glyphs (mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
&_cairo_pattern_white.base,
|
||||
scaled_font, glyphs, num_glyphs,
|
||||
clip);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
|
||||
if (clip != extents->clip) {
|
||||
status = _cairo_clip_combine_with_surface (extents->clip, mask,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y);
|
||||
if (unlikely (status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
_cairo_pattern_init_for_surface (&pattern, mask);
|
||||
cairo_matrix_init_translate (&pattern.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
pattern.base.filter = CAIRO_FILTER_NEAREST;
|
||||
pattern.base.extend = CAIRO_EXTEND_NONE;
|
||||
if (extents->op == CAIRO_OPERATOR_SOURCE) {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
CAIRO_OPERATOR_DEST_OUT,
|
||||
&_cairo_pattern_white.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
if ((status == CAIRO_INT_STATUS_SUCCESS)) {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
&extents->source_pattern.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
}
|
||||
} else {
|
||||
status = _cairo_surface_mask (extents->surface,
|
||||
extents->op,
|
||||
&extents->source_pattern.base,
|
||||
&pattern.base,
|
||||
clip);
|
||||
}
|
||||
_cairo_pattern_fini (&pattern.base);
|
||||
|
||||
error:
|
||||
if (clip != extents->clip)
|
||||
_cairo_clip_destroy (clip);
|
||||
cairo_surface_destroy (mask);
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_shape_mask_compositor_init (cairo_compositor_t *compositor,
|
||||
const cairo_compositor_t *delegate)
|
||||
{
|
||||
compositor->delegate = delegate;
|
||||
|
||||
compositor->paint = NULL;
|
||||
compositor->mask = NULL;
|
||||
compositor->fill = _cairo_shape_mask_compositor_fill;
|
||||
compositor->stroke = _cairo_shape_mask_compositor_stroke;
|
||||
compositor->glyphs = _cairo_shape_mask_compositor_glyphs;
|
||||
}
|
||||
|
|
@ -620,7 +620,7 @@ composite_polygon (const cairo_spans_compositor_t *compositor,
|
|||
cairo_bool_t needs_clip;
|
||||
cairo_int_status_t status;
|
||||
|
||||
needs_clip = composite_needs_clip (extents, &polygon->extents);
|
||||
needs_clip = extents->clip->path != NULL || extents->clip->num_boxes > 1;
|
||||
if (needs_clip) {
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
converter = _cairo_clip_tor_scan_converter_create (extents->clip,
|
||||
|
|
@ -879,25 +879,45 @@ _cairo_spans_compositor_stroke (const cairo_compositor_t *_compositor,
|
|||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
|
||||
cairo_polygon_t polygon;
|
||||
cairo_fill_rule_t fill_rule = CAIRO_FILL_RULE_WINDING;
|
||||
|
||||
if (extents->mask.width > extents->unbounded.width ||
|
||||
extents->mask.height > extents->unbounded.height)
|
||||
{
|
||||
_cairo_polygon_init_with_clip (&polygon, extents->clip);
|
||||
cairo_box_t limits;
|
||||
_cairo_box_from_rectangle (&limits, &extents->unbounded);
|
||||
_cairo_polygon_init (&polygon, &limits, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_cairo_polygon_init_with_clip (&polygon, NULL);
|
||||
_cairo_polygon_init (&polygon, NULL, 0);
|
||||
}
|
||||
status = _cairo_path_fixed_stroke_to_polygon (path,
|
||||
style,
|
||||
ctm, ctm_inverse,
|
||||
tolerance,
|
||||
&polygon);
|
||||
if (status == CAIRO_INT_STATUS_SUCCESS && extents->clip->num_boxes > 1) {
|
||||
status = _cairo_polygon_intersect_with_boxes (&polygon, &fill_rule,
|
||||
extents->clip->boxes,
|
||||
extents->clip->num_boxes);
|
||||
}
|
||||
if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
|
||||
cairo_clip_t *saved_clip = extents->clip;
|
||||
|
||||
if (extents->is_bounded) {
|
||||
extents->clip = _cairo_clip_copy_path (extents->clip);
|
||||
extents->clip = _cairo_clip_intersect_box(extents->clip,
|
||||
&polygon.extents);
|
||||
}
|
||||
|
||||
status = clip_and_composite_polygon (compositor, extents, &polygon,
|
||||
CAIRO_FILL_RULE_WINDING,
|
||||
antialias);
|
||||
fill_rule, antialias);
|
||||
|
||||
if (extents->clip != saved_clip) {
|
||||
_cairo_clip_destroy (extents->clip);
|
||||
extents->clip = saved_clip;
|
||||
}
|
||||
}
|
||||
_cairo_polygon_fini (&polygon);
|
||||
}
|
||||
|
|
@ -949,22 +969,27 @@ _cairo_spans_compositor_fill (const cairo_compositor_t *_compositor,
|
|||
}
|
||||
|
||||
status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &polygon);
|
||||
if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
|
||||
if (status == CAIRO_INT_STATUS_SUCCESS && extents->clip->num_boxes > 1) {
|
||||
status = _cairo_polygon_intersect_with_boxes (&polygon, &fill_rule,
|
||||
extents->clip->boxes,
|
||||
extents->clip->num_boxes);
|
||||
}
|
||||
if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
|
||||
if (extents->is_bounded) {
|
||||
if (extents->clip->boxes != &extents->clip->embedded_box)
|
||||
free (extents->clip->boxes);
|
||||
cairo_clip_t *saved_clip = extents->clip;
|
||||
|
||||
extents->clip->num_boxes = 1;
|
||||
extents->clip->boxes = &extents->clip->embedded_box;
|
||||
extents->clip->boxes[0] = polygon.extents;
|
||||
if (extents->is_bounded) {
|
||||
extents->clip = _cairo_clip_copy_path (extents->clip);
|
||||
extents->clip = _cairo_clip_intersect_box(extents->clip,
|
||||
&polygon.extents);
|
||||
}
|
||||
|
||||
status = clip_and_composite_polygon (compositor, extents, &polygon,
|
||||
fill_rule, antialias);
|
||||
|
||||
if (extents->clip != saved_clip) {
|
||||
_cairo_clip_destroy (extents->clip);
|
||||
extents->clip = saved_clip;
|
||||
}
|
||||
}
|
||||
_cairo_polygon_fini (&polygon);
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 653 B |
|
Before Width: | Height: | Size: 690 B After Width: | Height: | Size: 646 B |
|
Before Width: | Height: | Size: 653 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 891 B After Width: | Height: | Size: 837 B |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 618 B After Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 501 B After Width: | Height: | Size: 499 B |
|
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 596 B |
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 463 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 187 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 179 B |
|
Before Width: | Height: | Size: 511 KiB After Width: | Height: | Size: 518 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.1 KiB |