4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
7 * Stanislav Vorobiov <s.vorobiov@samsung.com>
8 * Jinhyung Jo <jinhyung.jo@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 #include "yagl_offscreen.h"
35 #include "yagl_offscreen_surface.h"
36 #include "yagl_offscreen_image_pixmap.h"
37 #include "yagl_display.h"
38 #include "yagl_native_display.h"
39 #include "yagl_backend.h"
40 #include "yagl_malloc.h"
41 #include "yagl_native_platform.h"
42 #include "yagl_egl_state.h"
43 #include "yagl_host_egl_calls.h"
45 static struct yagl_display
46 *yagl_offscreen_create_display(struct yagl_native_platform *platform,
47 yagl_os_display os_dpy)
50 struct yagl_display *dpy;
51 yagl_host_handle host_dpy;
52 struct yagl_native_display *native_dpy;
54 native_dpy = platform->wrap_display(os_dpy, 0);
60 host_dpy = yagl_host_eglGetDisplay((uint32_t)os_dpy, &error);
63 yagl_set_error(error);
64 native_dpy->destroy(native_dpy);
68 dpy = yagl_malloc0(sizeof(*dpy));
70 yagl_display_init(dpy, os_dpy, native_dpy, host_dpy);
75 static struct yagl_surface
76 *yagl_offscreen_create_window_surface(struct yagl_display *dpy,
77 yagl_host_handle host_config,
78 struct yagl_native_drawable *native_window,
79 const EGLint* attrib_list)
81 struct yagl_offscreen_surface *sfc =
82 yagl_offscreen_surface_create_window(dpy,
87 return sfc ? &sfc->base : NULL;
90 static struct yagl_surface
91 *yagl_offscreen_create_pixmap_surface(struct yagl_display *dpy,
92 yagl_host_handle host_config,
93 struct yagl_native_drawable *native_pixmap,
94 const EGLint* attrib_list)
96 struct yagl_offscreen_surface *sfc =
97 yagl_offscreen_surface_create_pixmap(dpy,
102 return sfc ? &sfc->base : NULL;
105 static struct yagl_surface
106 *yagl_offscreen_create_pbuffer_surface(struct yagl_display *dpy,
107 yagl_host_handle host_config,
108 const EGLint* attrib_list)
110 struct yagl_offscreen_surface *sfc =
111 yagl_offscreen_surface_create_pbuffer(dpy, host_config, attrib_list);
113 return sfc ? &sfc->base : NULL;
116 static struct yagl_image
117 *yagl_offscreen_create_image_pixmap(struct yagl_display *dpy,
118 struct yagl_native_drawable *native_pixmap,
119 struct yagl_client_interface *iface)
121 struct yagl_offscreen_image_pixmap *image =
122 yagl_offscreen_image_pixmap_create(dpy,
126 return image ? &image->base : NULL;
129 static struct yagl_image
130 *yagl_offscreen_create_image_wl_buffer(struct yagl_display *dpy,
131 struct wl_resource *buffer,
132 struct yagl_client_interface *iface)
137 static struct yagl_image
138 *yagl_offscreen_create_image_gl_texture_2d(struct yagl_display *dpy,
139 struct yagl_context *ctx,
140 yagl_object_name texture,
141 struct yagl_client_interface *iface)
146 static struct yagl_image
147 *yagl_offscreen_create_image_tizen_sfc(struct yagl_display *dpy,
148 EGLClientBuffer buffer,
149 struct yagl_client_interface *iface)
154 static struct yagl_fence
155 *yagl_offscreen_create_fence(struct yagl_display *dpy)
160 static void yagl_offscreen_destroy(struct yagl_backend *backend)
165 struct yagl_backend *yagl_offscreen_create()
167 struct yagl_backend *backend;
169 backend = yagl_malloc0(sizeof(*backend));
171 backend->create_display = &yagl_offscreen_create_display;
172 backend->create_window_surface = &yagl_offscreen_create_window_surface;
173 backend->create_pixmap_surface = &yagl_offscreen_create_pixmap_surface;
174 backend->create_pbuffer_surface = &yagl_offscreen_create_pbuffer_surface;
175 backend->create_image_pixmap = &yagl_offscreen_create_image_pixmap;
176 backend->create_image_wl_buffer = &yagl_offscreen_create_image_wl_buffer;
177 backend->create_image_gl_texture_2d = &yagl_offscreen_create_image_gl_texture_2d;
178 backend->create_image_tizen_sfc = &yagl_offscreen_create_image_tizen_sfc;
179 backend->create_fence = &yagl_offscreen_create_fence;
180 backend->destroy = &yagl_offscreen_destroy;
181 backend->y_inverted = 1;
182 backend->fence_supported = 0;