#include "ErrorLog.h"
#include "gralloc_cb.h"
#include "ThreadInfo.h"
+#include "EGLImage.h"
//XXX: fix this macro to get the context from fast tls path
}
//GL extensions
-void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES image)
+void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES img)
{
(void)self;
- DBG("glEGLImageTargetTexture2DOES v1 target=%#x image=%p", target, image);
- //TODO: check error - we don't have a way to set gl error
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+ DBG("glEGLImageTargetTexture2DOES v1 target=%#x img=%p", target, img);
+
+ EGLImage_t *image = (EGLImage_t*)img;
+
+ if (image->target == EGL_NATIVE_BUFFER_ANDROID) {
+ //TODO: check error - we don't have a way to set gl error
+ android_native_buffer_t* native_buffer = image->native_buffer;
+
+ if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+ return;
+ }
+
+ if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+ return;
+ }
+
+ GET_CONTEXT;
+ DEFINE_AND_VALIDATE_HOST_CONNECTION();
+
+ ctx->override2DTextureTarget(target);
+ rcEnc->rcBindTexture(rcEnc,
+ ((cb_handle_t *)(native_buffer->handle))->hostHandle);
+ ctx->restore2DTextureTarget();
- if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
return;
}
+ else if (image->target == EGL_GL_TEXTURE_2D_KHR) {
+ // TODO
- if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
return;
}
-
- GET_CONTEXT;
- DEFINE_AND_VALIDATE_HOST_CONNECTION();
-
- ctx->override2DTextureTarget(target);
- rcEnc->rcBindTexture(rcEnc,
- ((cb_handle_t *)(native_buffer->handle))->hostHandle);
- ctx->restore2DTextureTarget();
-
- return;
}
void glEGLImageTargetRenderbufferStorageOES(void *self, GLenum target, GLeglImageOES image)
#include "ErrorLog.h"
#include "gralloc_cb.h"
#include "ThreadInfo.h"
+#include "EGLImage.h"
//XXX: fix this macro to get the context from fast tls path
#define GET_CONTEXT GL2Encoder * ctx = getEGLThreadInfo()->hostConn->gl2Encoder();
}
//GL extensions
-void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES image)
+void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES img)
{
(void)self;
(void)target;
- DBG("glEGLImageTargetTexture2DOES v2 target=%#x img=%p\n", target, image);
- //TODO: check error - we don't have a way to set gl error
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+ DBG("glEGLImageTargetTexture2DOES v2 target=%#x img=%p\n", target, img);
+
+ EGLImage_t *image = (EGLImage_t*)img;
+
+ if (image->target == EGL_NATIVE_BUFFER_ANDROID) {
+ //TODO: check error - we don't have a way to set gl error
+ android_native_buffer_t* native_buffer = image->native_buffer;
+
+ if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+ return;
+ }
+
+ if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+ return;
+ }
+
+ GET_CONTEXT;
+ DEFINE_AND_VALIDATE_HOST_CONNECTION();
+
+ ctx->override2DTextureTarget(target);
+ rcEnc->rcBindTexture(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle);
+ ctx->restore2DTextureTarget();
- if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
return;
}
+ else if (image->target == EGL_GL_TEXTURE_2D_KHR) {
+ // TODO
- if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
return;
}
-
- GET_CONTEXT;
- DEFINE_AND_VALIDATE_HOST_CONNECTION();
-
- ctx->override2DTextureTarget(target);
- rcEnc->rcBindTexture(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle);
- ctx->restore2DTextureTarget();
-
- return;
}
void glEGLImageTargetRenderbufferStorageOES(void *self, GLenum target, GLeglImageOES image)
--- /dev/null
+/*
+* Copyright (C) 2015 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef __COMMON_EGL_IMAGE_H
+#define __COMMON_EGL_IMAGE_H
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES/gl.h>
+#include <system/window.h>
+
+struct EGLImage_t
+{
+ EGLDisplay dpy;
+ EGLenum target;
+
+ union
+ {
+ android_native_buffer_t *native_buffer;
+ uint32_t host_egl_image;
+ };
+};
+
+#endif
#include "GLSharedGroup.h"
#include "eglContext.h"
#include "ClientAPIExts.h"
+#include "EGLImage.h"
#include "GLEncoder.h"
#ifdef WITH_GLES2
(void)attrib_list;
VALIDATE_DISPLAY_INIT(dpy, EGL_NO_IMAGE_KHR);
- if (ctx != EGL_NO_CONTEXT) {
- setErrorReturn(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
- }
- if (target != EGL_NATIVE_BUFFER_ANDROID) {
- setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
- }
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer;
-
- if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
- setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+ if (target == EGL_NATIVE_BUFFER_ANDROID) {
+ if (ctx != EGL_NO_CONTEXT) {
+ setErrorReturn(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+ }
- if (native_buffer->common.version != sizeof(android_native_buffer_t))
- setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+ android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer;
- cb_handle_t *cb = (cb_handle_t *)(native_buffer->handle);
+ if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
+ setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
- switch (cb->format) {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_RGB_888:
- case HAL_PIXEL_FORMAT_RGB_565:
- case HAL_PIXEL_FORMAT_BGRA_8888:
- break;
- default:
+ if (native_buffer->common.version != sizeof(android_native_buffer_t))
setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+
+ cb_handle_t *cb = (cb_handle_t *)(native_buffer->handle);
+
+ switch (cb->format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_RGB_888:
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ break;
+ default:
+ setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+ }
+
+ native_buffer->common.incRef(&native_buffer->common);
+
+ EGLImage_t *image = new EGLImage_t();
+ image->dpy = dpy;
+ image->target = target;
+ image->native_buffer = native_buffer;
+
+ return (EGLImageKHR)image;
}
+ else if (target == EGL_GL_TEXTURE_2D_KHR) {
+ setErrorReturn(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR); // TODO
+
+ VALIDATE_CONTEXT_RETURN(ctx, EGL_NO_IMAGE_KHR);
- native_buffer->common.incRef(&native_buffer->common);
- return (EGLImageKHR)native_buffer;
+ EGLImage_t *image = new EGLImage_t();
+ image->dpy = dpy;
+ image->target = target;
+ image->texture_2d = 0; // TODO
+
+ return (EGLImageKHR)image;
+ }
+
+ setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
}
EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
{
VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)img;
+ EGLImage_t *image = (EGLImage_t*)img;
- if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
- setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+ if (!image || image->dpy != dpy) {
+ RETURN_ERROR(EGL_FALSE, EGL_BAD_PARAMETER);
+ }
- if (native_buffer->common.version != sizeof(android_native_buffer_t))
- setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+ if (image->target == EGL_NATIVE_BUFFER_ANDROID) {
+ android_native_buffer_t* native_buffer = image->native_buffer;
- native_buffer->common.decRef(&native_buffer->common);
+ if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
+ setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
- return EGL_TRUE;
+ if (native_buffer->common.version != sizeof(android_native_buffer_t))
+ setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+
+ native_buffer->common.decRef(&native_buffer->common);
+ delete image;
+
+ return EGL_TRUE;
+ }
+ else if (image->target == EGL_GL_TEXTURE_2D_KHR) {
+ // TODO
+
+ delete image;
+
+ return EGL_TRUE;
+ }
+
+ setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
}
#define FENCE_SYNC_HANDLE (EGLSyncKHR)0xFE4CE