4 Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
6 This file is part of libc3.
8 libc3 is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 libc3 is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with libc3. If not, see <http://www.gnu.org/licenses/>.
24 #include "c3driver_geometry.h"
31 const c3driver_geometry_t * d)
33 c3cairo_p c = (c3cairo_p)g;
38 cairo_surface_destroy(c->surface);
39 C3_DRIVER_INHERITED(g, d, dispose);
45 const struct c3driver_geometry_t *d,
48 C3_DRIVER_INHERITED(g, d, project, m);
51 const c3driver_geometry_t c3cairo_base_driver = {
52 .dispose = _c3cairo_dispose,
53 .project = _c3cairo_project,
55 extern const c3driver_geometry_t c3texture_driver;
56 extern const c3driver_geometry_t c3geometry_driver;
60 struct c3object_t * parent)
62 c3cairo_p res = malloc(sizeof(*res));
63 return c3cairo_init(res, parent);
69 struct c3object_t * parent)
71 memset(o, 0, sizeof(*o));
72 c3texture_init(&o->tex, parent);
74 static const c3driver_geometry_t * list[] = {
75 &c3cairo_base_driver, &c3texture_driver, &c3geometry_driver, NULL,
77 ((c3geometry_p)o)->driver = list;
83 c3cairo_new_offscreen(
84 struct c3object_t * parent,
87 c3cairo_p o = c3cairo_new(parent);
89 o->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
90 o->cr = cairo_create(o->surface);
92 c3pixels_p dst = c3pixels_new(w, h, 4,
93 cairo_image_surface_get_stride(o->surface),
94 cairo_image_surface_get_data(o->surface));
95 o->tex.geometry.mat.texture = dst;
101 cairo_surface_destroy(_surface);
103 cairo_surface_finish(_surface);
105 #endif // CONFIG_C3_CAIRO