1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2011 Intel Corporation
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
33 * Chris Wilson <chris@chris-wilson.co.uk>
38 #include "cairo-gl-private.h"
40 #include "cairo-surface-backend-private.h"
43 _cairo_gl_source_finish (void *abstract_surface)
45 cairo_gl_source_t *source = abstract_surface;
47 _cairo_gl_operand_destroy (&source->operand);
48 return CAIRO_STATUS_SUCCESS;
51 static const cairo_surface_backend_t cairo_gl_source_backend = {
52 CAIRO_SURFACE_TYPE_GL,
53 _cairo_gl_source_finish,
54 NULL, /* read-only wrapper */
58 _cairo_gl_pattern_to_source (cairo_surface_t *dst,
59 const cairo_pattern_t *pattern,
61 const cairo_rectangle_int_t *extents,
62 const cairo_rectangle_int_t *sample,
63 int *src_x, int *src_y)
65 cairo_gl_source_t *source;
66 cairo_int_status_t status;
68 TRACE ((stderr, "%s\n", __FUNCTION__));
70 return _cairo_gl_white_source ();
72 source = malloc (sizeof (*source));
73 if (unlikely (source == NULL))
74 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
76 _cairo_surface_init (&source->base,
77 &cairo_gl_source_backend,
79 CAIRO_CONTENT_COLOR_ALPHA);
82 status = _cairo_gl_operand_init (&source->operand, pattern,
83 (cairo_gl_surface_t *)dst,
84 sample, extents, FALSE);
85 if (unlikely (status)) {
86 cairo_surface_destroy (&source->base);
87 return _cairo_surface_create_in_error (status);
94 _cairo_gl_white_source (void)
96 cairo_gl_source_t *source;
98 source = malloc (sizeof (*source));
99 if (unlikely (source == NULL))
100 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
102 _cairo_surface_init (&source->base,
103 &cairo_gl_source_backend,
105 CAIRO_CONTENT_COLOR_ALPHA);
107 _cairo_gl_solid_operand_init (&source->operand, CAIRO_COLOR_WHITE);
109 return &source->base;