tizen 2.3.1 release
[framework/graphics/cairo.git] / boilerplate / cairo-boilerplate-tg.c
1 /*
2  * Copyright © 2012 SCore Corporation
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it either under the terms of the GNU Lesser General Public
6  * License version 2.1 as published by the Free Software Foundation
7  * (the "LGPL") or, at your option, under the terms of the Mozilla
8  * Public License Version 1.1 (the "MPL"). If you do not alter this
9  * notice, a recipient may use your version of this file under either
10  * the MPL or the LGPL.
11  *
12  * You should have received a copy of the LGPL along with this library
13  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
15  * You should have received a copy of the MPL along with this library
16  * in the file COPYING-MPL-1.1
17  *
18  * The contents of this file are subject to the Mozilla Public License
19  * Version 1.1 (the "License"); you may not use this file except in
20  * compliance with the License. You may obtain a copy of the License at
21  * http://www.mozilla.org/MPL/
22  *
23  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
24  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
25  * the specific language governing rights and limitations.
26  *
27  * Author: Taekyun Kim (podain77@gmail.com)
28  */
29
30 #include "cairo-boilerplate-private.h"
31
32 #include <cairo-tg.h>
33 #include <assert.h>
34
35 static cairo_surface_t *
36 _cairo_boilerplate_tg_create_surface (const char                *name,
37                                       cairo_content_t           content,
38                                       double                    width,
39                                       double                    height,
40                                       double                    max_width,
41                                       double                    max_height,
42                                       cairo_boilerplate_mode_t  mode,
43                                       void                      **closure)
44 {
45     cairo_format_t format;
46
47     if (content == CAIRO_CONTENT_COLOR_ALPHA)
48     {
49         format = CAIRO_FORMAT_ARGB32;
50     }
51     else if (content == CAIRO_CONTENT_COLOR)
52     {
53         format = CAIRO_FORMAT_RGB24;
54     }
55     else
56     {
57         assert (0);
58         return NULL;
59     }
60
61     *closure = NULL;
62
63     return cairo_tg_surface_create (format, ceil (width), ceil (height));
64 }
65
66 static const cairo_boilerplate_target_t targets[] =
67 {
68     {
69         "tg", "tg", NULL, NULL,
70         CAIRO_SURFACE_TYPE_TG, CAIRO_CONTENT_COLOR_ALPHA, 0,
71         NULL,
72         _cairo_boilerplate_tg_create_surface,
73         cairo_surface_create_similar,
74         NULL, NULL,
75         _cairo_boilerplate_get_image_surface,
76         cairo_surface_write_to_png,
77         NULL, NULL, NULL,
78         TRUE, FALSE, FALSE
79     }
80 };
81 CAIRO_BOILERPLATE (tg, targets)