yagl_offscreen_surface.c
yagl_onscreen.c
yagl_onscreen_image_pixmap.c
+ yagl_onscreen_image_gl_texture_2d.c
yagl_onscreen_surface.c
yagl_onscreen_fence.c
yagl_onscreen_utils.c
struct yagl_native_drawable;
struct yagl_client_interface;
struct wl_resource;
+struct yagl_context;
struct yagl_backend
{
struct wl_resource */*buffer*/,
struct yagl_client_interface */*iface*/);
+ struct yagl_image *(*create_image_gl_texture_2d)(struct yagl_display */*dpy*/,
+ struct yagl_context */*ctx*/,
+ yagl_object_name /*texture*/,
+ struct yagl_client_interface */*iface*/);
+
struct yagl_fence *(*create_fence)(struct yagl_display */*dpy*/);
void (*destroy)(struct yagl_backend */*backend*/);
#define YAGL_EGL_WL_BIND_WAYLAND_DISPLAY_EXTENSIONS "EGL_WL_bind_wayland_display "
+#define YAGL_EGL_GL_TEXTURE_EXTENSIONS "EGL_KHR_gl_texture_2D_image "
+
#define YAGL_EGL_BUFFER_AGE_EXTENSIONS "EGL_EXT_buffer_age "
#define YAGL_EGL_FENCE_EXTENSIONS "EGL_KHR_fence_sync "
len += strlen(YAGL_EGL_FENCE_EXTENSIONS);
}
+ len += strlen(YAGL_EGL_GL_TEXTURE_EXTENSIONS);
+
dpy->extensions = yagl_malloc(len + 1);
strcpy(dpy->extensions, YAGL_EGL_BASE_EXTENSIONS);
if (yagl_egl_fence_supported()) {
strcat(dpy->extensions, YAGL_EGL_FENCE_EXTENSIONS);
}
+
+ strcat(dpy->extensions, YAGL_EGL_GL_TEXTURE_EXTENSIONS);
}
pthread_mutex_unlock(&dpy->mutex);
}
YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_,
- EGLContext ctx,
+ EGLContext ctx_,
EGLenum target,
EGLClientBuffer buffer,
const EGLint *attrib_list)
EGLImageKHR ret = EGL_NO_IMAGE_KHR;
struct yagl_client_interface *iface = NULL;
struct yagl_display *dpy = NULL;
+ struct yagl_context *ctx = NULL;
struct yagl_native_drawable *native_buffer = NULL;
struct yagl_image *image = NULL;
int i = 0;
YAGL_LOG_FUNC_ENTER(eglCreateImageKHR,
"dpy = %u, ctx = %u, target = %u, buffer = %p",
(yagl_host_handle)dpy_,
- (yagl_host_handle)ctx,
+ (yagl_host_handle)ctx_,
target,
buffer);
goto out;
}
+ break;
+ case EGL_GL_TEXTURE_2D_KHR:
+ if (attrib_list) {
+ while (attrib_list[i] != EGL_NONE) {
+ switch (attrib_list[i]) {
+ case EGL_IMAGE_PRESERVED_KHR:
+ case EGL_GL_TEXTURE_LEVEL_KHR:
+ break;
+ default:
+ YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
+ goto out;
+ }
+
+ i += 2;
+ }
+ }
+
+ if (!yagl_validate_context(dpy, ctx_, &ctx)) {
+ goto out;
+ }
+
+ image = yagl_get_backend()->create_image_gl_texture_2d(dpy,
+ ctx,
+ (yagl_object_name)buffer,
+ iface);
+
+ if (!image) {
+ goto out;
+ }
+
break;
default:
YAGL_SET_ERR(EGL_BAD_PARAMETER);
out:
yagl_image_release(image);
+ yagl_context_release(ctx);
+
YAGL_LOG_FUNC_EXIT("%p", ret);
return ret;
return NULL;
}
+static struct yagl_image
+ *yagl_offscreen_create_image_gl_texture_2d(struct yagl_display *dpy,
+ struct yagl_context *ctx,
+ yagl_object_name texture,
+ struct yagl_client_interface *iface)
+{
+ return NULL;
+}
+
static struct yagl_fence
*yagl_offscreen_create_fence(struct yagl_display *dpy)
{
backend->create_pbuffer_surface = &yagl_offscreen_create_pbuffer_surface;
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_fence = &yagl_offscreen_create_fence;
backend->destroy = &yagl_offscreen_destroy;
backend->y_inverted = 1;
#ifdef YAGL_PLATFORM_WAYLAND
#include "yagl_onscreen_image_wl_buffer.h"
#endif
+#include "yagl_onscreen_image_gl_texture_2d.h"
#include "yagl_onscreen_fence.h"
#include "yagl_backend.h"
#include "yagl_malloc.h"
#endif
}
+static struct yagl_image
+ *yagl_onscreen_create_image_gl_texture_2d(struct yagl_display *dpy,
+ struct yagl_context *ctx,
+ yagl_object_name texture,
+ struct yagl_client_interface *iface)
+{
+ struct yagl_onscreen_image_gl_texture_2d *image =
+ yagl_onscreen_image_gl_texture_2d_create(dpy, ctx, texture, iface);
+
+ return image ? &image->base: NULL;
+}
+
static struct yagl_fence
*yagl_onscreen_create_fence(struct yagl_display *dpy)
{
backend->create_pbuffer_surface = &yagl_onscreen_create_pbuffer_surface;
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_fence = &yagl_onscreen_create_fence;
backend->destroy = &yagl_onscreen_destroy;
backend->y_inverted = 0;
--- /dev/null
+/*
+ * 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_gl_texture_2d.h"
+#include "yagl_client_interface.h"
+#include "yagl_client_image.h"
+#include "yagl_egl_state.h"
+#include "yagl_context.h"
+#include "yagl_malloc.h"
+
+static void yagl_onscreen_image_gl_texture_2d_update(struct yagl_image *image)
+{
+}
+
+static void yagl_onscreen_image_gl_texture_2d_destroy(struct yagl_ref *ref)
+{
+ struct yagl_onscreen_image_gl_texture_2d *image = (struct yagl_onscreen_image_gl_texture_2d *)ref;
+
+ yagl_object_release(image->texture_obj);
+
+ yagl_image_cleanup(&image->base);
+
+ yagl_free(image);
+}
+
+
+struct yagl_onscreen_image_gl_texture_2d
+ *yagl_onscreen_image_gl_texture_2d_create(struct yagl_display *dpy,
+ struct yagl_context *ctx,
+ yagl_object_name texture,
+ struct yagl_client_interface *iface)
+{
+ struct yagl_client_image *client_image;
+ struct yagl_onscreen_image_gl_texture_2d *image;
+ struct yagl_object *texture_obj = NULL;
+
+ image = yagl_malloc0(sizeof(*image));
+
+ client_image = iface->wrap_texture(iface,
+ ctx->client_ctx,
+ texture,
+ &texture_obj);
+
+ if (!client_image) {
+ yagl_set_error(EGL_BAD_PARAMETER);
+ goto fail;
+ }
+
+ yagl_image_init(&image->base,
+ &yagl_onscreen_image_gl_texture_2d_destroy,
+ dpy,
+ (EGLImageKHR)image,
+ client_image);
+
+ yagl_client_image_release(client_image);
+
+ image->base.update = &yagl_onscreen_image_gl_texture_2d_update;
+
+ image->texture_obj = texture_obj;
+
+ return image;
+
+fail:
+ if (texture_obj) {
+ yagl_object_release(texture_obj);
+ }
+
+ yagl_free(image);
+
+ return NULL;
+}
--- /dev/null
+/*
+ * 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_GL_TEXTURE_2D_H_
+#define _YAGL_ONSCREEN_IMAGE_GL_TEXTURE_2D_H_
+
+#include "yagl_image.h"
+#include "EGL/egl.h"
+
+struct yagl_context;
+struct yagl_client_interface;
+
+struct yagl_onscreen_image_gl_texture_2d
+{
+ struct yagl_image base;
+
+ struct yagl_object *texture_obj;
+};
+
+struct yagl_onscreen_image_gl_texture_2d
+ *yagl_onscreen_image_gl_texture_2d_create(struct yagl_display *dpy,
+ struct yagl_context *ctx,
+ yagl_object_name texture,
+ struct yagl_client_interface *iface);
+
+#endif
#include "GL/gl.h"
#include "yagl_gles_image.h"
+#include "yagl_gles_texture.h"
+#include "yagl_client_context.h"
+#include "yagl_sharegroup.h"
#include "yagl_malloc.h"
#include "yagl_host_gles_calls.h"
{
struct yagl_gles_image *image = (struct yagl_gles_image*)ref;
- yagl_host_glDeleteObjects(&image->tex_global_name, 1);
+ if (image->own_tex) {
+ yagl_host_glDeleteObjects(&image->tex_global_name, 1);
+ }
yagl_client_image_cleanup(&image->base);
image->base.update = &yagl_gles_image_update;
image->tex_global_name = tex_global_name;
+ image->own_tex = 1;
+
+ return image;
+}
+
+struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx,
+ yagl_object_name tex_local_name,
+ struct yagl_object **obj)
+{
+ struct yagl_gles_texture *texture_obj;
+ struct yagl_gles_image *image;
+
+ texture_obj = (struct yagl_gles_texture *)yagl_sharegroup_acquire_object(ctx->sg,
+ YAGL_NS_TEXTURE,
+ tex_local_name);
+
+ if (!texture_obj) {
+ goto fail;
+ }
+
+ image = yagl_malloc0(sizeof(*image));
+
+ yagl_client_image_init(&image->base, &yagl_gles_image_destroy);
+
+ image->base.update = &yagl_gles_image_update;
+
+ image->tex_global_name = texture_obj->global_name;
+ image->own_tex = 0;
+
+ *obj = &texture_obj->base;
return image;
+
+fail:
+ yagl_gles_texture_release(texture_obj);
+
+ return NULL;
}
void yagl_gles_image_acquire(struct yagl_gles_image *image)
#include "yagl_types.h"
#include "yagl_client_image.h"
+struct yagl_client_context;
+
struct yagl_gles_image
{
struct yagl_client_image base;
yagl_object_name tex_global_name;
+
+ int own_tex;
};
struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name);
+struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx,
+ yagl_object_name tex_local_name,
+ struct yagl_object **obj);
+
/*
* Passing NULL won't hurt, this is for convenience.
*/
return &yagl_gles_image_create(tex_global_name)->base;
}
+static struct yagl_client_image
+ *yagl_gles1_wrap_texture(struct yagl_client_interface *iface,
+ struct yagl_client_context *ctx,
+ yagl_object_name tex_local_name,
+ struct yagl_object **texture_obj)
+{
+ return &yagl_gles_image_wrap_tex(ctx,tex_local_name, texture_obj)->base;
+}
+
static void yagl_gles1_release_tex_image(struct yagl_client_interface *iface,
void *cookie)
{
{
.create_ctx = &yagl_gles1_create_ctx,
.create_image = &yagl_gles1_create_image,
+ .wrap_texture = &yagl_gles1_wrap_texture,
.release_tex_image = &yagl_gles1_release_tex_image
};
return &yagl_gles_image_create(tex_global_name)->base;
}
+static struct yagl_client_image
+ *yagl_gles2_wrap_texture(struct yagl_client_interface *iface,
+ struct yagl_client_context *ctx,
+ yagl_object_name tex_local_name,
+ struct yagl_object **texture_obj)
+{
+ return &yagl_gles_image_wrap_tex(ctx, tex_local_name, texture_obj)->base;
+}
+
static void yagl_gles2_release_tex_image(struct yagl_client_interface *iface,
void *cookie)
{
{
.create_ctx = &yagl_gles2_create_ctx,
.create_image = &yagl_gles2_create_image,
+ .wrap_texture = &yagl_gles2_wrap_texture,
.release_tex_image = &yagl_gles2_release_tex_image
};
struct yagl_client_context;
struct yagl_client_image;
struct yagl_sharegroup;
+struct yagl_object;
struct yagl_client_interface
{
*(*create_image)(struct yagl_client_interface */*iface*/,
yagl_object_name /*tex_global_name*/);
+ struct yagl_client_image
+ *(*wrap_texture)(struct yagl_client_interface */*iface*/,
+ struct yagl_client_context */*ctx*/,
+ yagl_object_name /*tex_local_name*/,
+ struct yagl_object **/*obj*/);
+
void (*release_tex_image)(struct yagl_client_interface */*iface*/,
void */*cookie*/);
};