diff options
author | Xuelian Bai <xuelian.bai@samsung.com> | 2016-04-29 03:51:31 +0800 |
---|---|---|
committer | Mun, Gwan-gyeong <kk.moon@samsung.com> | 2016-04-29 23:54:16 +0900 |
commit | 3fe0e371ed079a5370f0d42b3dcacad099abd531 (patch) | |
tree | 0407312c15e62d737c5fd7059183dc578c5cd971 | |
parent | 4e11aa32f3d9b1313e9af78c654ed453e1134778 (diff) | |
download | emulator-yagl-3fe0e371ed079a5370f0d42b3dcacad099abd531.tar.gz emulator-yagl-3fe0e371ed079a5370f0d42b3dcacad099abd531.tar.bz2 emulator-yagl-3fe0e371ed079a5370f0d42b3dcacad099abd531.zip |
porting YAGL to TIZEN platformsubmit/tizen/20160502.043551
This patch ports YAGL to TIZEN platform as an
initial version, creates following files:
EGL/tizen/yagl_tizen_display.c
EGL/tizen/yagl_tizen_display.h
EGL/tizen/yagl_tizen_native_image.c
EGL/tizen/yagl_tizen_native_image.h
EGL/tizen/yagl_tizen_pbuffer.c
EGL/tizen/yagl_tizen_pbuffer.h
EGL/tizen/yagl_tizen_platform.c
EGL/tizen/yagl_tizen_platform.h
EGL/tizen/yagl_tizen_window.c
EGL/tizen/yagl_tizen_window.h
Signed-off-by: Xuelian Bai <xuelian.bai@samsung.com>
Change-Id: I639dc736f242096ba417054576453ea941113eea
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | EGL/CMakeLists.txt | 16 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_display.c | 180 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_display.h | 66 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_native_image.c | 135 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_native_image.h | 60 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_pbuffer.c | 199 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_pbuffer.h | 49 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_platform.c | 65 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_platform.h | 43 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_window.c | 288 | ||||
-rw-r--r-- | EGL/tizen/yagl_tizen_window.h | 74 | ||||
-rw-r--r-- | EGL/yagl_backend.h | 8 | ||||
-rw-r--r-- | EGL/yagl_egl_calls.c | 28 | ||||
-rw-r--r-- | EGL/yagl_native_display.c | 121 | ||||
-rw-r--r-- | EGL/yagl_native_display.h | 13 | ||||
-rw-r--r-- | EGL/yagl_native_platform.c | 6 | ||||
-rw-r--r-- | EGL/yagl_offscreen.c | 8 | ||||
-rw-r--r-- | EGL/yagl_onscreen.c | 14 | ||||
-rw-r--r-- | packaging/emulator-yagl.spec | 49 |
20 files changed, 1365 insertions, 62 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b42e86..2f7d7ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,13 +26,14 @@ if (CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) endif () -option(PLATFORM_X11 "Enable X11 platform" TRUE) +option(PLATFORM_TIZEN "Enable Tizen backend" FALSE) +option(PLATFORM_X11 "Enable X11 platform" FALSE) option(PLATFORM_GBM "Enable GBM platform" FALSE) option(PLATFORM_WAYLAND "Enable wayland platform" FALSE) # END USER SETTINGS -if ((NOT PLATFORM_X11) AND (NOT PLATFORM_GBM) AND (NOT PLATFORM_WAYLAND)) +if ((NOT PLATFORM_X11) AND (NOT PLATFORM_GBM) AND (NOT PLATFORM_WAYLAND) AND (NOT PLATFORM_TIZEN)) message(FATAL_ERROR "At least one platform must be supported") endif () diff --git a/EGL/CMakeLists.txt b/EGL/CMakeLists.txt index d42af56..c5f2bb5 100644 --- a/EGL/CMakeLists.txt +++ b/EGL/CMakeLists.txt @@ -100,6 +100,22 @@ if (PLATFORM_WAYLAND) add_definitions(-DYAGL_PLATFORM_WAYLAND) endif () +if (PLATFORM_TIZEN) + set(SOURCES ${SOURCES} + tizen/yagl_tizen_platform.c + tizen/yagl_tizen_display.c + tizen/yagl_tizen_window.c + tizen/yagl_tizen_pbuffer.c + tizen/yagl_tizen_native_image.c + ) + set(LIBRARIES ${LIBRARIES} + wayland-egl + tpl-egl + ${WAYLAND_CLIENT_LIBRARIES} + ) + add_definitions(-DYAGL_PLATFORM_TIZEN) +endif () + include_directories(.) add_library(EGL SHARED ${SOURCES}) diff --git a/EGL/tizen/yagl_tizen_display.c b/EGL/tizen/yagl_tizen_display.c new file mode 100644 index 0000000..b95ac92 --- /dev/null +++ b/EGL/tizen/yagl_tizen_display.c @@ -0,0 +1,180 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_tizen_display.h" +#include "yagl_tizen_window.h" +#include "yagl_tizen_pbuffer.h" +#include <tbm_bufmgr_backend.h> +#include "yagl_log.h" +#include "yagl_malloc.h" +#include "vigs.h" +#include <sys/fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + + + +static int yagl_tizen_display_authenticate(struct yagl_native_display *dpy, + uint32_t id) +{ + return 1; +} + +static struct yagl_native_drawable + *yagl_tizen_display_wrap_window(struct yagl_native_display *dpy, + yagl_os_window os_window) +{ + return yagl_tizen_window_create(dpy, os_window); +} + +static struct yagl_native_drawable + *yagl_tizen_display_wrap_pixmap(struct yagl_native_display *dpy, + yagl_os_pixmap os_pixmap) +{ + return NULL; +} + +static struct yagl_native_drawable + *yagl_tizen_display_create_pixmap(struct yagl_native_display *dpy, + uint32_t width, + uint32_t height, + uint32_t depth) +{ + /* + * Wayland actaully has no pixmap type. This is just for creating + * a pbuffer and to make Tizen conformance tests happy. + */ + return yagl_tizen_pbuffer_create(dpy, width, height, depth); +} + +static struct yagl_native_image + *yagl_tizen_display_create_image(struct yagl_native_display *dpy, + uint32_t width, + uint32_t height, + uint32_t depth) +{ + return NULL; +} + +static int yagl_tizen_display_get_visual(struct yagl_native_display *dpy, + int *visual_id, + int *visual_type) +{ + tpl_display_t *tpl_display = NULL; + tpl_result_t ret; + + YAGL_LOG_FUNC_SET(yagl_tizen_display_get_visual); + + tpl_display = tpl_display_get((tpl_handle_t)dpy->os_dpy); + + + ret = tpl_display_query_config(tpl_display, TPL_SURFACE_TYPE_WINDOW, + 8, 8, 8, 8, 32, + visual_id, NULL); + if (ret != TPL_ERROR_NONE) { + YAGL_LOG_ERROR("query error"); + } + + *visual_type = 0; + + return 1; +} + +static void yagl_tizen_display_update_wl_server(struct yagl_native_display *dpy) +{ + return ; +} + +static void yagl_tizen_display_destroy(struct yagl_native_display *dpy) +{ + struct yagl_tizen_display *tizen_dpy = (struct yagl_tizen_display *)dpy; + if (tizen_dpy->tpl_display != NULL) { + tpl_object_unreference((tpl_object_t *)tizen_dpy->tpl_display); + } + + yagl_native_display_cleanup(dpy); + + yagl_free(dpy); +} + +struct yagl_native_display + *yagl_tizen_display_create(struct yagl_native_platform *platform, + yagl_os_display os_dpy) +{ + struct yagl_tizen_display *dpy; + tbm_bufmgr bufmgr; + struct vigs_drm_device *drm_dev = NULL; + + YAGL_LOG_FUNC_ENTER(yagl_tizen_display_create, "os_dpy = %p", os_dpy); + + dpy = yagl_malloc0(sizeof(*dpy)); + + dpy->drm_fd = -1; + + dpy->tpl_display = tpl_display_create(TPL_BACKEND_UNKNOWN, (tpl_handle_t)os_dpy); + + if (!dpy->tpl_display) { + YAGL_LOG_ERROR("Failed to tpl_display"); + goto fail; + } + + bufmgr = tbm_bufmgr_init(-1); + drm_dev = (struct vigs_drm_device *)tbm_backend_get_priv_from_bufmgr(bufmgr); + + yagl_native_display_init(&dpy->base, + platform, + os_dpy, + drm_dev, + NULL); + dpy->base.authenticate = &yagl_tizen_display_authenticate; + dpy->base.wrap_window = &yagl_tizen_display_wrap_window; + dpy->base.wrap_pixmap = &yagl_tizen_display_wrap_pixmap; + dpy->base.create_pixmap = &yagl_tizen_display_create_pixmap; + dpy->base.create_image = &yagl_tizen_display_create_image; + dpy->base.get_visual = &yagl_tizen_display_get_visual; + dpy->base.update_wl_server = &yagl_tizen_display_update_wl_server; + dpy->base.destroy = &yagl_tizen_display_destroy; + + YAGL_LOG_FUNC_EXIT("display %p created", dpy); + + return &dpy->base; + +fail: + yagl_free(dpy); + + YAGL_LOG_FUNC_EXIT(NULL); + + return NULL; +} diff --git a/EGL/tizen/yagl_tizen_display.h b/EGL/tizen/yagl_tizen_display.h new file mode 100644 index 0000000..be54ec7 --- /dev/null +++ b/EGL/tizen/yagl_tizen_display.h @@ -0,0 +1,66 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_TIZEN_DISPLAY_H_ +#define _YAGL_TIZEN_DISPLAY_H_ + +#include "yagl_export.h" +#include "yagl_native_display.h" +#include <tpl.h> + + +struct wl_drm; + +struct yagl_tizen_display +{ + struct yagl_native_display base; + + int own_dpy; + + tpl_display_t *tpl_display; + + struct wl_drm *wl_drm; + + char *drm_dev_name; + + int drm_fd; + + int authenticated; +}; + +struct yagl_native_display + *yagl_tizen_display_create(struct yagl_native_platform *platform, + yagl_os_display os_dpy); + + +#endif diff --git a/EGL/tizen/yagl_tizen_native_image.c b/EGL/tizen/yagl_tizen_native_image.c new file mode 100644 index 0000000..52157d5 --- /dev/null +++ b/EGL/tizen/yagl_tizen_native_image.c @@ -0,0 +1,135 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_log.h" +#include "yagl_malloc.h" +#include "yagl_display.h" +#include "yagl_tizen_native_image.h" +#include "yagl_state.h" +#include "yagl_egl_state.h" +#include "yagl_client_image.h" +#include "yagl_host_egl_calls.h" +#include "vigs.h" +#include <errno.h> +#include <tbm_surface.h> +#include <tbm_surface_internal.h> +#include <tpl.h> +#include <tbm_bufmgr_backend.h> + +static void yagl_onscreen_image_tizen_update(struct yagl_image *image) +{ +} + +static void yagl_onscreen_image_tizen_destroy(struct yagl_ref *ref) +{ + struct yagl_onscreen_image_tizen *image = (struct yagl_onscreen_image_tizen*)ref; + + if (image->buffer) + tbm_surface_internal_unref(image->buffer); + + yagl_image_cleanup(&image->base); + + yagl_free(image); +} + + +struct yagl_onscreen_image_tizen + *yagl_onscreen_image_tizen_create(struct yagl_display *dpy, + EGLClientBuffer pixmap, + struct yagl_client_interface *iface) +{ + EGLint error = 0; + tpl_display_t *tpl_display; + tbm_surface_h tbm_surface; + tbm_bo bo; + yagl_object_name tex_global_name = yagl_get_global_name(); + struct yagl_client_image *client_image; + struct yagl_onscreen_image_tizen *image; + struct vigs_drm_surface *drm_sfc; + + YAGL_LOG_FUNC_SET(yagl_onscreen_image_tizen_create); + image = yagl_malloc0(sizeof(*image)); + + tpl_display = tpl_display_get((tpl_handle_t)dpy->display_id); + if (tpl_display == NULL) { + yagl_set_error(EGL_BAD_DISPLAY); + YAGL_LOG_ERROR("tpl_display is NULL"); + goto fail; + } + + /* Get native buffer from pixmap */ + tbm_surface = tpl_display_get_buffer_from_native_pixmap(tpl_display, pixmap); + + if (tbm_surface == NULL) { + yagl_set_error(EGL_BAD_NATIVE_PIXMAP); + YAGL_LOG_ERROR("tbm_surface is NULL"); + goto fail; + } + tbm_surface_internal_ref(tbm_surface); + + bo = tbm_surface_internal_get_bo(tbm_surface, 0); + drm_sfc = (struct vigs_drm_surface *)tbm_backend_get_bo_priv(bo); + if (vigs_drm_gem_get_name(&drm_sfc->gem)) { + yagl_set_error(EGL_BAD_NATIVE_PIXMAP); + YAGL_LOG_ERROR("get gem name failed"); + goto fail; + } + 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_destroy, + dpy, + (EGLImageKHR)INT2VOIDP(drm_sfc->gem.name), + client_image); + + yagl_client_image_release(client_image); + + image->base.update = &yagl_onscreen_image_tizen_update; + + image->buffer = tbm_surface; + + return image; + +fail: + yagl_free(image); + + return NULL; +} diff --git a/EGL/tizen/yagl_tizen_native_image.h b/EGL/tizen/yagl_tizen_native_image.h new file mode 100644 index 0000000..31a1fa4 --- /dev/null +++ b/EGL/tizen/yagl_tizen_native_image.h @@ -0,0 +1,60 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_TIZEN_NATIVE_IMAGE_H_ +#define _YAGL_TIZEN_NATIVE_IMAGE_H_ + + +#include "yagl_types.h" +#include "yagl_image.h" +#include "yagl_export.h" +#include "yagl_native_drawable.h" +#include "yagl_client_interface.h" +#include "yagl_image.h" +#include "EGL/egl.h" +#include <tbm_surface.h> + +struct yagl_onscreen_image_tizen +{ + struct yagl_image base; + + tbm_surface_h buffer; +}; + +struct yagl_onscreen_image_tizen + *yagl_onscreen_image_tizen_create(struct yagl_display *dpy, + EGLClientBuffer pixmap, + struct yagl_client_interface *iface); + + +#endif diff --git a/EGL/tizen/yagl_tizen_pbuffer.c b/EGL/tizen/yagl_tizen_pbuffer.c new file mode 100644 index 0000000..68f386a --- /dev/null +++ b/EGL/tizen/yagl_tizen_pbuffer.c @@ -0,0 +1,199 @@ +/* + * 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_tizen_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> + +/* This file is almost the same as wayland backend, not necessary to call tpl */ + +#define YAGL_TIZEN_PBUFFER(os_pbuffer) ((struct vigs_drm_surface *)(os_pbuffer)) + +static int yagl_tizen_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_TIZEN_PBUFFER(drawable->os_drawable); + + YAGL_LOG_FUNC_SET(yagl_tizen_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_tizen_pbuffer_get_buffer_age(struct yagl_native_drawable *drawable) +{ + return 0; +} + +static void yagl_tizen_pbuffer_swap_buffers(struct yagl_native_drawable *drawable) +{ +} + +static void yagl_tizen_pbuffer_wait(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ +} + +static void yagl_tizen_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_tizen_pbuffer_set_swap_interval(struct yagl_native_drawable *drawable, + int interval) +{ +} + +static void yagl_tizen_pbuffer_get_geometry(struct yagl_native_drawable *drawable, + uint32_t *width, + uint32_t *height, + uint32_t *depth) +{ + struct vigs_drm_surface *drm_sfc = YAGL_TIZEN_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_tizen_pbuffer_get_image(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ + return NULL; +} + +static void yagl_tizen_pbuffer_destroy(struct yagl_native_drawable *drawable) +{ + struct vigs_drm_surface *drm_sfc = YAGL_TIZEN_PBUFFER(drawable->os_drawable); + + vigs_drm_gem_unref(&drm_sfc->gem); + + yagl_native_drawable_cleanup(drawable); + + yagl_free(drawable); +} + +struct yagl_native_drawable + *yagl_tizen_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_tizen_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_tizen_pbuffer_get_buffer; + pbuffer->get_buffer_age = &yagl_tizen_pbuffer_get_buffer_age; + pbuffer->swap_buffers = &yagl_tizen_pbuffer_swap_buffers; + pbuffer->wait = &yagl_tizen_pbuffer_wait; + pbuffer->copy_to_pixmap = &yagl_tizen_pbuffer_copy_to_pixmap; + pbuffer->set_swap_interval = &yagl_tizen_pbuffer_set_swap_interval; + pbuffer->get_geometry = &yagl_tizen_pbuffer_get_geometry; + pbuffer->get_image = &yagl_tizen_pbuffer_get_image; + pbuffer->destroy = &yagl_tizen_pbuffer_destroy; + + return pbuffer; +} diff --git a/EGL/tizen/yagl_tizen_pbuffer.h b/EGL/tizen/yagl_tizen_pbuffer.h new file mode 100644 index 0000000..fe1fad4 --- /dev/null +++ b/EGL/tizen/yagl_tizen_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_TIZEN_PBUFFER_H_ +#define _YAGL_TIZEN_PBUFFER_H_ + +#include "yagl_export.h" +#include "yagl_native_types.h" + +struct yagl_native_display; +struct yagl_native_drawable; + +struct yagl_native_drawable + *yagl_tizen_pbuffer_create(struct yagl_native_display *dpy, + uint32_t width, + uint32_t height, + uint32_t depth); + +#endif /* _YAGL_TIZEN_PBUFFER_H_ */ diff --git a/EGL/tizen/yagl_tizen_platform.c b/EGL/tizen/yagl_tizen_platform.c new file mode 100644 index 0000000..a35f55e --- /dev/null +++ b/EGL/tizen/yagl_tizen_platform.c @@ -0,0 +1,65 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_tizen_platform.h" +#include "yagl_tizen_display.h" +#include "yagl_native_platform.h" +#include "yagl_log.h" +#include "EGL/egl.h" + +static int yagl_tizen_platform_probe(yagl_os_display os_dpy) +{ + /* Don't need to do anything */ + return 1; +} + +static struct yagl_native_display + *yagl_tizen_wrap_display(yagl_os_display os_dpy, + int enable_drm) +{ + struct yagl_native_display *dpy = NULL; + + YAGL_LOG_FUNC_SET(eglGetDisplay); + + dpy = yagl_tizen_display_create(&yagl_tizen_platform,os_dpy); + + return dpy; +} + +struct yagl_native_platform yagl_tizen_platform = +{ + .pixmaps_supported = 0, + .buffer_age_supported = 1, + .probe = yagl_tizen_platform_probe, + .wrap_display = yagl_tizen_wrap_display +}; diff --git a/EGL/tizen/yagl_tizen_platform.h b/EGL/tizen/yagl_tizen_platform.h new file mode 100644 index 0000000..2dac072 --- /dev/null +++ b/EGL/tizen/yagl_tizen_platform.h @@ -0,0 +1,43 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_TIZEN_PLATFORM_H_ +#define _YAGL_TIZEN_PLATFORM_H_ + +#include "yagl_export.h" + +struct yagl_native_platform; + +extern struct yagl_native_platform yagl_tizen_platform; + +#endif diff --git a/EGL/tizen/yagl_tizen_window.c b/EGL/tizen/yagl_tizen_window.c new file mode 100644 index 0000000..3524f8a --- /dev/null +++ b/EGL/tizen/yagl_tizen_window.c @@ -0,0 +1,288 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_tizen_window.h" +#include "yagl_tizen_display.h" +#include "yagl_log.h" +#include "yagl_malloc.h" +#include <tbm_bufmgr_backend.h> +#include "vigs.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + + +static int yagl_tizen_window_get_buffer(struct yagl_native_drawable *drawable, + yagl_native_attachment attachment, + uint32_t *buffer_name, + struct vigs_drm_surface **buffer_sfc) +{ + struct yagl_tizen_window *window = (struct yagl_tizen_window*)drawable; + int width, height; + tbm_bo bo; + tbm_surface_h tbm_surface; + int i; + + YAGL_LOG_FUNC_SET(yagl_tizen_window_get_buffer); + + switch (attachment) { + case yagl_native_attachment_back: + break; + case yagl_native_attachment_front: + default: + YAGL_LOG_ERROR("Bad attachment %u", attachment); + return 0; + } + + tbm_surface = tpl_surface_dequeue_buffer(window->surface); + if (tbm_surface == NULL) { + YAGL_LOG_ERROR("can't get buffer for %p", window->surface); + return 0; + } + YAGL_LOG_INFO("get buffer %p for %p", tbm_surface, window->surface); + tbm_surface_internal_ref(tbm_surface); + width = tbm_surface_get_width(tbm_surface); + height = tbm_surface_get_height(tbm_surface); + + if ((window->width != width) || + (window->height != height)) { + for (i = 0; i < YAGL_TIZEN_MAX_COLOR_BUF; i++) { + if (window->color_buffers[i].locked && window->back != &window->color_buffers[i]) { + /* + * Buffer is locked and it's not a back buffer. + */ + continue; + } + if(window->color_buffers[i].data) { + tbm_surface_internal_unref(window->color_buffers[i].data); + window->color_buffers[i].data = NULL; + } + if (window->back == &window->color_buffers[i]) { + /* + * If it's a back buffer and the window was resized + * then we MUST destroy it and create a new one + * later. + * + * Otherwise, we'll get very obscure resizing bugs. + */ + window->color_buffers[i].locked = 0; + window->back = NULL; + } + } + + window->width = width; + window->height = height; + } + + if (!window->back) { + int cur; + for (i = 1; i <= YAGL_TIZEN_MAX_COLOR_BUF;i++) { + cur = (i + window->current_buf >= YAGL_TIZEN_MAX_COLOR_BUF) ? + (i + window->current_buf)%YAGL_TIZEN_MAX_COLOR_BUF : i + window->current_buf; + + if (window->color_buffers[cur].locked) { + continue; + } + if (!window->back || !window->back->data) { + window->back = &window->color_buffers[cur]; + window->current_buf = cur; + } + } + } + + if (!window->back) { + return 0; + } + + bo = tbm_surface_internal_get_bo(tbm_surface, 0); + + if (buffer_sfc != NULL) { + *buffer_sfc = (struct vigs_drm_surface *)tbm_backend_get_bo_priv(bo); + + if (vigs_drm_gem_get_name(&(*buffer_sfc)->gem)) + YAGL_LOG_ERROR("%s: get gem name failed\n", __func__); + + vigs_drm_gem_ref(&(*buffer_sfc)->gem); + + if (buffer_name) + *buffer_name = (*buffer_sfc)->gem.name; + } + + window->back->age = 0; + window->back->locked = 1; + window->back->data = (void *)tbm_surface; + + return 1; +} + +static int yagl_tizen_window_get_buffer_age(struct yagl_native_drawable *drawable) +{ + struct yagl_tizen_window *window = (struct yagl_tizen_window*)drawable; + + YAGL_LOG_FUNC_SET(yagl_tizen_window_get_buffer_age); + + return window->back->age; +} + +static void yagl_tizen_window_swap_buffers(struct yagl_native_drawable *drawable) +{ + struct yagl_tizen_window *window = (struct yagl_tizen_window*)drawable; + tpl_result_t ret = TPL_ERROR_INVALID_OPERATION; + int i; + + YAGL_LOG_FUNC_SET(yagl_tizen_window_swap_buffers); + + for (i = 0; i < YAGL_TIZEN_MAX_COLOR_BUF; ++i) { + if (window->color_buffers[i].age > 0) { + ++window->color_buffers[i].age; + } + } + + /* + * Make sure we have a back buffer in case we're swapping without ever + * rendering. + */ + if (!window->back || !window->back->data) { + yagl_tizen_window_get_buffer(drawable, yagl_native_attachment_back, NULL, NULL); + if (!window->back || !window->back->data) { + YAGL_LOG_ERROR("Cannot lock back for egl_window %p\n", window); + return; + } + } + + ret = tpl_surface_enqueue_buffer(window->surface, window->back->data); + if (ret != TPL_ERROR_NONE) + YAGL_LOG_ERROR("post failed\n"); + + window->back->age = 1; + window->back->locked = 0; + tbm_surface_internal_unref(window->back->data); + window->back->data = NULL; + window->back = NULL; + + ++drawable->stamp; +} + +static void yagl_tizen_window_wait(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ +} + +static void yagl_tizen_window_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_tizen_window_set_swap_interval(struct yagl_native_drawable *drawable, + int interval) +{ +} + +static void yagl_tizen_window_get_geometry(struct yagl_native_drawable *drawable, + uint32_t *width, + uint32_t *height, + uint32_t *depth) +{ +} + +static struct yagl_native_image + *yagl_tizen_window_get_image(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ + return NULL; +} + +static void yagl_tizen_window_destroy(struct yagl_native_drawable *drawable) +{ + struct yagl_tizen_window *window = (struct yagl_tizen_window *)drawable; + + yagl_native_drawable_cleanup(drawable); + + window->user_data = NULL; + + /* Destroy TPL surface. */ + if (window->surface) + tpl_object_unreference((tpl_object_t *)window->surface); + + yagl_free(drawable); +} + +struct yagl_native_drawable + *yagl_tizen_window_create(struct yagl_native_display *dpy, + yagl_os_window os_window) +{ + struct yagl_tizen_window *window; + tpl_display_t *tpl_display = NULL; + tpl_surface_t *tpl_surface = NULL; + + YAGL_LOG_FUNC_SET(yagl_tizen_window_create); + + window = yagl_malloc0(sizeof(*window)); + + yagl_native_drawable_init(&window->base, dpy, os_window); + + tpl_display = tpl_display_get((tpl_handle_t)dpy->os_dpy); + tpl_surface = tpl_surface_create(tpl_display, + (tpl_handle_t)os_window, + TPL_SURFACE_TYPE_WINDOW, + TBM_FORMAT_ARGB8888); + window->base.get_buffer = &yagl_tizen_window_get_buffer; + window->base.get_buffer_age = &yagl_tizen_window_get_buffer_age; + window->base.swap_buffers = &yagl_tizen_window_swap_buffers; + window->base.wait = &yagl_tizen_window_wait; + window->base.copy_to_pixmap = &yagl_tizen_window_copy_to_pixmap; + window->base.set_swap_interval = &yagl_tizen_window_set_swap_interval; + window->base.get_geometry = &yagl_tizen_window_get_geometry; + window->base.get_image = &yagl_tizen_window_get_image; + window->base.destroy = &yagl_tizen_window_destroy; + + /* + * First comparison against real window + * dimensions must always fail. + */ + window->width = -1; + window->height = -1; + window->current_buf = 0; + window->surface = tpl_surface; + + return &window->base; +} diff --git a/EGL/tizen/yagl_tizen_window.h b/EGL/tizen/yagl_tizen_window.h new file mode 100644 index 0000000..2e6d950 --- /dev/null +++ b/EGL/tizen/yagl_tizen_window.h @@ -0,0 +1,74 @@ +/* + * YaGL + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact : + * Stanislav Vorobiov <s.vorobiov@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_TIZEN_WINDOW_H_ +#define _YAGL_TIZEN_WINDOW_H_ + +#include "yagl_export.h" +#include "yagl_native_drawable.h" +#include <tpl.h> +#include <tbm_surface.h> +#include <tbm_surface_internal.h> + +#define YAGL_TIZEN_MAX_COLOR_BUF 3 + +struct vigs_drm_surface; + +struct yagl_tizen_window +{ + struct yagl_native_drawable base; + + struct + { + void *data; + int locked; + int age; + } color_buffers[YAGL_TIZEN_MAX_COLOR_BUF], *back; + + int current_buf; + + int width; + int height; + + tpl_surface_t *surface; + void *user_data; + + struct wl_callback *frame_callback; +}; + +struct yagl_native_drawable + *yagl_tizen_window_create(struct yagl_native_display *dpy, + yagl_os_window os_window); + + +#endif diff --git a/EGL/yagl_backend.h b/EGL/yagl_backend.h index c845109..7ad034d 100644 --- a/EGL/yagl_backend.h +++ b/EGL/yagl_backend.h @@ -81,8 +81,12 @@ struct yagl_backend struct yagl_native_drawable */*native_pixmap*/, struct yagl_client_interface */*iface*/); - struct yagl_image *(*create_image_wl_buffer)(struct yagl_display */*dpy*/, - struct wl_resource */*buffer*/, + struct yagl_image *(*create_image_wl_buffer)(struct yagl_display *dpy, +#ifdef YAGL_PLATFORM_WAYLAND + struct wl_resource *buffer, +#elif YAGL_PLATFORM_TIZEN + EGLClientBuffer pixmap, +#endif struct yagl_client_interface */*iface*/); struct yagl_image *(*create_image_gl_texture_2d)(struct yagl_display */*dpy*/, diff --git a/EGL/yagl_egl_calls.c b/EGL/yagl_egl_calls.c index ee01410..360eaab 100644 --- a/EGL/yagl_egl_calls.c +++ b/EGL/yagl_egl_calls.c @@ -1729,10 +1729,15 @@ YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_, i += 2; } } - +#ifdef YAGL_PLATFORM_WAYLAND image = yagl_get_backend()->create_image_wl_buffer(dpy, (struct wl_resource*)buffer, iface); +#elif YAGL_PLATFORM_TIZEN + image = yagl_get_backend()->create_image_wl_buffer(dpy, + buffer, + iface); +#endif if (!image) { goto out; @@ -2117,10 +2122,11 @@ out: return res; } + #ifdef YAGL_PLATFORM_WAYLAND struct wl_display; struct wl_resource; - +#endif YAGL_API EGLBoolean eglBindWaylandDisplayWL(EGLDisplay dpy_, struct wl_display *display) { @@ -2146,7 +2152,11 @@ YAGL_API EGLBoolean eglBindWaylandDisplayWL(EGLDisplay dpy_, goto out; } +#ifdef YAGL_PLATFORM_WAYLAND res = yagl_native_display_bind_wl_display(dpy->native_dpy, display); +#elif YAGL_PLATFORM_TIZEN + res = yagl_native_display_bind_wl_display(dpy->display_id); +#endif out: YAGL_LOG_FUNC_EXIT("%d", res); @@ -2179,7 +2189,12 @@ YAGL_API EGLBoolean eglUnbindWaylandDisplayWL(EGLDisplay dpy_, goto out; } +#ifdef YAGL_PLATFORM_WAYLAND res = yagl_native_display_unbind_wl_display(dpy->native_dpy); +#elif YAGL_PLATFORM_TIZEN + res = yagl_native_display_unbind_wl_display(dpy->display_id); +#endif + out: YAGL_LOG_FUNC_EXIT("%d", res); @@ -2215,17 +2230,24 @@ YAGL_API EGLBoolean eglQueryWaylandBufferWL(EGLDisplay dpy_, goto out; } +#ifdef YAGL_PLATFORM_WAYLAND res = yagl_native_display_query_wl_buffer(dpy->native_dpy, buffer, attribute, value); +#elif YAGL_PLATFORM_TIZEN + res = yagl_native_display_query_wl_buffer(dpy->display_id, + buffer, + attribute, + value); +#endif + out: YAGL_LOG_FUNC_EXIT("%d", res); return res; } -#endif YAGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* procname) { diff --git a/EGL/yagl_native_display.c b/EGL/yagl_native_display.c index 78216e2..7af9d92 100644 --- a/EGL/yagl_native_display.c +++ b/EGL/yagl_native_display.c @@ -37,6 +37,9 @@ #ifdef YAGL_PLATFORM_WAYLAND #include "wayland-drm.h" #endif +#ifdef YAGL_PLATFORM_TIZEN +#include <tpl.h> +#endif #include "vigs.h" #include "EGL/eglext.h" #include "EGL/eglmesaext.h" @@ -52,13 +55,15 @@ void yagl_native_display_init(struct yagl_native_display *dpy, dpy->platform = platform; dpy->os_dpy = os_dpy; dpy->drm_dev = drm_dev; - if (drm_dev) { + if (drm_dev && drm_dev_name) { dpy->drm_dev_name = strdup(drm_dev_name); } else { dpy->drm_dev_name = NULL; } #ifdef YAGL_PLATFORM_WAYLAND dpy->WL_bind_wayland_display_supported = (drm_dev ? 1 : 0); +#elif YAGL_PLATFORM_TIZEN + dpy->WL_bind_wayland_display_supported = (drm_dev ? 1 : 0); #else dpy->WL_bind_wayland_display_supported = 0; #endif @@ -67,7 +72,8 @@ void yagl_native_display_init(struct yagl_native_display *dpy, void yagl_native_display_cleanup(struct yagl_native_display *dpy) { dpy->drm_dev = NULL; - free(dpy->drm_dev_name); + if (dpy->drm_dev_name) + free(dpy->drm_dev_name); dpy->drm_dev_name = NULL; } @@ -154,31 +160,104 @@ int yagl_native_display_query_wl_buffer(struct yagl_native_display *dpy, drm_sfc = wayland_drm_buffer_get_sfc(drm_buffer); switch (attribute) { - case EGL_TEXTURE_FORMAT: - switch (drm_sfc->format) { - case vigs_drm_surface_bgrx8888: - *value = EGL_TEXTURE_RGB; + case EGL_TEXTURE_FORMAT: + switch (drm_sfc->format) { + case vigs_drm_surface_bgrx8888: + *value = EGL_TEXTURE_RGB; + break; + case vigs_drm_surface_bgra8888: + *value = EGL_TEXTURE_RGBA; + break; + default: + return 0; + } + break; + case EGL_WIDTH: + *value = drm_sfc->width; break; - case vigs_drm_surface_bgra8888: - *value = EGL_TEXTURE_RGBA; + case EGL_HEIGHT: + *value = drm_sfc->height; + break; + case EGL_WAYLAND_Y_INVERTED_WL: + *value = yagl_get_backend()->y_inverted; break; default: - return 0; - } - break; - case EGL_WIDTH: - *value = drm_sfc->width; - break; - case EGL_HEIGHT: - *value = drm_sfc->height; - break; - case EGL_WAYLAND_Y_INVERTED_WL: - *value = yagl_get_backend()->y_inverted; - break; - default: return 0; } return 1; } #endif + +#ifdef YAGL_PLATFORM_TIZEN +int yagl_native_display_bind_wl_display(yagl_os_display dpy) +{ + tpl_display_t *tpl_display = tpl_display_get((tpl_handle_t)dpy); + + if (tpl_display) + return EGL_TRUE; + else + return EGL_FALSE; +} + +int yagl_native_display_unbind_wl_display(yagl_os_display dpy) +{ + tpl_display_t *tpl_display = tpl_display_get((tpl_handle_t)dpy); + + if (tpl_display) + return EGL_TRUE; + else + return EGL_TRUE; +} + +int yagl_native_display_query_wl_buffer(yagl_os_display dpy, + struct wl_resource *buffer, + EGLint attribute, + EGLint *value) +{ + tpl_display_t *tpl_display = tpl_display_get((tpl_handle_t)dpy); + tbm_format format = 0; + tpl_result_t ret; + int width = 0, height = 0; + + YAGL_LOG_FUNC_SET(yagl_native_display_query_wl_buffer); + if ( (ret=tpl_display_get_native_pixmap_info(tpl_display, + (tpl_handle_t)buffer, &width, &height, &format)) != TPL_ERROR_NONE ) + { + YAGL_LOG_ERROR("get pixmap info failed"); + return 0; + } + + switch (attribute) { + case EGL_TEXTURE_FORMAT: + switch (format) { + case TBM_FORMAT_ARGB8888: + case TBM_FORMAT_BGRA8888: + *value = EGL_TEXTURE_RGBA; + break; + case TBM_FORMAT_XRGB8888: + case TBM_FORMAT_BGRX8888: + case TBM_FORMAT_RGB565: + *value = EGL_TEXTURE_RGB; + break; + + default: + return 0; + } + break; + case EGL_WIDTH: + *value = width; + break; + case EGL_HEIGHT: + *value = height; + break; + case EGL_WAYLAND_Y_INVERTED_WL: + *value = yagl_get_backend()->y_inverted; + break; + default: + return 0; + } + + return 1; +} +#endif diff --git a/EGL/yagl_native_display.h b/EGL/yagl_native_display.h index ed87000..9221c43 100644 --- a/EGL/yagl_native_display.h +++ b/EGL/yagl_native_display.h @@ -49,6 +49,10 @@ struct wl_resource; struct wl_drm; #endif +#ifdef YAGL_PLATFORM_TIZEN +struct wl_resource; +#endif + struct yagl_native_display { struct yagl_native_platform *platform; @@ -102,13 +106,20 @@ void yagl_native_display_cleanup(struct yagl_native_display *dpy); #ifdef YAGL_PLATFORM_WAYLAND int yagl_native_display_bind_wl_display(struct yagl_native_display *dpy, struct wl_display *wl_dpy); - int yagl_native_display_unbind_wl_display(struct yagl_native_display *dpy); int yagl_native_display_query_wl_buffer(struct yagl_native_display *dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#elif YAGL_PLATFORM_TIZEN +int yagl_native_display_bind_wl_display(yagl_os_display dpy); +int yagl_native_display_unbind_wl_display(yagl_os_display dpy); +int yagl_native_display_query_wl_buffer(yagl_os_display dpy, + struct wl_resource *buffer, + EGLint attribute, + EGLint *value); + #endif #endif diff --git a/EGL/yagl_native_platform.c b/EGL/yagl_native_platform.c index 06833b4..66ca436 100644 --- a/EGL/yagl_native_platform.c +++ b/EGL/yagl_native_platform.c @@ -41,6 +41,9 @@ #ifdef YAGL_PLATFORM_WAYLAND #include "wayland/yagl_wayland_platform.h" #endif +#ifdef YAGL_PLATFORM_TIZEN +#include "tizen/yagl_tizen_platform.h" +#endif #include "yagl_log.h" #include <stdlib.h> #include <string.h> @@ -51,6 +54,9 @@ static struct const char *name; } g_platforms[] = { +#ifdef YAGL_PLATFORM_TIZEN + {&yagl_tizen_platform, "wayland"}, +#endif #ifdef YAGL_PLATFORM_WAYLAND {&yagl_wayland_platform, "wayland"}, #endif diff --git a/EGL/yagl_offscreen.c b/EGL/yagl_offscreen.c index 5adadf0..4a271a5 100644 --- a/EGL/yagl_offscreen.c +++ b/EGL/yagl_offscreen.c @@ -128,8 +128,12 @@ static struct yagl_image static struct yagl_image *yagl_offscreen_create_image_wl_buffer(struct yagl_display *dpy, - struct wl_resource *buffer, - struct yagl_client_interface *iface) +#ifdef YAGL_PLATFORM_WAYLAND + struct wl_resource *buffer, +#elif YAGL_PLATFORM_TIZEN + EGLClientBuffer pixmap, +#endif + struct yagl_client_interface *iface) { return NULL; } diff --git a/EGL/yagl_onscreen.c b/EGL/yagl_onscreen.c index 7ad8d06..38f0e3a 100644 --- a/EGL/yagl_onscreen.c +++ b/EGL/yagl_onscreen.c @@ -37,6 +37,9 @@ #ifdef YAGL_PLATFORM_WAYLAND #include "yagl_onscreen_image_wl_buffer.h" #endif +#ifdef YAGL_PLATFORM_TIZEN +#include "tizen/yagl_tizen_native_image.h" +#endif #include "yagl_onscreen_image_gl_texture_2d.h" #include "yagl_onscreen_image_tizen_sfc.h" #include "yagl_onscreen_fence.h" @@ -134,8 +137,12 @@ static struct yagl_image static struct yagl_image *yagl_onscreen_create_image_wl_buffer(struct yagl_display *dpy, - struct wl_resource *buffer, - struct yagl_client_interface *iface) +#ifdef YAGL_PLATFORM_WAYLAND + struct wl_resource *buffer, +#elif YAGL_PLATFORM_TIZEN + EGLClientBuffer pixmap, +#endif + struct yagl_client_interface *iface) { #ifdef YAGL_PLATFORM_WAYLAND struct yagl_onscreen_image_wl_buffer *image = @@ -144,6 +151,9 @@ static struct yagl_image iface); return image ? &image->base : NULL; +#elif YAGL_PLATFORM_TIZEN + struct yagl_onscreen_image_tizen *image = yagl_onscreen_image_tizen_create(dpy, pixmap, iface); + return image ? &image->base : NULL; #else return NULL; #endif diff --git a/packaging/emulator-yagl.spec b/packaging/emulator-yagl.spec index 9a909ab..e9f7846 100644 --- a/packaging/emulator-yagl.spec +++ b/packaging/emulator-yagl.spec @@ -1,5 +1,6 @@ -%bcond_with wayland -%bcond_with emulator +#%bcond_with wayland +#%bcond_with emulator +%define ENABLE_TIZEN_BACKEND 1 Name: emulator-yagl Summary: YaGL - OpenGLES acceleration module for emulator @@ -13,19 +14,17 @@ BuildRequires: cmake BuildRequires: flex BuildRequires: bison BuildRequires: pkgconfig(libdrm) +%if "%{ENABLE_TIZEN_BACKEND}" == "1" BuildRequires: pkgconfig(libtbm) +BuildRequires: pkgconfig(tpl-egl) +BuildRequires: pkgconfig(wayland-egl) +%endif BuildRequires: pkgconfig(gbm) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(wayland-server) Provides: opengl-es-drv -%if %{with emulator} -ExclusiveArch: %{ix86} x86_64 -%else -ExclusiveArch: -%endif - %description YaGL - OpenGLES acceleration module for emulator. This package contains shared libraries libEGL, libGLES_CM, libGLESv2. @@ -37,7 +36,7 @@ Requires: %{name} = %{version}-%{release} %description devel YaGL - OpenGLES acceleration module for emulator (devel) -%if %{with wayland} +%if "%{ENABLE_TIZEN_BACKEND}" == "0" %package -n libwayland-egl Summary: Wayland EGL backend @@ -56,7 +55,11 @@ Development files for use with Wayland protocol %build cp %{SOURCE1001} . -cmake -DCMAKE_INSTALL_PREFIX=%{buildroot} -DINSTALL_LIB_DIR=%{buildroot}%{_libdir} -DPLATFORM_X11=0 -DPLATFORM_GBM=1 -DPLATFORM_WAYLAND=1 +%if "%{ENABLE_TIZEN_BACKEND}" == "1" +cmake -DCMAKE_INSTALL_PREFIX=%{buildroot} -DINSTALL_LIB_DIR=%{buildroot}%{_libdir} -DPLATFORM_TIZEN=1 +%else +cmake -DCMAKE_INSTALL_PREFIX=%{buildroot} -DINSTALL_LIB_DIR=%{buildroot}%{_libdir} -DPLATFORM_X11=0 -DPLATFORM_GBM=0 -DPLATFORM_WAYLAND=1 +%endif make %install @@ -67,38 +70,26 @@ mkdir -p %{buildroot}%{_libdir}/pkgconfig make install +%if "%{ENABLE_TIZEN_BACKEND}" == "0" cp pkgconfig/wayland-egl.pc %{buildroot}%{_libdir}/pkgconfig/ - -%if %{with wayland} -ln -sf driver/libGLESv1_CM.so.1.0 %{buildroot}%{_libdir}/libGLESv1_CM.so.1.0 +%post -n libwayland-egl -p /sbin/ldconfig +%postun -n libwayland-egl -p /sbin/ldconfig %endif +ln -sf driver/libGLESv1_CM.so.1.0 %{buildroot}%{_libdir}/libGLESv1_CM.so.1.1 + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig -%if %{with wayland} -%post -n libwayland-egl -p /sbin/ldconfig -%postun -n libwayland-egl -p /sbin/ldconfig -%endif - %files %manifest %{name}.manifest %license COPYING %defattr(-,root,root,-) -%if %{with wayland} -%{_libdir}/libgbm* %{_libdir}/driver/libEGL* %{_libdir}/driver/libGL* -%{_libdir}/libGLESv1_CM.so.1.0 -%else -%{_libdir}/libEGL* -%{_libdir}/libGLES* -%{_libdir}/yagl/* -%{_libdir}/dummy-gl/* -%attr(777,root,root)/etc/emulator/opengl-es-setup-yagl-env.sh -%endif +%{_libdir}/libGLESv1_CM.so.1.1 -%if %{with wayland} +%if "%{ENABLE_TIZEN_BACKEND}" == "0" %files -n libwayland-egl %manifest %{name}.manifest %license COPYING |