main
surface.c
1/* wld: surface.c
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#include "wld-private.h"
25
26struct wld_surface *
27default_create_surface(struct wld_context *context,
28 uint32_t width, uint32_t height,
29 uint32_t format, uint32_t flags)
30{
31 return buffered_surface_create(context, width, height, format, flags, NULL);
32}
33
34void
35surface_initialize(struct wld_surface *surface, const struct wld_surface_impl *impl)
36{
37 *((const struct wld_surface_impl **)&surface->impl) = impl;
38}
39
40EXPORT
41pixman_region32_t *
42wld_surface_damage(struct wld_surface *surface, pixman_region32_t *new_damage)
43{
44 return surface->impl->damage(surface, new_damage);
45}
46
47EXPORT
48struct wld_buffer *
49wld_surface_take(struct wld_surface *surface)
50{
51 return &surface->impl->take(surface)->base;
52}
53
54EXPORT
55void
56wld_surface_release(struct wld_surface *surface, struct wld_buffer *buffer)
57{
58 surface->impl->release(surface, (struct buffer *)buffer);
59}
60
61EXPORT
62bool
63wld_swap(struct wld_surface *surface)
64{
65 return surface->impl->swap(surface);
66}
67
68EXPORT
69void
70wld_destroy_surface(struct wld_surface *surface)
71{
72 surface->impl->destroy(surface);
73}