diff options
author | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2013-08-02 15:33:18 +0400 |
---|---|---|
committer | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2013-08-02 15:33:18 +0400 |
commit | 2ba02c3679f61494463a386372e3440df1976224 (patch) | |
tree | 801d1bbc465e8b69f89f18f6153f8ad6c7e1b8fb /EGL | |
parent | ae779661d52b878f0436e123bdc7d20823bbbf4f (diff) | |
download | emulator-yagl-2ba02c3679f61494463a386372e3440df1976224.tar.gz emulator-yagl-2ba02c3679f61494463a386372e3440df1976224.tar.bz2 emulator-yagl-2ba02c3679f61494463a386372e3440df1976224.zip |
YaGL: GBM platform added
Change-Id: I20ce694cf9847e281ff4033a7e593e21015a2493
Diffstat (limited to 'EGL')
-rw-r--r-- | EGL/CMakeLists.txt | 6 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_display.c | 77 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_display.h | 16 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_drawable.c | 0 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_drawable.h | 0 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_pixmap.c | 106 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_pixmap.h | 16 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_platform.c | 15 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_window.c | 114 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_window.h | 16 | ||||
-rw-r--r-- | EGL/yagl_onscreen_utils.c | 2 |
11 files changed, 364 insertions, 4 deletions
diff --git a/EGL/CMakeLists.txt b/EGL/CMakeLists.txt index 268926c..fe4970f 100644 --- a/EGL/CMakeLists.txt +++ b/EGL/CMakeLists.txt @@ -55,7 +55,11 @@ if (PLATFORM_GBM) set(SOURCES ${SOURCES} gbm/yagl_gbm_platform.c gbm/yagl_gbm_display.c - gbm/yagl_gbm_drawable.c + gbm/yagl_gbm_window.c + gbm/yagl_gbm_pixmap.c + ) + set(LIBRARIES ${LIBRARIES} + gbm-yagl ) add_definitions(-DYAGL_PLATFORM_GBM) endif () diff --git a/EGL/gbm/yagl_gbm_display.c b/EGL/gbm/yagl_gbm_display.c index e69de29..51d5057 100644 --- a/EGL/gbm/yagl_gbm_display.c +++ b/EGL/gbm/yagl_gbm_display.c @@ -0,0 +1,77 @@ +#include "yagl_gbm_display.h" +#include "yagl_gbm_window.h" +#include "yagl_gbm_pixmap.h" +#include "yagl_native_display.h" +#include "yagl_log.h" +#include "yagl_malloc.h" +#include "yagl_gbm.h" + +static struct yagl_native_drawable + *yagl_gbm_display_wrap_window(struct yagl_native_display *dpy, + yagl_os_window os_window) +{ + return yagl_gbm_window_create(dpy, os_window); +} + +static struct yagl_native_drawable + *yagl_gbm_display_wrap_pixmap(struct yagl_native_display *dpy, + yagl_os_pixmap os_pixmap) +{ + return yagl_gbm_pixmap_create(dpy, os_pixmap); +} + +static struct yagl_native_drawable + *yagl_gbm_display_create_pixmap(struct yagl_native_display *dpy, + uint32_t width, + uint32_t height, + uint32_t depth) +{ + return NULL; +} + +static struct yagl_native_image + *yagl_gbm_display_create_image(struct yagl_native_display *dpy, + uint32_t width, + uint32_t height, + uint32_t depth) +{ + return NULL; +} + +static int yagl_gbm_display_get_visual(struct yagl_native_display *dpy, + int *visual_id, + int *visual_type) +{ + return 0; +} + +static void yagl_gbm_display_destroy(struct yagl_native_display *dpy) +{ + yagl_native_display_cleanup(dpy); + + yagl_free(dpy); +} + +struct yagl_native_display + *yagl_gbm_display_create(struct yagl_native_platform *platform, + yagl_os_display os_dpy) +{ + struct gbm_device *gbm_dpy = YAGL_GBM_DPY(os_dpy); + struct yagl_native_display *dpy; + + dpy = yagl_malloc0(sizeof(*dpy)); + + yagl_native_display_init(dpy, + platform, + os_dpy, + gbm_dpy->drm_dev); + + dpy->wrap_window = &yagl_gbm_display_wrap_window; + dpy->wrap_pixmap = &yagl_gbm_display_wrap_pixmap; + dpy->create_pixmap = &yagl_gbm_display_create_pixmap; + dpy->create_image = &yagl_gbm_display_create_image; + dpy->get_visual = &yagl_gbm_display_get_visual; + dpy->destroy = &yagl_gbm_display_destroy; + + return dpy; +} diff --git a/EGL/gbm/yagl_gbm_display.h b/EGL/gbm/yagl_gbm_display.h index e69de29..ff0b3bf 100644 --- a/EGL/gbm/yagl_gbm_display.h +++ b/EGL/gbm/yagl_gbm_display.h @@ -0,0 +1,16 @@ +#ifndef _YAGL_GBM_DISPLAY_H_ +#define _YAGL_GBM_DISPLAY_H_ + +#include "yagl_export.h" +#include "yagl_native_types.h" + +#define YAGL_GBM_DPY(os_dpy) ((struct gbm_device*)(os_dpy)) + +struct yagl_native_platform; +struct yagl_native_display; + +struct yagl_native_display + *yagl_gbm_display_create(struct yagl_native_platform *platform, + yagl_os_display os_dpy); + +#endif diff --git a/EGL/gbm/yagl_gbm_drawable.c b/EGL/gbm/yagl_gbm_drawable.c deleted file mode 100644 index e69de29..0000000 --- a/EGL/gbm/yagl_gbm_drawable.c +++ /dev/null diff --git a/EGL/gbm/yagl_gbm_drawable.h b/EGL/gbm/yagl_gbm_drawable.h deleted file mode 100644 index e69de29..0000000 --- a/EGL/gbm/yagl_gbm_drawable.h +++ /dev/null diff --git a/EGL/gbm/yagl_gbm_pixmap.c b/EGL/gbm/yagl_gbm_pixmap.c new file mode 100644 index 0000000..317b400 --- /dev/null +++ b/EGL/gbm/yagl_gbm_pixmap.c @@ -0,0 +1,106 @@ +#include "yagl_gbm_pixmap.h" +#include "yagl_native_drawable.h" +#include "yagl_log.h" +#include "yagl_malloc.h" +#include "yagl_gbm.h" +#include "vigs.h" + +static int yagl_gbm_pixmap_get_buffer(struct yagl_native_drawable *drawable, + yagl_native_attachment attachment, + uint32_t *buffer_name, + struct vigs_drm_surface **buffer_sfc) +{ + struct gbm_bo *bo = YAGL_GBM_PIXMAP(drawable->os_drawable); + + YAGL_LOG_FUNC_SET(yagl_gbm_pixmap_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(&bo->drm_sfc->gem); + + *buffer_sfc = bo->drm_sfc; + + return 1; +} + +static void yagl_gbm_pixmap_swap_buffers(struct yagl_native_drawable *drawable) +{ +} + +static void yagl_gbm_pixmap_wait(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ +} + +static void yagl_gbm_pixmap_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_gbm_pixmap_set_swap_interval(struct yagl_native_drawable *drawable, + int interval) +{ +} + +static void yagl_gbm_pixmap_get_geometry(struct yagl_native_drawable *drawable, + uint32_t *width, + uint32_t *height, + uint32_t *depth) +{ + struct gbm_bo *bo = YAGL_GBM_PIXMAP(drawable->os_drawable); + + *width = bo->drm_sfc->width; + *height = bo->drm_sfc->height; + *depth = bo->depth; +} + +static struct yagl_native_image + *yagl_gbm_pixmap_get_image(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ + return NULL; +} + +static void yagl_gbm_pixmap_destroy(struct yagl_native_drawable *drawable) +{ + yagl_native_drawable_cleanup(drawable); + + yagl_free(drawable); +} + +struct yagl_native_drawable + *yagl_gbm_pixmap_create(struct yagl_native_display *dpy, + yagl_os_pixmap os_pixmap) +{ + struct yagl_native_drawable *pixmap; + + pixmap = yagl_malloc0(sizeof(*pixmap)); + + yagl_native_drawable_init(pixmap, dpy, os_pixmap); + + pixmap->get_buffer = &yagl_gbm_pixmap_get_buffer; + pixmap->swap_buffers = &yagl_gbm_pixmap_swap_buffers; + pixmap->wait = &yagl_gbm_pixmap_wait; + pixmap->copy_to_pixmap = &yagl_gbm_pixmap_copy_to_pixmap; + pixmap->set_swap_interval = &yagl_gbm_pixmap_set_swap_interval; + pixmap->get_geometry = &yagl_gbm_pixmap_get_geometry; + pixmap->get_image = &yagl_gbm_pixmap_get_image; + pixmap->destroy = &yagl_gbm_pixmap_destroy; + + return pixmap; +} diff --git a/EGL/gbm/yagl_gbm_pixmap.h b/EGL/gbm/yagl_gbm_pixmap.h new file mode 100644 index 0000000..5714837 --- /dev/null +++ b/EGL/gbm/yagl_gbm_pixmap.h @@ -0,0 +1,16 @@ +#ifndef _YAGL_GBM_PIXMAP_H_ +#define _YAGL_GBM_PIXMAP_H_ + +#include "yagl_export.h" +#include "yagl_native_types.h" + +#define YAGL_GBM_PIXMAP(os_pixmap) ((struct gbm_bo*)(os_pixmap)) + +struct yagl_native_display; +struct yagl_native_drawable; + +struct yagl_native_drawable + *yagl_gbm_pixmap_create(struct yagl_native_display *dpy, + yagl_os_pixmap os_pixmap); + +#endif diff --git a/EGL/gbm/yagl_gbm_platform.c b/EGL/gbm/yagl_gbm_platform.c index 7afa63f..a459a90 100644 --- a/EGL/gbm/yagl_gbm_platform.c +++ b/EGL/gbm/yagl_gbm_platform.c @@ -1,16 +1,27 @@ #include "yagl_gbm_platform.h" +#include "yagl_gbm_display.h" #include "yagl_native_platform.h" +#include "yagl_gbm.h" +#include "EGL/egl.h" static int yagl_gbm_platform_probe(yagl_os_display os_dpy) { - return 0; + void *first_pointer; + + if (os_dpy == (yagl_os_display)EGL_DEFAULT_DISPLAY) { + return 0; + } + + first_pointer = *(void**)os_dpy; + + return (first_pointer == &gbm_create_device); } static struct yagl_native_display *yagl_gbm_wrap_display(yagl_os_display os_dpy, int enable_drm) { - return NULL; + return yagl_gbm_display_create(&yagl_gbm_platform, os_dpy); } struct yagl_native_platform yagl_gbm_platform = diff --git a/EGL/gbm/yagl_gbm_window.c b/EGL/gbm/yagl_gbm_window.c new file mode 100644 index 0000000..5dc36ae --- /dev/null +++ b/EGL/gbm/yagl_gbm_window.c @@ -0,0 +1,114 @@ +#include "yagl_gbm_window.h" +#include "yagl_native_drawable.h" +#include "yagl_log.h" +#include "yagl_malloc.h" +#include "yagl_gbm.h" + +static int yagl_gbm_window_get_buffer(struct yagl_native_drawable *drawable, + yagl_native_attachment attachment, + uint32_t *buffer_name, + struct vigs_drm_surface **buffer_sfc) +{ + struct gbm_surface *sfc = YAGL_GBM_WINDOW(drawable->os_drawable); + + YAGL_LOG_FUNC_SET(yagl_gbm_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; + } + + *buffer_sfc = sfc->acquire_back(sfc); + + if (!*buffer_sfc) { + YAGL_LOG_ERROR("Cannot get back for drawable %p", + drawable->os_drawable); + return 0; + } + + return 1; +} + +static void yagl_gbm_window_swap_buffers(struct yagl_native_drawable *drawable) +{ + struct gbm_surface *sfc = YAGL_GBM_WINDOW(drawable->os_drawable); + + sfc->swap_buffers(sfc); + + ++drawable->stamp; +} + +static void yagl_gbm_window_wait(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ +} + +static void yagl_gbm_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_gbm_window_set_swap_interval(struct yagl_native_drawable *drawable, + int interval) +{ +} + +static void yagl_gbm_window_get_geometry(struct yagl_native_drawable *drawable, + uint32_t *width, + uint32_t *height, + uint32_t *depth) +{ + struct gbm_surface *sfc = YAGL_GBM_WINDOW(drawable->os_drawable); + + *width = sfc->width; + *height = sfc->height; + *depth = sfc->depth; +} + +static struct yagl_native_image + *yagl_gbm_window_get_image(struct yagl_native_drawable *drawable, + uint32_t width, + uint32_t height) +{ + return NULL; +} + +static void yagl_gbm_window_destroy(struct yagl_native_drawable *drawable) +{ + yagl_native_drawable_cleanup(drawable); + + yagl_free(drawable); +} + +struct yagl_native_drawable + *yagl_gbm_window_create(struct yagl_native_display *dpy, + yagl_os_window os_window) +{ + struct yagl_native_drawable *window; + + window = yagl_malloc0(sizeof(*window)); + + yagl_native_drawable_init(window, dpy, os_window); + + window->get_buffer = &yagl_gbm_window_get_buffer; + window->swap_buffers = &yagl_gbm_window_swap_buffers; + window->wait = &yagl_gbm_window_wait; + window->copy_to_pixmap = &yagl_gbm_window_copy_to_pixmap; + window->set_swap_interval = &yagl_gbm_window_set_swap_interval; + window->get_geometry = &yagl_gbm_window_get_geometry; + window->get_image = &yagl_gbm_window_get_image; + window->destroy = &yagl_gbm_window_destroy; + + return window; +} diff --git a/EGL/gbm/yagl_gbm_window.h b/EGL/gbm/yagl_gbm_window.h new file mode 100644 index 0000000..7e425a7 --- /dev/null +++ b/EGL/gbm/yagl_gbm_window.h @@ -0,0 +1,16 @@ +#ifndef _YAGL_GBM_WINDOW_H_ +#define _YAGL_GBM_WINDOW_H_ + +#include "yagl_export.h" +#include "yagl_native_types.h" + +#define YAGL_GBM_WINDOW(os_window) ((struct gbm_surface*)(os_window)) + +struct yagl_native_display; +struct yagl_native_drawable; + +struct yagl_native_drawable + *yagl_gbm_window_create(struct yagl_native_display *dpy, + yagl_os_window os_window); + +#endif diff --git a/EGL/yagl_onscreen_utils.c b/EGL/yagl_onscreen_utils.c index f3edae4..2a39d85 100644 --- a/EGL/yagl_onscreen_utils.c +++ b/EGL/yagl_onscreen_utils.c @@ -11,7 +11,7 @@ struct vigs_drm_surface struct vigs_drm_surface *check_sfc) { int ret; - uint32_t buffer_name; + uint32_t buffer_name = 0; struct vigs_drm_surface *buffer_sfc = NULL; YAGL_LOG_FUNC_ENTER(yagl_onscreen_buffer_create, |