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

Unified Diff: ui/gl/gl_image_android_native_buffer.cc

Issue 301793003: During image destroy, delete textures only if we have a GL context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve android clang dbg build issue. Created 6 years, 5 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_android_native_buffer.h ('k') | ui/gl/gl_image_egl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_android_native_buffer.cc
diff --git a/ui/gl/gl_image_android_native_buffer.cc b/ui/gl/gl_image_android_native_buffer.cc
index 5e311eeef785a3934fc7604e35942498d81cc650..0323954be572f35724c4733b51778ce0f6a0820c 100644
--- a/ui/gl/gl_image_android_native_buffer.cc
+++ b/ui/gl/gl_image_android_native_buffer.cc
@@ -18,7 +18,10 @@ GLImageAndroidNativeBuffer::GLImageAndroidNativeBuffer(const gfx::Size& size)
texture_id_for_unbind_(0) {
}
-GLImageAndroidNativeBuffer::~GLImageAndroidNativeBuffer() { Destroy(); }
+GLImageAndroidNativeBuffer::~GLImageAndroidNativeBuffer() {
+ DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
+ DCHECK_EQ(0u, texture_id_for_unbind_);
+}
bool GLImageAndroidNativeBuffer::Initialize(EGLClientBuffer native_buffer) {
EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
@@ -26,18 +29,20 @@ bool GLImageAndroidNativeBuffer::Initialize(EGLClientBuffer native_buffer) {
EGL_NATIVE_BUFFER_ANDROID, native_buffer, attrs);
}
-void GLImageAndroidNativeBuffer::Destroy() {
+void GLImageAndroidNativeBuffer::Destroy(bool have_context) {
if (egl_image_for_unbind_ != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
egl_image_for_unbind_);
egl_image_for_unbind_ = EGL_NO_IMAGE_KHR;
}
+
if (texture_id_for_unbind_) {
- glDeleteTextures(1, &texture_id_for_unbind_);
- texture_id_for_unbind_ = 0;
+ if (have_context)
+ glDeleteTextures(1, &texture_id_for_unbind_);
+ texture_id_for_unbind_ = 0u;
}
- GLImageEGL::Destroy();
+ GLImageEGL::Destroy(have_context);
}
bool GLImageAndroidNativeBuffer::BindTexImage(unsigned target) {
@@ -64,7 +69,7 @@ bool GLImageAndroidNativeBuffer::BindTexImage(unsigned target) {
}
void GLImageAndroidNativeBuffer::WillUseTexImage() {
- DCHECK(egl_image_);
+ DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
DCHECK(!in_use_);
in_use_ = true;
glEGLImageTargetTexture2DOES(target_, egl_image_);
@@ -72,6 +77,7 @@ void GLImageAndroidNativeBuffer::WillUseTexImage() {
}
void GLImageAndroidNativeBuffer::DidUseTexImage() {
+ DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
DCHECK(in_use_);
in_use_ = false;
« no previous file with comments | « ui/gl/gl_image_android_native_buffer.h ('k') | ui/gl/gl_image_egl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698