Commit 0f73014d authored by Zhenyao Mo's avatar Zhenyao Mo Committed by Commit Bot

Fix a crash in gl::DirectCompositionChildSurfaceWin::SetDrawRectangle

We assumed GLContext::GetCurrent() will not return null, but it the wild
it seems it could be null. So instead of DCHECK, we fail gracefully.

BUG=1002637
TEST=crash reports
R=sunnyps@chromium.org

Change-Id: If3b83bd93c73353632baedfa7876cba77cebdf16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804219
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Auto-Submit: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696628}
parent c895047b
......@@ -253,6 +253,17 @@ bool DirectCompositionChildSurfaceWin::SetDrawRectangle(
return false;
}
gl::GLContext* context = gl::GLContext::GetCurrent();
if (!context) {
DLOG(ERROR) << "gl::GLContext::GetCurrent() returned nullptr";
return false;
}
gl::GLSurface* surface = gl::GLSurface::GetCurrent();
if (!surface) {
DLOG(ERROR) << "gl::GLSurface::GetCurrent() returned nullptr";
return false;
}
DXGI_FORMAT dxgi_format = ColorSpaceUtils::GetDXGIFormat(color_space_);
if (!dcomp_surface_ && enable_dc_layers_) {
......@@ -357,10 +368,6 @@ bool DirectCompositionChildSurfaceWin::SetDrawRectangle(
// We make current with the same surface (could be the parent), but its
// handle has changed to |real_surface_|.
gl::GLContext* context = gl::GLContext::GetCurrent();
DCHECK(context);
gl::GLSurface* surface = gl::GLSurface::GetCurrent();
DCHECK(surface);
if (!context->MakeCurrent(surface)) {
DLOG(ERROR) << "Failed to make current in SetDrawRectangle";
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment