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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1756633002: Defer WebGL lost context restore until visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index db8d8d527f334c7b340a41efa2b68bef92c010ee..a0b60b8783715fbbc2f466c3958884d40ebb8d6b 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -833,6 +833,7 @@ bool isSRGBFormat(GLenum internalformat)
WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes)
: CanvasRenderingContext(passedCanvas)
+ , m_isHidden(false)
, m_contextLostMode(NotLostContext)
, m_autoRecoveryMethod(Manual)
, m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatchContextLostEvent)
@@ -1214,8 +1215,14 @@ void WebGLRenderingContextBase::markLayerComposited()
void WebGLRenderingContextBase::setIsHidden(bool hidden)
{
+ m_isHidden = hidden;
if (drawingBuffer())
drawingBuffer()->setIsHidden(hidden);
+
+ if (!hidden && isContextLost() && m_restoreAllowed && m_autoRecoveryMethod == Auto) {
+ ASSERT(!m_restoreTimer.isActive());
+ m_restoreTimer.startOneShot(0, BLINK_FROM_HERE);
+ }
}
bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffer sourceBuffer)
@@ -5901,7 +5908,7 @@ void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(EventTypeNames::webglcontextlost, false, true, "");
canvas()->dispatchEvent(event);
m_restoreAllowed = event->defaultPrevented();
- if (m_restoreAllowed) {
+ if (m_restoreAllowed && !m_isHidden) {
if (m_autoRecoveryMethod == Auto)
m_restoreTimer.startOneShot(0, BLINK_FROM_HERE);
}
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698