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

Unified Diff: ui/gl/gl_image_memory.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: build issues addressed. 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
Index: ui/gl/gl_image_memory.cc
diff --git a/ui/gl/gl_image_memory.cc b/ui/gl/gl_image_memory.cc
index 5d0f901c812fde7d71819ac47306cbbb75994256..5747ccfb57b91d91be8491357220c72eb3d039c3 100644
--- a/ui/gl/gl_image_memory.cc
+++ b/ui/gl/gl_image_memory.cc
@@ -81,6 +81,11 @@ GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat)
}
GLImageMemory::~GLImageMemory() {
+#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
+ defined(USE_OZONE)
+ DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
+ DCHECK_EQ(0u, egl_texture_id_);
+#endif
}
bool GLImageMemory::Initialize(const unsigned char* memory) {
@@ -95,7 +100,7 @@ bool GLImageMemory::Initialize(const unsigned char* memory) {
return true;
}
-void GLImageMemory::Destroy() {
+void GLImageMemory::Destroy(bool have_context) {
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
defined(USE_OZONE)
if (egl_image_ != EGL_NO_IMAGE_KHR) {
@@ -104,7 +109,8 @@ void GLImageMemory::Destroy() {
}
if (egl_texture_id_) {
- glDeleteTextures(1, &egl_texture_id_);
+ if (have_context)
+ glDeleteTextures(1, &egl_texture_id_);
egl_texture_id_ = 0u;
}
#endif
@@ -118,7 +124,10 @@ gfx::Size GLImageMemory::GetSize() {
bool GLImageMemory::BindTexImage(unsigned target) {
TRACE_EVENT0("gpu", "GLImageMemory::BindTexImage");
- DCHECK(memory_);
+ if (!memory_) {
+ LOG(ERROR) << "Uninitialized image cannot be bound to texture";
+ return false;
+ }
reveman 2014/07/25 19:00:23 Let's keep this as before. Sorry.
sohanjg 2014/07/26 10:42:23 Done.
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
defined(USE_OZONE)
if (target == GL_TEXTURE_EXTERNAL_OES) {

Powered by Google App Engine
This is Rietveld 408576698