Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: ui/gl/gl_image_egl.cc

Issue 198703002: Add GL_TEXTURE_EXTERNAL_OES as supported texture target for CHROMIUM_map_image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac build break Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_shm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_egl.cc
diff --git a/ui/gl/gl_image_egl.cc b/ui/gl/gl_image_egl.cc
index ddd2f6f5e29552cba3706e78fadae7d5951bbfb3..fae83e068e2c7c9c8e8f91f08401cf0476aa3460 100644
--- a/ui/gl/gl_image_egl.cc
+++ b/ui/gl/gl_image_egl.cc
@@ -6,6 +6,7 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_egl.h"
+#include "ui/gl/scoped_binders.h"
namespace gfx {
@@ -14,8 +15,9 @@ GLImageEGL::GLImageEGL(gfx::Size size)
size_(size),
release_after_use_(false),
in_use_(false),
- target_(0) {
-}
+ target_(0),
+ egl_image_for_unbind_(EGL_NO_IMAGE_KHR),
+ texture_id_for_unbind_(0) {}
GLImageEGL::~GLImageEGL() {
Destroy();
@@ -44,18 +46,21 @@ bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) {
}
void GLImageEGL::Destroy() {
- if (egl_image_ == EGL_NO_IMAGE_KHR)
- return;
-
- EGLBoolean success = eglDestroyImageKHR(
- GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
+ if (egl_image_ != EGL_NO_IMAGE_KHR) {
+ eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
+ egl_image_ = EGL_NO_IMAGE_KHR;
+ }
- if (success == EGL_FALSE) {
- EGLint error = eglGetError();
- LOG(ERROR) << "Error destroying EGLImage: " << error;
+ if (egl_image_for_unbind_ != EGL_NO_IMAGE_KHR) {
+ eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
+ egl_image_for_unbind_);
+ egl_image_for_unbind_ = EGL_NO_IMAGE_KHR;
}
- egl_image_ = EGL_NO_IMAGE_KHR;
+ if (texture_id_for_unbind_) {
+ glDeleteTextures(1, &texture_id_for_unbind_);
+ texture_id_for_unbind_ = 0;
+ }
}
gfx::Size GLImageEGL::GetSize() {
@@ -108,16 +113,37 @@ void GLImageEGL::DidUseTexImage() {
if (!release_after_use_)
return;
- char zero[4] = { 0, };
- glTexImage2D(target_,
- 0,
- GL_RGBA,
- 1,
- 1,
- 0,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- &zero);
+ if (egl_image_for_unbind_ == EGL_NO_IMAGE_KHR) {
+ DCHECK_EQ(0u, texture_id_for_unbind_);
+ glGenTextures(1, &texture_id_for_unbind_);
+
+ {
+ ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_for_unbind_);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ char zero[4] = {0, };
+ glTexImage2D(
+ GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &zero);
+ }
+
+ EGLint attrs[] = {EGL_GL_TEXTURE_LEVEL_KHR, 0, // mip-level.
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
+ // Need to pass current EGL rendering context to eglCreateImageKHR for
+ // target type EGL_GL_TEXTURE_2D_KHR.
+ egl_image_for_unbind_ = eglCreateImageKHR(
+ GLSurfaceEGL::GetHardwareDisplay(),
+ eglGetCurrentContext(),
+ EGL_GL_TEXTURE_2D_KHR,
+ reinterpret_cast<EGLClientBuffer>(texture_id_for_unbind_),
+ attrs);
+ DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_for_unbind_)
+ << "Error creating EGLImage: " << eglGetError();
+ }
+
+ glEGLImageTargetTexture2DOES(target_, egl_image_for_unbind_);
+ DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
}
void GLImageEGL::WillModifyTexImage() {
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_shm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698