Title: [94217] branches/chromium/835/Source/WebKit/chromium/src
Revision
94217
Author
vange...@chromium.org
Date
2011-08-31 12:29:06 -0700 (Wed, 31 Aug 2011)

Log Message

Direct commit into chromium 835 branch:

Fix handling of lost context recovery for windows XP. The existing code didn't always 
succeed creating a GC3D right after recovering from a lost device and ended up in an inconsistent 
state of doing s/w rendering but without having properly cleared the composited layers. 
The new code attempts to create a GC3D a few times before giving up and switching to s/w rendering. 
Upon repeated failure we now switch to s/w rendering and force a style recalc on the document 
to make sure that composited layers are properly disposed. 

This code is checked in to the 835 branch directly as handling of the lost context events on the trunk has significantly diverged. A similar change must be made to the trunk as well. 

CHROME BUG=http://code.google.com/p/chromium/issues/detail?id=94183
TEST=Open pages using the compositor like the poster circle on windows XP and trigger repeated lost device events 
by locking the screen. Verify that upon return the page renders correctly.

Modified Paths

Diff

Modified: branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.cpp (94216 => 94217)


--- branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-08-31 19:21:51 UTC (rev 94216)
+++ branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-08-31 19:29:06 UTC (rev 94217)
@@ -334,6 +334,7 @@
     , m_isAcceleratedCompositingActive(false)
     , m_compositorCreationFailed(false)
     , m_recreatingGraphicsContext(false)
+    , m_recreateGraphicsContextAttemptsCount(0)
 #endif
 #if ENABLE(INPUT_SPEECH)
     , m_speechInputClient(SpeechInputClientImpl::create(client))
@@ -1151,10 +1152,18 @@
 #else
     TRACE_EVENT("WebViewImpl::composite", this, 0);
 
+    // The maximum number of times we'll try to recreate the compositor
+    // and associated GC3D context before failing over to s/w compositing.
+    const int maxGraphicsContextRecreateAttempts = 5;
+
     if (m_recreatingGraphicsContext) {
         // reallocateRenderer will request a repaint whether or not it succeeded
         // in creating a new context.
-        reallocateRenderer();
+        if (!reallocateRenderer(!m_recreateGraphicsContextAttemptsCount)) {
+            m_recreateGraphicsContextAttemptsCount--;
+            setRootLayerNeedsDisplay();
+            return;
+        }
         m_recreatingGraphicsContext = false;
         return;
     }
@@ -1175,6 +1184,7 @@
         // renderer, recreate the renderer at the next message loop iteration
         // and request a repaint yet again.
         m_recreatingGraphicsContext = true;
+        m_recreateGraphicsContextAttemptsCount = maxGraphicsContextRecreateAttempts;
         setRootLayerNeedsDisplay();
     }
 #endif
@@ -2564,10 +2574,12 @@
     return context;
 }
 
-void WebViewImpl::reallocateRenderer()
+bool WebViewImpl::reallocateRenderer(bool disableCompositingOnFailure)
 {
     // GraphicsContext3D::create might fail and return 0, in that case LayerRendererChromium::create will also return 0.
     RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(this, WebViewImplContentPainter::create(this), m_page->settings()->acceleratedDrawingEnabled());
+    if (!layerRenderer && !disableCompositingOnFailure)
+        return false;
 
     // Reattach the root layer.  Child layers will get reattached as a side effect of updateLayersRecursive.
     if (layerRenderer) {
@@ -2588,8 +2600,14 @@
         m_client->didActivateAcceleratedCompositing(true);
         if (m_pageOverlay)
             m_pageOverlay->update();
-    } else
+    } else {
         setRootPlatformLayer(0);
+        m_compositorCreationFailed = true;
+        // Force a style recalc to remove all the composited layers.
+        m_page->mainFrame()->document()->scheduleForcedStyleRecalc();
+    }
+
+    return true;
 }
 #endif
 

Modified: branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.h (94216 => 94217)


--- branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.h	2011-08-31 19:21:51 UTC (rev 94216)
+++ branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.h	2011-08-31 19:29:06 UTC (rev 94217)
@@ -428,7 +428,7 @@
     void setIsAcceleratedCompositingActive(bool);
     void doComposite();
     void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&);
-    void reallocateRenderer();
+    bool reallocateRenderer(bool disableCompositingOnFailure);
     void updateLayerRendererSettings();
     void updateLayerRendererViewport();
 #endif
@@ -553,6 +553,7 @@
     bool m_compositorCreationFailed;
     // If true, the graphics context is being restored.
     bool m_recreatingGraphicsContext;
+    int m_recreateGraphicsContextAttemptsCount;
 #endif
     static const WebInputEvent* m_currentInputEvent;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to