summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Ulyanov <v.ulyanov@samsung.com>2015-05-07 16:45:39 +0300
committerjinhyung.jo <jinhyung.jo@samsung.com>2015-05-26 18:48:28 +0900
commita18ae148f3712a5f306e2543f9bd33649a8aa8ae (patch)
tree2d1d43389eebe7d86067751d8a0d5b59e2e65cca
parent8931c19c44843144405514d5f725c6348fa24355 (diff)
downloademulator-yagl-a18ae148f3712a5f306e2543f9bd33649a8aa8ae.tar.gz
emulator-yagl-a18ae148f3712a5f306e2543f9bd33649a8aa8ae.tar.bz2
emulator-yagl-a18ae148f3712a5f306e2543f9bd33649a8aa8ae.zip
YaGL: Add EGL_TIZEN_image_native_surface support
eglCreateImageKHR(...) now supports EGL_NATIVE_SURFACE_TIZEN target (onscreen backend only) Change-Id: I9ac7016cb3f0c05d7c35a31135506142c22bcb0c Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
-rw-r--r--CMakeLists.txt5
-rw-r--r--EGL/CMakeLists.txt2
-rw-r--r--EGL/yagl_backend.h4
-rw-r--r--EGL/yagl_display.c6
-rw-r--r--EGL/yagl_egl_calls.c28
-rw-r--r--EGL/yagl_offscreen.c9
-rw-r--r--EGL/yagl_onscreen.c13
-rw-r--r--EGL/yagl_onscreen_image_tizen_sfc.c122
-rw-r--r--EGL/yagl_onscreen_image_tizen_sfc.h55
-rw-r--r--packaging/emulator-yagl.spec2
10 files changed, 246 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d7f758..bced734 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,6 +70,11 @@ add_definitions(${LIBDRM_VIGS_CFLAGS})
include_directories(${LIBDRM_VIGS_INCLUDE_DIRS})
link_directories(${LIBDRM_VIGS_LIBRARY_DIRS})
+pkg_check_modules(LIBTBM REQUIRED libtbm)
+add_definitions(${LIBTBM_CFLAGS})
+include_directories(${LIBTBM_INCLUDE_DIRS})
+link_directories(${LIBTBM_LIBRARY_DIRS})
+
if (PLATFORM_X11)
pkg_check_modules(X11 REQUIRED x11)
pkg_check_modules(XEXT REQUIRED xext)
diff --git a/EGL/CMakeLists.txt b/EGL/CMakeLists.txt
index 58b295a..4d40059 100644
--- a/EGL/CMakeLists.txt
+++ b/EGL/CMakeLists.txt
@@ -22,6 +22,7 @@ set(SOURCES
yagl_onscreen.c
yagl_onscreen_image_pixmap.c
yagl_onscreen_image_gl_texture_2d.c
+ yagl_onscreen_image_tizen_sfc.c
yagl_onscreen_surface.c
yagl_onscreen_fence.c
yagl_onscreen_utils.c
@@ -42,6 +43,7 @@ set(LIBRARIES
${CMAKE_THREAD_LIBS_INIT}
${LIBDRM_LIBRARIES}
${LIBDRM_VIGS_LIBRARIES}
+ ${LIBTBM_LIBRARIES}
dl
)
diff --git a/EGL/yagl_backend.h b/EGL/yagl_backend.h
index d939ba6..c845109 100644
--- a/EGL/yagl_backend.h
+++ b/EGL/yagl_backend.h
@@ -90,6 +90,10 @@ struct yagl_backend
yagl_object_name /*texture*/,
struct yagl_client_interface */*iface*/);
+ struct yagl_image *(*create_image_tizen_sfc)(struct yagl_display */*dpy*/,
+ EGLClientBuffer /*buffer*/,
+ struct yagl_client_interface */*iface*/);
+
struct yagl_fence *(*create_fence)(struct yagl_display */*dpy*/);
void (*destroy)(struct yagl_backend */*backend*/);
diff --git a/EGL/yagl_display.c b/EGL/yagl_display.c
index d18281c..7a17dec 100644
--- a/EGL/yagl_display.c
+++ b/EGL/yagl_display.c
@@ -59,6 +59,8 @@
#define YAGL_EGL_GL_TEXTURE_EXTENSIONS "EGL_KHR_gl_texture_2D_image "
+#define YAGL_EGL_TIZEN_EXTENSIONS "EGL_TIZEN_image_native_surface "
+
#define YAGL_EGL_BUFFER_AGE_EXTENSIONS "EGL_EXT_buffer_age "
#define YAGL_EGL_FENCE_EXTENSIONS "EGL_KHR_fence_sync "
@@ -310,6 +312,8 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy)
len += strlen(YAGL_EGL_GL_TEXTURE_EXTENSIONS);
+ len += strlen(YAGL_EGL_TIZEN_EXTENSIONS);
+
dpy->extensions = yagl_malloc(len + 1);
strcpy(dpy->extensions, YAGL_EGL_BASE_EXTENSIONS);
@@ -331,6 +335,8 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy)
}
strcat(dpy->extensions, YAGL_EGL_GL_TEXTURE_EXTENSIONS);
+
+ strcpy(dpy->extensions, YAGL_EGL_TIZEN_EXTENSIONS);
}
pthread_mutex_unlock(&dpy->mutex);
diff --git a/EGL/yagl_egl_calls.c b/EGL/yagl_egl_calls.c
index 59aa871..138488d 100644
--- a/EGL/yagl_egl_calls.c
+++ b/EGL/yagl_egl_calls.c
@@ -1630,6 +1630,10 @@ out:
return res;
}
+#ifndef EGL_NATIVE_SURFACE_TIZEN
+#define EGL_NATIVE_SURFACE_TIZEN 0x32A1
+#endif
+
YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_,
EGLContext ctx_,
EGLenum target,
@@ -1765,6 +1769,30 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_,
}
break;
+ case EGL_NATIVE_SURFACE_TIZEN:
+ if (attrib_list) {
+ while (attrib_list[i] != EGL_NONE) {
+ switch (attrib_list[i]) {
+ case EGL_IMAGE_PRESERVED_KHR:
+ break;
+ default:
+ YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
+ goto out;
+ }
+
+ i += 2;
+ }
+ }
+
+ image = yagl_get_backend()->create_image_tizen_sfc(dpy,
+ buffer,
+ iface);
+
+ if (!image) {
+ goto out;
+ }
+
+ break;
default:
YAGL_SET_ERR(EGL_BAD_PARAMETER);
goto out;
diff --git a/EGL/yagl_offscreen.c b/EGL/yagl_offscreen.c
index e8c3781..5adadf0 100644
--- a/EGL/yagl_offscreen.c
+++ b/EGL/yagl_offscreen.c
@@ -143,6 +143,14 @@ static struct yagl_image
return NULL;
}
+static struct yagl_image
+ *yagl_offscreen_create_image_tizen_sfc(struct yagl_display *dpy,
+ EGLClientBuffer buffer,
+ struct yagl_client_interface *iface)
+{
+ return NULL;
+}
+
static struct yagl_fence
*yagl_offscreen_create_fence(struct yagl_display *dpy)
{
@@ -167,6 +175,7 @@ struct yagl_backend *yagl_offscreen_create()
backend->create_image_pixmap = &yagl_offscreen_create_image_pixmap;
backend->create_image_wl_buffer = &yagl_offscreen_create_image_wl_buffer;
backend->create_image_gl_texture_2d = &yagl_offscreen_create_image_gl_texture_2d;
+ backend->create_image_tizen_sfc = &yagl_offscreen_create_image_tizen_sfc;
backend->create_fence = &yagl_offscreen_create_fence;
backend->destroy = &yagl_offscreen_destroy;
backend->y_inverted = 1;
diff --git a/EGL/yagl_onscreen.c b/EGL/yagl_onscreen.c
index 4af1863..7ad8d06 100644
--- a/EGL/yagl_onscreen.c
+++ b/EGL/yagl_onscreen.c
@@ -38,6 +38,7 @@
#include "yagl_onscreen_image_wl_buffer.h"
#endif
#include "yagl_onscreen_image_gl_texture_2d.h"
+#include "yagl_onscreen_image_tizen_sfc.h"
#include "yagl_onscreen_fence.h"
#include "yagl_backend.h"
#include "yagl_malloc.h"
@@ -160,6 +161,17 @@ static struct yagl_image
return image ? &image->base: NULL;
}
+static struct yagl_image
+ *yagl_onscreen_create_image_tizen_sfc(struct yagl_display *dpy,
+ EGLClientBuffer buffer,
+ struct yagl_client_interface *iface)
+{
+ struct yagl_onscreen_image_tizen_sfc *image =
+ yagl_onscreen_image_tizen_sfc_create(dpy, buffer, iface);
+
+ return image ? &image->base: NULL;
+}
+
static struct yagl_fence
*yagl_onscreen_create_fence(struct yagl_display *dpy)
{
@@ -186,6 +198,7 @@ struct yagl_backend *yagl_onscreen_create()
backend->create_image_pixmap = &yagl_onscreen_create_image_pixmap;
backend->create_image_wl_buffer = &yagl_onscreen_create_image_wl_buffer;
backend->create_image_gl_texture_2d = &yagl_onscreen_create_image_gl_texture_2d;
+ backend->create_image_tizen_sfc = &yagl_onscreen_create_image_tizen_sfc;
backend->create_fence = &yagl_onscreen_create_fence;
backend->destroy = &yagl_onscreen_destroy;
backend->y_inverted = 0;
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.c b/EGL/yagl_onscreen_image_tizen_sfc.c
new file mode 100644
index 0000000..4eaab32
--- /dev/null
+++ b/EGL/yagl_onscreen_image_tizen_sfc.c
@@ -0,0 +1,122 @@
+/*
+ * YaGL
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact :
+ * Vasily Ulyanov <v.ulyanov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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_onscreen_image_tizen_sfc.h"
+#include "yagl_display.h"
+#include "yagl_log.h"
+#include "yagl_malloc.h"
+#include "yagl_host_egl_calls.h"
+#include "yagl_egl_state.h"
+#include "yagl_state.h"
+#include "yagl_client_interface.h"
+#include "yagl_client_image.h"
+#include "vigs.h"
+#include <tbm_bufmgr.h>
+#include <tbm_bufmgr_backend.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+static void yagl_onscreen_image_tizen_sfc_update(struct yagl_image *image)
+{
+}
+
+static void yagl_onscreen_image_tizen_sfc_destroy(struct yagl_ref *ref)
+{
+ struct yagl_onscreen_image_tizen_sfc *image = (struct yagl_onscreen_image_tizen_sfc *)ref;
+
+ vigs_drm_gem_unref(&image->drm_sfc->gem);
+
+ yagl_image_cleanup(&image->base);
+
+ yagl_free(image);
+}
+
+
+struct yagl_onscreen_image_tizen_sfc
+ *yagl_onscreen_image_tizen_sfc_create(struct yagl_display *dpy,
+ EGLClientBuffer buffer,
+ struct yagl_client_interface *iface)
+{
+ EGLint error = 0;
+ yagl_object_name tex_global_name = yagl_get_global_name();
+ struct yagl_client_image *client_image;
+ struct yagl_onscreen_image_tizen_sfc *image;
+ struct vigs_drm_surface *drm_sfc;
+ tbm_surface_h sfc;
+ tbm_bo bo;
+
+ image = yagl_malloc0(sizeof(*image));
+
+ sfc = (tbm_surface_h)buffer;
+ bo = tbm_surface_internal_get_bo(sfc, 0);
+ drm_sfc = bo ? tbm_backend_get_bo_priv(bo) : NULL;
+
+ if (!drm_sfc || (tbm_surface_internal_get_num_bos(sfc) != 1)) {
+ yagl_set_error(EGL_BAD_PARAMETER);
+ goto fail;
+ }
+
+ vigs_drm_gem_ref(&drm_sfc->gem);
+
+ if (!yagl_host_eglCreateImageYAGL(tex_global_name,
+ dpy->host_dpy,
+ drm_sfc->id,
+ &error)) {
+ yagl_set_error(error);
+ goto fail;
+ }
+
+ client_image = iface->create_image(iface, tex_global_name);
+
+ yagl_image_init(&image->base,
+ &yagl_onscreen_image_tizen_sfc_destroy,
+ dpy,
+ (EGLImageKHR)drm_sfc->gem.name,
+ client_image);
+
+ yagl_client_image_release(client_image);
+
+ image->base.update = &yagl_onscreen_image_tizen_sfc_update;
+ image->drm_sfc = drm_sfc;
+
+ return image;
+
+fail:
+ if (drm_sfc) {
+ vigs_drm_gem_unref(&drm_sfc->gem);
+ }
+
+ yagl_free(image);
+
+ return NULL;
+}
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.h b/EGL/yagl_onscreen_image_tizen_sfc.h
new file mode 100644
index 0000000..d07eb69
--- /dev/null
+++ b/EGL/yagl_onscreen_image_tizen_sfc.h
@@ -0,0 +1,55 @@
+/*
+ * YaGL
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact :
+ * Vasily Ulyanov <v.ulyanov@samsung.com>
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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_ONSCREEN_IMAGE_TIZEN_SFC_H_
+#define _YAGL_ONSCREEN_IMAGE_TIZEN_SFC_H_
+
+#include "yagl_image.h"
+#include "EGL/egl.h"
+
+struct yagl_client_interface;
+struct vigs_drm_surface;
+
+struct yagl_onscreen_image_tizen_sfc
+{
+ struct yagl_image base;
+
+ struct vigs_drm_surface *drm_sfc;
+};
+
+struct yagl_onscreen_image_tizen_sfc
+ *yagl_onscreen_image_tizen_sfc_create(struct yagl_display *dpy,
+ EGLClientBuffer buffer,
+ struct yagl_client_interface *iface);
+
+#endif
diff --git a/packaging/emulator-yagl.spec b/packaging/emulator-yagl.spec
index 2358c41..5b86d8f 100644
--- a/packaging/emulator-yagl.spec
+++ b/packaging/emulator-yagl.spec
@@ -12,6 +12,7 @@ Source0: %{name}-%{version}.tar.gz
Source1001: emulator-yagl.manifest
BuildRequires: cmake
BuildRequires: pkgconfig(libdrm)
+BuildRequires: pkgconfig(libtbm)
BuildRequires: flex
BuildRequires: bison
%if %{with wayland}
@@ -28,6 +29,7 @@ BuildRequires: pkgconfig(xcb)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(dri2proto)
%endif
+Requires: libtbm
Provides: opengl-es-drv
%if !%{with emulator}