4 Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr 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 simavr 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 simavr. If not, see <http://www.gnu.org/licenses/>.
23 #include "c3/c3cairo.h"
24 #include "c3/c3driver_geometry.h"
29 const c3driver_geometry_t * d)
31 c3cairo_p c = (c3cairo_p)g;
36 cairo_surface_destroy(c->surface);
37 C3_DRIVER_INHERITED(g, d, dispose);
43 const struct c3driver_geometry_t *d,
46 C3_DRIVER_INHERITED(g, d, project, m);
49 const c3driver_geometry_t c3cairo_base_driver = {
50 .dispose = _c3cairo_dispose,
51 .project = _c3cairo_project,
53 const c3driver_geometry_t c3texture_driver;
54 const c3driver_geometry_t c3geometry_driver;
58 struct c3object_t * parent)
60 c3cairo_p res = malloc(sizeof(*res));
61 return c3cairo_init(res, parent);
67 struct c3object_t * parent)
69 memset(o, 0, sizeof(*o));
70 c3texture_init(&o->tex, parent);
72 static const c3driver_geometry_t * list[] = {
73 &c3cairo_base_driver, &c3texture_driver, &c3geometry_driver, NULL,
75 ((c3geometry_p)o)->driver = list;
81 c3cairo_new_offscreen(
82 struct c3object_t * parent,
85 c3cairo_p o = c3cairo_new(parent);
87 o->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
88 o->cr = cairo_create(o->surface);
90 c3pixels_init(&o->tex.pixels, w, h, 4,
91 cairo_image_surface_get_stride(o->surface),
92 cairo_image_surface_get_data(o->surface));
98 cairo_surface_destroy(_surface);
100 cairo_surface_finish(_surface);