1/* wld: interface/drawable.h
2 *
3 * Copyright (c) 2013, 2014 Michael Forney
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24static uint32_t renderer_capabilities(struct wld_renderer *renderer,
25 struct buffer *buffer);
26static bool renderer_set_target(struct wld_renderer *renderer,
27 struct buffer *buffer);
28static void renderer_fill_rectangle(struct wld_renderer *renderer,
29 uint32_t color, int32_t x, int32_t y,
30 uint32_t width, uint32_t height);
31static void renderer_copy_rectangle(struct wld_renderer *renderer,
32 struct buffer *buffer,
33 int32_t dst_x, int32_t dst_y,
34 int32_t src_x, int32_t src_y,
35 uint32_t width, uint32_t height);
36
37#ifdef RENDERER_IMPLEMENTS_REGION
38static void renderer_fill_region(struct wld_renderer *base, uint32_t color,
39 pixman_region32_t *region);
40static void renderer_copy_region(struct wld_renderer *base,
41 struct buffer *buffer,
42 int32_t dst_x, int32_t dst_y,
43 pixman_region32_t *region);
44#endif
45static void renderer_draw_text(struct wld_renderer *renderer,
46 struct font *font, uint32_t color,
47 int32_t x, int32_t y,
48 const char *text, uint32_t length,
49 struct wld_extents *extents);
50static void renderer_flush(struct wld_renderer *renderer);
51static void renderer_destroy(struct wld_renderer *renderer);
52
53static const struct wld_renderer_impl wld_renderer_impl = {
54 .capabilities = &renderer_capabilities,
55 .set_target = &renderer_set_target,
56 .fill_rectangle = &renderer_fill_rectangle,
57 .copy_rectangle = &renderer_copy_rectangle,
58#ifdef RENDERER_IMPLEMENTS_REGION
59 .fill_region = &renderer_fill_region,
60 .copy_region = &renderer_copy_region,
61#else
62 .fill_region = &default_fill_region,
63 .copy_region = &default_copy_region,
64#endif
65 .draw_circle = &wld_draw_circle,
66 .draw_line = &wld_draw_line,
67 .draw_text = &renderer_draw_text,
68 .flush = &renderer_flush,
69 .destroy = &renderer_destroy
70};