1 /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
2 /* cairo - a vector graphics library with display and print output
4 * Copyright © 2003 University of Southern California
5 * Copyright © 2009,2010,2011 Intel Corporation
7 * This library is free software; you can redistribute it and/or
8 * modify it either under the terms of the GNU Lesser General Public
9 * License version 2.1 as published by the Free Software Foundation
10 * (the "LGPL") or, at your option, under the terms of the Mozilla
11 * Public License Version 1.1 (the "MPL"). If you do not alter this
12 * notice, a recipient may use your version of this file under either
13 * the MPL or the LGPL.
15 * You should have received a copy of the LGPL along with this library
16 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
18 * You should have received a copy of the MPL along with this library
19 * in the file COPYING-MPL-1.1
21 * The contents of this file are subject to the Mozilla Public License
22 * Version 1.1 (the "License"); you may not use this file except in
23 * compliance with the License. You may obtain a copy of the License at
24 * http://www.mozilla.org/MPL/
26 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
27 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
28 * the specific language governing rights and limitations.
30 * The Original Code is the cairo graphics library.
32 * The Initial Developer of the Original Code is University of Southern
36 * Carl D. Worth <cworth@cworth.org>
37 * Chris Wilson <chris@chris-wilson.co.uk>
42 #include "cairo-compositor-private.h"
43 #include "cairo-image-surface-private.h"
44 #include "cairo-spans-compositor-private.h"
46 typedef struct _cairo_image_span_renderer {
47 cairo_span_renderer_t base;
49 pixman_image_compositor_t *compositor;
52 cairo_rectangle_int_t extents;
53 } cairo_image_span_renderer_t;
56 _cairo_image_span_renderer_init (cairo_abstract_span_renderer_t *_r,
62 const cairo_composite_rectangles_t *composite,
63 cairo_bool_t needs_clip)
65 cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *)_r;
66 cairo_pixman_source_t *src = (cairo_pixman_source_t *)_src;
69 if (op == CAIRO_OPERATOR_CLEAR) {
70 op = CAIRO_OPERATOR_DEST_OUT;
74 r->src = ((cairo_pixman_source_t *) src)->pixman_image;
77 if (composite->is_bounded) {
79 r->base.render_rows = _cairo_image_bounded_opaque_spans;
81 r->base.render_rows = _cairo_image_bounded_spans;
82 r->base.finish = NULL;
85 r->base.render_rows = _cairo_image_clipped_spans;
87 r->base.render_rows = _cairo_image_unbounded_spans;
88 r->base.finish = _cairo_image_finish_unbounded_spans;
89 r->extents = composite->unbounded;
90 r->extents.height += r->extents.y;
94 pixman_image_create_compositor (_pixman_operator (op),
95 r->src, NULL, dst->pixman_image,
96 composite->bounded.x + src_x,
97 composite->bounded.y + src_y,
100 composite->bounded.y,
101 composite->bounded.width,
102 composite->bounded.height);
103 if (unlikely (r->compositor == NULL))
104 return CAIRO_INT_STATUS_NOTHING_TO_DO;
106 return CAIRO_STATUS_SUCCESS;
110 _cairo_image_span_renderer_fini (cairo_abstract_span_renderer_t *_r)
112 cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *) r;
113 pixman_image_compositor_destroy (r->compositor);
116 const cairo_compositor_t *
117 _cairo_image_spans_compositor_get (void)
119 static cairo_spans_compositor_t compositor;
121 if (compositor.base.delegate == NULL) {
122 /* Can't fallback to the mask compositor as that will simply
123 * call the spans-compositor again to render the mask!
125 _cairo_spans_compositor_init (&compositor,
126 _cairo_image_traps_compositor_get());
130 return &compositor.base;