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

Unified Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 1934363002: Improve robustness of lost context checks in Canvas2DLayerBridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
index 9895364de873bfbe6836b6fb2c63ebcf8cb6d1b9..5f750f02efcb1f71b98dd1aa3f0d4ed382d0516b 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -201,6 +201,9 @@ bool Canvas2DLayerBridge::prepareIOSurfaceMailboxFromImage(SkImage* image, WebEx
return false;
gpu::gles2::GLES2Interface* gl = contextGL();
+ if (!gl)
+ return false;
+
GLuint imageTexture = skia::GrBackendObjectToGrGLTextureInfo(image->getTextureHandle(true))->fID;
gl->CopySubTextureCHROMIUM(imageTexture, imageInfo.m_textureId, 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE);
@@ -236,6 +239,9 @@ Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture
}
gpu::gles2::GLES2Interface* gl = contextGL();
+ if (!gl)
+ return Canvas2DLayerBridge::ImageInfo();
+
GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_size.height(), GL_RGBA, GC3D_SCANOUT_CHROMIUM);
if (!imageId)
return Canvas2DLayerBridge::ImageInfo();
@@ -256,7 +262,7 @@ Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture
void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info)
{
gpu::gles2::GLES2Interface* gl = contextGL();
- if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
+ if (!gl)
return;
GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
@@ -322,6 +328,9 @@ bool Canvas2DLayerBridge::prepareMailboxFromImage(PassRefPtr<SkImage> image, Web
mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D;
gpu::gles2::GLES2Interface* gl = contextGL();
+ if (!gl)
+ return false;
+
GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_image->getTextureHandle(true))->fID;
gl->BindTexture(GL_TEXTURE_2D, textureID);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter());
@@ -694,8 +703,9 @@ gpu::gles2::GLES2Interface* Canvas2DLayerBridge::contextGL()
// Check on m_layer is necessary because contextGL() may be called during
// the destruction of m_layer
if (m_layer && !m_destructionInProgress) {
- // Ensure rate limiter is disabled if context is lost.
- checkSurfaceValid();
+ // Call checkSurfaceValid to ensure rate limiter is disabled if context is lost.
+ if (!checkSurfaceValid())
+ return nullptr;
}
return m_contextProvider ? m_contextProvider->contextGL() : nullptr;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698