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

Unified Diff: ui/gl/gl_image_surface_texture.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: prevent crash when accessing destroyed glimage while doing bind/releaseTexImage. 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_surface_texture.cc
diff --git a/ui/gl/gl_image_surface_texture.cc b/ui/gl/gl_image_surface_texture.cc
index bb9fa135e1e718a26472c945f6aa68ee3991c4fc..76f6c29e91228579445714303438ce9e0042382c 100644
--- a/ui/gl/gl_image_surface_texture.cc
+++ b/ui/gl/gl_image_surface_texture.cc
@@ -14,7 +14,10 @@ GLImageSurfaceTexture::GLImageSurfaceTexture(const gfx::Size& size)
: size_(size), texture_id_(0) {
}
-GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); }
+GLImageSurfaceTexture::~GLImageSurfaceTexture() {
+ DCHECK(!surface_texture_);
+ DCHECK_EQ(0u, texture_id_);
+}
bool GLImageSurfaceTexture::Initialize(
const gfx::GpuMemoryBufferHandle& handle) {
@@ -26,7 +29,7 @@ bool GLImageSurfaceTexture::Initialize(
return !!surface_texture_;
}
-void GLImageSurfaceTexture::Destroy() {
+void GLImageSurfaceTexture::Destroy(bool have_context) {
surface_texture_ = NULL;
texture_id_ = 0;
}
@@ -51,7 +54,10 @@ bool GLImageSurfaceTexture::BindTexImage(unsigned target) {
return false;
}
- DCHECK(surface_texture_);
+ if (!surface_texture_) {
+ LOG(ERROR) << "No SurfaceTexture Image memory to bind";
+ return false;
+ }
if (texture_id != texture_id_) {
// Note: Surface textures used as gpu memory buffers are created with an
// initial dummy texture id of 0. We need to call DetachFromGLContext() here
« gpu/command_buffer/service/image_manager.cc ('K') | « ui/gl/gl_image_surface_texture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698