aboutsummaryrefslogtreecommitdiff
path: root/src/wld/interface/renderer.h
blob: 557b6935b320530d738d354a8843676ab567ad26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* wld: interface/drawable.h
 *
 * Copyright (c) 2013, 2014 Michael Forney
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

static uint32_t renderer_capabilities(struct wld_renderer * renderer,
                                      struct buffer * buffer);
static bool renderer_set_target(struct wld_renderer * renderer,
                                struct buffer * buffer);
static void renderer_fill_rectangle(struct wld_renderer * renderer,
                                    uint32_t color, int32_t x, int32_t y,
                                    uint32_t width, uint32_t height);
static void renderer_copy_rectangle(struct wld_renderer * renderer,
                                    struct buffer * buffer,
                                    int32_t dst_x, int32_t dst_y,
                                    int32_t src_x, int32_t src_y,
                                    uint32_t width, uint32_t height);
#ifdef RENDERER_IMPLEMENTS_REGION
static void renderer_fill_region(struct wld_renderer * base, uint32_t color,
                                 pixman_region32_t * region);
static void renderer_copy_region(struct wld_renderer * base,
                                 struct buffer * buffer,
                                 int32_t dst_x, int32_t dst_y,
                                 pixman_region32_t * region);
#endif
static void renderer_draw_text(struct wld_renderer * renderer,
                               struct font * font, uint32_t color,
                               int32_t x, int32_t y,
                               const char * text, uint32_t length,
                               struct wld_extents * extents);
static void renderer_flush(struct wld_renderer * renderer);
static void renderer_destroy(struct wld_renderer * renderer);

static const struct wld_renderer_impl wld_renderer_impl = {
    .capabilities = &renderer_capabilities,
    .set_target = &renderer_set_target,
    .fill_rectangle = &renderer_fill_rectangle,
    .copy_rectangle = &renderer_copy_rectangle,
#ifdef RENDERER_IMPLEMENTS_REGION
    .fill_region = &renderer_fill_region,
    .copy_region = &renderer_copy_region,
#else
    .fill_region = &default_fill_region,
    .copy_region = &default_copy_region,
#endif
    .draw_text = &renderer_draw_text,
    .flush = &renderer_flush,
    .destroy = &renderer_destroy
};