summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Ulyanov <v.ulyanov@samsung.com>2016-03-03 17:55:02 +0300
committerVasiliy Ulyanov <v.ulyanov@samsung.com>2016-03-03 18:06:01 +0300
commitda44b0ee3500c970f903e461854c0389ba326643 (patch)
tree59c4f726ebb9de4dc2b6d35c495b1f2dc9e5a85b
parent1f93bb9b68e1d5e2a047ff5f7351470c24ff7a22 (diff)
downloademulator-yagl-da44b0ee3500c970f903e461854c0389ba326643.tar.gz
emulator-yagl-da44b0ee3500c970f903e461854c0389ba326643.tar.bz2
emulator-yagl-da44b0ee3500c970f903e461854c0389ba326643.zip
Currently it is needed to make Tizen 3.0 feature tests pass in emulator. They appear to be using eglCreatePbufferSurface(...) for offscreen rendering. I am not sure if such functionality is really needed with Wayland (in fact it is not supported even in Mesa). Anyway I have not found any spec saying that Wayland should fail with this call so for the moment some draft implementation should be okay I think. Change-Id: I01372121c0e080e0007c69a12d4b97ad8df6fc04 Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
-rw-r--r--EGL/CMakeLists.txt1
-rw-r--r--EGL/wayland/yagl_wayland_display.c7
-rw-r--r--EGL/wayland/yagl_wayland_pbuffer.c197
-rw-r--r--EGL/wayland/yagl_wayland_pbuffer.h49
4 files changed, 253 insertions, 1 deletions
diff --git a/EGL/CMakeLists.txt b/EGL/CMakeLists.txt
index 4f5d75e..d42af56 100644
--- a/EGL/CMakeLists.txt
+++ b/EGL/CMakeLists.txt
@@ -89,6 +89,7 @@ if (PLATFORM_WAYLAND)
wayland/yagl_wayland_platform.c
wayland/yagl_wayland_display.c
wayland/yagl_wayland_window.c
+ wayland/yagl_wayland_pbuffer.c
yagl_onscreen_image_wl_buffer.c
)
set(LIBRARIES ${LIBRARIES}
diff --git a/EGL/wayland/yagl_wayland_display.c b/EGL/wayland/yagl_wayland_display.c
index a617e73..a3f662d 100644
--- a/EGL/wayland/yagl_wayland_display.c
+++ b/EGL/wayland/yagl_wayland_display.c
@@ -33,6 +33,7 @@
#include "yagl_wayland_display.h"
#include "yagl_wayland_window.h"
+#include "yagl_wayland_pbuffer.h"
#include "yagl_log.h"
#include "yagl_malloc.h"
#include "wayland-drm-client-protocol.h"
@@ -251,7 +252,11 @@ static struct yagl_native_drawable
uint32_t height,
uint32_t depth)
{
- return NULL;
+ /*
+ * Wayland actaully has no pixmap type. This is just for creating
+ * a pbuffer and to make Tizen conformance tests happy.
+ */
+ return yagl_wayland_pbuffer_create(dpy, width, height, depth);
}
static struct yagl_native_image
diff --git a/EGL/wayland/yagl_wayland_pbuffer.c b/EGL/wayland/yagl_wayland_pbuffer.c
new file mode 100644
index 0000000..7b230ff
--- /dev/null
+++ b/EGL/wayland/yagl_wayland_pbuffer.c
@@ -0,0 +1,197 @@
+/*
+ * YaGL
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact :
+ * Vasiliy Ulyanov <v.ulyanov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "yagl_wayland_pbuffer.h"
+#include "yagl_native_display.h"
+#include "yagl_native_drawable.h"
+#include "yagl_log.h"
+#include "yagl_malloc.h"
+#include "yagl_gbm.h"
+#include "vigs.h"
+#include <assert.h>
+#include <string.h>
+
+#define YAGL_WAYLAND_PBUFFER(os_pbuffer) ((struct vigs_drm_surface *)(os_pbuffer))
+
+static int yagl_wayland_pbuffer_get_buffer(struct yagl_native_drawable *drawable,
+ yagl_native_attachment attachment,
+ uint32_t *buffer_name,
+ struct vigs_drm_surface **buffer_sfc)
+{
+ struct vigs_drm_surface *drm_sfc = YAGL_WAYLAND_PBUFFER(drawable->os_drawable);
+
+ YAGL_LOG_FUNC_SET(yagl_wayland_pbuffer_get_buffer);
+
+ switch (attachment) {
+ case yagl_native_attachment_front:
+ break;
+ case yagl_native_attachment_back:
+ default:
+ YAGL_LOG_ERROR("Bad attachment %u", attachment);
+ return 0;
+ }
+
+ vigs_drm_gem_ref(&drm_sfc->gem);
+
+ *buffer_sfc = drm_sfc;
+
+ return 1;
+}
+
+static int yagl_wayland_pbuffer_get_buffer_age(struct yagl_native_drawable *drawable)
+{
+ return 0;
+}
+
+static void yagl_wayland_pbuffer_swap_buffers(struct yagl_native_drawable *drawable)
+{
+}
+
+static void yagl_wayland_pbuffer_wait(struct yagl_native_drawable *drawable,
+ uint32_t width,
+ uint32_t height)
+{
+}
+
+static void yagl_wayland_pbuffer_copy_to_pixmap(struct yagl_native_drawable *drawable,
+ yagl_os_pixmap os_pixmap,
+ uint32_t from_x,
+ uint32_t from_y,
+ uint32_t to_x,
+ uint32_t to_y,
+ uint32_t width,
+ uint32_t height)
+{
+}
+
+static void yagl_wayland_pbuffer_set_swap_interval(struct yagl_native_drawable *drawable,
+ int interval)
+{
+}
+
+static void yagl_wayland_pbuffer_get_geometry(struct yagl_native_drawable *drawable,
+ uint32_t *width,
+ uint32_t *height,
+ uint32_t *depth)
+{
+ struct vigs_drm_surface *drm_sfc = YAGL_WAYLAND_PBUFFER(drawable->os_drawable);
+
+ *width = drm_sfc->width;
+ *height = drm_sfc->height;
+
+ switch (drm_sfc->format) {
+ case vigs_drm_surface_bgrx8888:
+ *depth = 24;
+ break;
+ case vigs_drm_surface_bgra8888:
+ *depth = 32;
+ break;
+ default: /* should never happen */
+ assert(NULL);
+ break;
+ }
+}
+
+static struct yagl_native_image
+ *yagl_wayland_pbuffer_get_image(struct yagl_native_drawable *drawable,
+ uint32_t width,
+ uint32_t height)
+{
+ return NULL;
+}
+
+static void yagl_wayland_pbuffer_destroy(struct yagl_native_drawable *drawable)
+{
+ struct vigs_drm_surface *drm_sfc = YAGL_WAYLAND_PBUFFER(drawable->os_drawable);
+
+ vigs_drm_gem_unref(&drm_sfc->gem);
+
+ yagl_native_drawable_cleanup(drawable);
+
+ yagl_free(drawable);
+}
+
+struct yagl_native_drawable
+ *yagl_wayland_pbuffer_create(struct yagl_native_display *dpy,
+ uint32_t width,
+ uint32_t height,
+ uint32_t depth)
+{
+ vigs_drm_surface_format format;
+ struct vigs_drm_surface *drm_sfc;
+ struct yagl_native_drawable *pbuffer;
+ int ret;
+
+ YAGL_LOG_FUNC_SET(yagl_wayland_pbuffer_create);
+
+ switch (depth) {
+ case 24:
+ format = vigs_drm_surface_bgrx8888;
+ break;
+ case 32:
+ format = vigs_drm_surface_bgra8888;
+ break;
+ default:
+ YAGL_LOG_ERROR("Bad depth value: %u", depth);
+ return NULL;
+ }
+
+ ret = vigs_drm_surface_create(dpy->drm_dev,
+ width,
+ height,
+ width * 4, /* stride */
+ format,
+ 0, /* scanout */
+ &drm_sfc);
+
+ if (ret) {
+ YAGL_LOG_ERROR("vigs_drm_surface_create failed: %s", strerror(-ret));
+ return NULL;
+ }
+
+ pbuffer = yagl_malloc0(sizeof(*pbuffer));
+
+ yagl_native_drawable_init(pbuffer, dpy, (yagl_os_drawable)drm_sfc);
+
+ pbuffer->get_buffer = &yagl_wayland_pbuffer_get_buffer;
+ pbuffer->get_buffer_age = &yagl_wayland_pbuffer_get_buffer_age;
+ pbuffer->swap_buffers = &yagl_wayland_pbuffer_swap_buffers;
+ pbuffer->wait = &yagl_wayland_pbuffer_wait;
+ pbuffer->copy_to_pixmap = &yagl_wayland_pbuffer_copy_to_pixmap;
+ pbuffer->set_swap_interval = &yagl_wayland_pbuffer_set_swap_interval;
+ pbuffer->get_geometry = &yagl_wayland_pbuffer_get_geometry;
+ pbuffer->get_image = &yagl_wayland_pbuffer_get_image;
+ pbuffer->destroy = &yagl_wayland_pbuffer_destroy;
+
+ return pbuffer;
+}
diff --git a/EGL/wayland/yagl_wayland_pbuffer.h b/EGL/wayland/yagl_wayland_pbuffer.h
new file mode 100644
index 0000000..a27a356
--- /dev/null
+++ b/EGL/wayland/yagl_wayland_pbuffer.h
@@ -0,0 +1,49 @@
+/*
+ * YaGL
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact :
+ * Vasiliy Ulyanov <v.ulyanov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef _YAGL_WAYLAND_PBUFFER_H_
+#define _YAGL_WAYLAND_PBUFFER_H_
+
+#include "yagl_export.h"
+#include "yagl_native_types.h"
+
+struct yagl_native_display;
+struct yagl_native_drawable;
+
+struct yagl_native_drawable
+ *yagl_wayland_pbuffer_create(struct yagl_native_display *dpy,
+ uint32_t width,
+ uint32_t height,
+ uint32_t depth);
+
+#endif /* _YAGL_WAYLAND_PBUFFER_H_ */