renderer.h (3638B)
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 24 static uint32_t renderer_capabilities(struct wld_renderer *renderer, 25 struct buffer *buffer); 26 static bool renderer_set_target(struct wld_renderer *renderer, 27 struct buffer *buffer); 28 static 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); 31 static 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 38 static void renderer_fill_region(struct wld_renderer *base, uint32_t color, 39 pixman_region32_t *region); 40 static 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 45 static 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); 50 #ifdef RENDERER_IMPLEMENTS_CLIP 51 static void renderer_set_clip(struct wld_renderer *renderer, int32_t x, int32_t y, 52 uint32_t width, uint32_t height); 53 #endif 54 static void renderer_flush(struct wld_renderer *renderer); 55 static void renderer_destroy(struct wld_renderer *renderer); 56 57 static const struct wld_renderer_impl wld_renderer_impl = { 58 .capabilities = &renderer_capabilities, 59 .set_target = &renderer_set_target, 60 .fill_rectangle = &renderer_fill_rectangle, 61 .copy_rectangle = &renderer_copy_rectangle, 62 #ifdef RENDERER_IMPLEMENTS_REGION 63 .fill_region = &renderer_fill_region, 64 .copy_region = &renderer_copy_region, 65 #else 66 .fill_region = &default_fill_region, 67 .copy_region = &default_copy_region, 68 #endif 69 .draw_circle = &wld_draw_circle, 70 .draw_line = &wld_draw_line, 71 .draw_text = &renderer_draw_text, 72 #ifdef RENDERER_IMPLEMENTS_CLIP 73 .set_clip = &renderer_set_clip, 74 #endif 75 .flush = &renderer_flush, 76 .destroy = &renderer_destroy 77 };