Diff
Modified: trunk/Source/WebCore/ChangeLog (109838 => 109839)
--- trunk/Source/WebCore/ChangeLog 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/ChangeLog 2012-03-06 04:15:27 UTC (rev 109839)
@@ -1,3 +1,32 @@
+2012-03-05 Kenneth Russell <[email protected]>
+
+ [chromium] Notify CCLayerImpl tree of context loss and restoration
+ https://bugs.webkit.org/show_bug.cgi?id=80339
+
+ Reviewed by James Robinson.
+
+ Tested by manually killing GPU process while playing Flash video.
+ Video continues to play after compositor restores its context.
+
+ * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+ (WebCore::CCLayerImpl::didLoseAndRecreateGraphicsContext):
+ (WebCore):
+ * platform/graphics/chromium/cc/CCLayerImpl.h:
+ (CCLayerImpl):
+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+ (WebCore::CCLayerTreeHostImpl::sendContextLostAndRestoredNotification):
+ (WebCore):
+ (WebCore::CCLayerTreeHostImpl::sendContextLostAndRestoredNotificationRecursive):
+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+ (CCLayerTreeHostImpl):
+ * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
+ (WebCore::CCPluginLayerImpl::didLoseAndRecreateGraphicsContext):
+ (WebCore):
+ * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
+ (CCPluginLayerImpl):
+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+ (WebCore::CCSingleThreadProxy::recreateContext):
+
2012-03-05 Changhun Kang <[email protected]>
Change the argument orders to match OpenGL's in GraphicsContext3D functions
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp 2012-03-06 04:15:27 UTC (rev 109839)
@@ -529,7 +529,11 @@
noteLayerPropertyChangedForSubtree();
}
+void CCLayerImpl::didLoseAndRecreateGraphicsContext()
+{
}
+}
+
#endif // USE(ACCELERATED_COMPOSITING)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h 2012-03-06 04:15:27 UTC (rev 109839)
@@ -215,6 +215,11 @@
CCLayerAnimationControllerImpl* layerAnimationController() { return m_layerAnimationController.get(); }
+ // Indicates that the context previously used to render this layer
+ // was lost and that a new one has been created. Won't be called
+ // until the new context has been created successfully.
+ virtual void didLoseAndRecreateGraphicsContext();
+
protected:
explicit CCLayerImpl(int);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2012-03-06 04:15:27 UTC (rev 109839)
@@ -700,4 +700,21 @@
m_client->setNeedsRedrawOnImplThread();
}
+void CCLayerTreeHostImpl::sendContextLostAndRestoredNotification()
+{
+ sendContextLostAndRestoredNotificationRecursive(m_rootLayerImpl.get());
+}
+
+void CCLayerTreeHostImpl::sendContextLostAndRestoredNotificationRecursive(CCLayerImpl* current)
+{
+ if (!current)
+ return;
+
+ current->didLoseAndRecreateGraphicsContext();
+ sendContextLostAndRestoredNotificationRecursive(current->maskLayer());
+ sendContextLostAndRestoredNotificationRecursive(current->replicaLayer());
+ for (size_t i = 0; i < current->children().size(); ++i)
+ sendContextLostAndRestoredNotificationRecursive(current->children()[i].get());
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h 2012-03-06 04:15:27 UTC (rev 109839)
@@ -124,6 +124,9 @@
bool needsAnimateLayers() const { return m_needsAnimateLayers; }
void setNeedsAnimateLayers() { m_needsAnimateLayers = true; }
+ // Notifies the layer tree that the context was lost and successfully restored.
+ void sendContextLostAndRestoredNotification();
+
protected:
CCLayerTreeHostImpl(const CCSettings&, CCLayerTreeHostImplClient*);
@@ -152,6 +155,7 @@
void optimizeRenderPasses(CCRenderPassList&);
void animateLayersRecursive(CCLayerImpl*, double frameBeginTimeSecs, CCAnimationEventsVector&, bool& didAnimate, bool& needsAnimateLayers);
IntSize contentSize() const;
+ void sendContextLostAndRestoredNotificationRecursive(CCLayerImpl*);
OwnPtr<LayerRendererChromium> m_layerRenderer;
OwnPtr<CCLayerImpl> m_rootLayerImpl;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp 2012-03-06 04:15:27 UTC (rev 109839)
@@ -103,6 +103,16 @@
CCLayerImpl::dumpLayerProperties(ts, indent);
}
+void CCPluginLayerImpl::didLoseAndRecreateGraphicsContext()
+{
+ if (m_ioSurfaceId) {
+ // We don't have a valid texture ID in the new context; however,
+ // the IOSurface is still valid.
+ m_ioSurfaceTextureId = 0;
+ m_ioSurfaceChanged = true;
+ }
+}
+
void CCPluginLayerImpl::setIOSurfaceProperties(int width, int height, uint32_t ioSurfaceId)
{
if (m_ioSurfaceId != ioSurfaceId)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h 2012-03-06 04:15:27 UTC (rev 109839)
@@ -50,6 +50,7 @@
typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexRectFlipAlpha> TexRectProgramFlip;
virtual void dumpLayerProperties(TextStream&, int indent) const;
+ virtual void didLoseAndRecreateGraphicsContext();
void setTextureId(unsigned id) { m_textureId = id; }
void setFlipped(bool flipped) { m_flipped = flipped; }
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (109838 => 109839)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-03-06 04:15:27 UTC (rev 109839)
@@ -159,8 +159,10 @@
DebugScopedSetImplThread impl;
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator());
initialized = m_layerTreeHostImpl->initializeLayerRenderer(context);
- if (initialized)
+ if (initialized) {
m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities();
+ m_layerTreeHostImpl->sendContextLostAndRestoredNotification();
+ }
}
if (initialized)
Modified: trunk/Source/WebKit/chromium/ChangeLog (109838 => 109839)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-03-06 04:15:27 UTC (rev 109839)
@@ -1,3 +1,21 @@
+2012-03-05 Kenneth Russell <[email protected]>
+
+ [chromium] Notify CCLayerImpl tree of context loss and restoration
+ https://bugs.webkit.org/show_bug.cgi?id=80339
+
+ Reviewed by James Robinson.
+
+ Unit test for notification of context loss and restoration.
+
+ * tests/CCLayerTreeHostImplTest.cpp:
+ (WebKit):
+ (ContextLostNotificationCheckLayer):
+ (WebKit::ContextLostNotificationCheckLayer::create):
+ (WebKit::ContextLostNotificationCheckLayer::didLoseAndRecreateGraphicsContext):
+ (WebKit::ContextLostNotificationCheckLayer::didLoseAndRecreateGraphicsContextCalled):
+ (WebKit::ContextLostNotificationCheckLayer::ContextLostNotificationCheckLayer):
+ (WebKit::TEST_F):
+
2012-03-05 Changhun Kang <[email protected]>
Change the argument orders to match OpenGL's in GraphicsContext3D functions
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (109838 => 109839)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-03-06 04:02:32 UTC (rev 109838)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-03-06 04:15:27 UTC (rev 109839)
@@ -865,4 +865,51 @@
EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height());
}
+// Make sure that context lost notifications are propagated through the tree.
+class ContextLostNotificationCheckLayer : public CCLayerImpl {
+public:
+ static PassOwnPtr<ContextLostNotificationCheckLayer> create(int id) { return adoptPtr(new ContextLostNotificationCheckLayer(id)); }
+
+ virtual void didLoseAndRecreateGraphicsContext()
+ {
+ m_didLoseAndRecreateGraphicsContextCalled = true;
+ }
+
+ bool didLoseAndRecreateGraphicsContextCalled() const { return m_didLoseAndRecreateGraphicsContextCalled; }
+
+private:
+ explicit ContextLostNotificationCheckLayer(int id)
+ : CCLayerImpl(id)
+ , m_didLoseAndRecreateGraphicsContextCalled(false)
+ {
+ }
+
+ bool m_didLoseAndRecreateGraphicsContextCalled;
+};
+
+TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers)
+{
+ m_hostImpl->initializeLayerRenderer(createContext());
+ m_hostImpl->setViewportSize(IntSize(10, 10));
+
+ m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(0));
+ ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificationCheckLayer*>(m_hostImpl->rootLayer());
+
+ root->addChild(ContextLostNotificationCheckLayer::create(1));
+ ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificationCheckLayer*>(root->children()[0].get());
+
+ layer1->addChild(ContextLostNotificationCheckLayer::create(2));
+ ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificationCheckLayer*>(layer1->children()[0].get());
+
+ EXPECT_FALSE(root->didLoseAndRecreateGraphicsContextCalled());
+ EXPECT_FALSE(layer1->didLoseAndRecreateGraphicsContextCalled());
+ EXPECT_FALSE(layer2->didLoseAndRecreateGraphicsContextCalled());
+
+ m_hostImpl->sendContextLostAndRestoredNotification();
+
+ EXPECT_TRUE(root->didLoseAndRecreateGraphicsContextCalled());
+ EXPECT_TRUE(layer1->didLoseAndRecreateGraphicsContextCalled());
+ EXPECT_TRUE(layer2->didLoseAndRecreateGraphicsContextCalled());
+}
+
} // namespace