Changeset 109411 in webkit
- Timestamp:
- Mar 1, 2012, 1:42:45 PM (15 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (modified) (8 diffs)
-
WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (modified) (6 diffs)
-
WebCore/platform/graphics/chromium/cc/CCProxy.h (modified) (2 diffs)
-
WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (modified) (9 diffs)
-
WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h (modified) (4 diffs)
-
WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (modified) (3 diffs)
-
WebCore/platform/graphics/chromium/cc/CCThreadProxy.h (modified) (1 diff)
-
WebKit/chromium/ChangeLog (modified) (1 diff)
-
WebKit/chromium/src/WebLayerTreeView.cpp (modified) (1 diff)
-
WebKit/chromium/src/WebLayerTreeViewImpl.cpp (modified) (2 diffs)
-
WebKit/chromium/src/WebLayerTreeViewImpl.h (modified) (1 diff)
-
WebKit/chromium/tests/CCLayerTreeHostTest.cpp (modified) (2 diffs)
-
WebKit/chromium/tests/FakeCCLayerTreeHostClient.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109406 r109411 1 2012-02-29 Nat Duca <nduca@chromium.org> 2 3 [chromium] Move context lost control code from CCSingleThreadProxy to CCLayerTreeHost 4 https://bugs.webkit.org/show_bug.cgi?id=79964 5 6 Reviewed by James Robinson. 7 8 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 9 (WebCore::CCLayerTreeHost::CCLayerTreeHost): 10 (WebCore::CCLayerTreeHost::initializeLayerRenderer): 11 (WebCore::CCLayerTreeHost::recreateContext): 12 (WebCore::CCLayerTreeHost::createContext): 13 (WebCore::CCLayerTreeHost::didLoseContext): 14 (WebCore::CCLayerTreeHost::compositeAndReadback): 15 (WebCore::CCLayerTreeHost::loseContext): 16 (WebCore::CCLayerTreeHost::updateLayers): 17 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 18 (CCLayerTreeHostClient): 19 (CCLayerTreeHost): 20 * platform/graphics/chromium/cc/CCProxy.h: 21 (CCProxy): 22 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: 23 (WebCore::CCSingleThreadProxy::CCSingleThreadProxy): 24 (WebCore::CCSingleThreadProxy::compositeAndReadback): 25 (WebCore::CCSingleThreadProxy::initializeContext): 26 (WebCore::CCSingleThreadProxy::recreateContext): 27 (WebCore): 28 (WebCore::CCSingleThreadProxy::loseContext): 29 (WebCore::CCSingleThreadProxy::compositeImmediately): 30 (WebCore::CCSingleThreadProxy::doComposite): 31 * platform/graphics/chromium/cc/CCSingleThreadProxy.h: 32 (CCSingleThreadProxy): 33 * platform/graphics/chromium/cc/CCThreadProxy.cpp: 34 (WebCore::CCThreadProxy::initializeContext): 35 (WebCore::CCThreadProxy::recreateContext): 36 (WebCore): 37 (WebCore::CCThreadProxy::loseContext): 38 * platform/graphics/chromium/cc/CCThreadProxy.h: 39 (CCThreadProxy): 40 1 41 2012-03-01 Abhishek Arya <inferno@chromium.org> 2 42 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r108886 r109411 67 67 , m_frameNumber(0) 68 68 , m_layerRendererInitialized(false) 69 , m_contextLost(false) 70 , m_numTimesRecreateShouldFail(0) 71 , m_numFailedRecreateAttempts(0) 69 72 , m_settings(settings) 70 73 , m_visible(true) … … 115 118 if (!m_proxy->initializeLayerRenderer()) { 116 119 // Uh oh, better tell the client that we can't do anything with this context. 117 m_client->didRecreate GraphicsContext(false);120 m_client->didRecreateContext(false); 118 121 return; 119 122 } … … 132 135 } 133 136 137 void CCLayerTreeHost::recreateContext() 138 { 139 TRACE_EVENT0("cc", "CCLayerTreeHost::recreateContext"); 140 ASSERT(m_contextLost); 141 142 bool recreated = false; 143 if (!m_numTimesRecreateShouldFail) 144 recreated = m_proxy->recreateContext(); 145 else 146 m_numTimesRecreateShouldFail--; 147 148 if (recreated) { 149 m_client->didRecreateContext(true); 150 m_contextLost = false; 151 return; 152 } 153 154 // Tolerate a certain number of recreation failures to work around races 155 // in the context-lost machinery. 156 m_numFailedRecreateAttempts++; 157 if (m_numFailedRecreateAttempts < 5) { 158 setNeedsCommit(); 159 return; 160 } 161 162 // We have tried too many times to recreate the context. Tell the host to fall 163 // back to software rendering. 164 m_client->didRecreateContext(false); 165 } 134 166 135 167 void CCLayerTreeHost::deleteContentsTexturesOnImplThread(TextureAllocator* allocator) … … 190 222 } 191 223 192 PassRefPtr<GraphicsContext3D> CCLayerTreeHost::create LayerTreeHostContext3D()193 { 194 return m_client->create LayerTreeHostContext3D();224 PassRefPtr<GraphicsContext3D> CCLayerTreeHost::createContext() 225 { 226 return m_client->createContext(); 195 227 } 196 228 … … 200 232 } 201 233 202 void CCLayerTreeHost::didRecreateGraphicsContext(bool success) 203 { 204 m_client->didRecreateGraphicsContext(success); 234 void CCLayerTreeHost::didLoseContext() 235 { 236 TRACE_EVENT("CCLayerTreeHost::didLoseContext", 0, this); 237 ASSERT(CCProxy::isMainThread()); 238 m_contextLost = true; 239 m_numFailedRecreateAttempts = 0; 240 setNeedsCommit(); 205 241 } 206 242 … … 217 253 initializeLayerRenderer(); 218 254 if (!m_layerRendererInitialized) 255 return false; 256 } 257 if (m_contextLost) { 258 recreateContext(); 259 if (m_contextLost) 219 260 return false; 220 261 } … … 352 393 } 353 394 354 void CCLayerTreeHost::loseCompositorContext(int numTimes) 355 { 356 m_proxy->loseCompositorContext(numTimes); 395 void CCLayerTreeHost::loseContext(int numTimes) 396 { 397 TRACE_EVENT1("cc", "CCLayerTreeHost::loseCompositorContext", "numTimes", numTimes); 398 m_numTimesRecreateShouldFail = numTimes - 1; 399 m_proxy->loseContext(); 357 400 } 358 401 … … 374 417 // If we couldn't initialize, then bail since we're returning to software mode. 375 418 if (!m_layerRendererInitialized) 419 return false; 420 } 421 if (m_contextLost) { 422 recreateContext(); 423 if (m_contextLost) 376 424 return false; 377 425 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r108880 r109411 56 56 virtual void layout() = 0; 57 57 virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0; 58 virtual PassRefPtr<GraphicsContext3D> create LayerTreeHostContext3D() = 0;59 virtual void didRecreate GraphicsContext(bool success) = 0;58 virtual PassRefPtr<GraphicsContext3D> createContext() = 0; 59 virtual void didRecreateContext(bool success) = 0; 60 60 virtual void didCommitAndDrawFrame() = 0; 61 61 virtual void didCompleteSwapBuffers() = 0; … … 131 131 void finishCommitOnImplThread(CCLayerTreeHostImpl*); 132 132 void commitComplete(); 133 PassRefPtr<GraphicsContext3D> create LayerTreeHostContext3D();133 PassRefPtr<GraphicsContext3D> createContext(); 134 134 virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient*); 135 135 void didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl*); 136 void did RecreateGraphicsContext(bool success);136 void didLoseContext(); 137 137 void didCommitAndDrawFrame() { m_client->didCommitAndDrawFrame(); } 138 138 void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); } 139 139 void deleteContentsTexturesOnImplThread(TextureAllocator*); 140 // Returns false if we should abort this frame due to initialization failure. 141 bool updateLayers(); 140 142 141 143 CCLayerTreeHostClient* client() { return m_client; } … … 160 162 161 163 // Test only hook 162 void loseCo mpositorContext(int numTimes);164 void loseContext(int numTimes); 163 165 164 166 void setNeedsAnimate(); … … 186 188 void setVisible(bool); 187 189 188 // Returns false if we should abort this frame due to initialization failure.189 bool updateLayers();190 191 190 void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec); 192 191 … … 208 207 209 208 void initializeLayerRenderer(); 209 void recreateContext(); 210 210 211 211 enum PaintType { PaintVisible, PaintIdle }; … … 231 231 OwnPtr<CCProxy> m_proxy; 232 232 bool m_layerRendererInitialized; 233 bool m_contextLost; 234 int m_numTimesRecreateShouldFail; 235 int m_numFailedRecreateAttempts; 233 236 234 237 RefPtr<LayerChromium> m_rootLayer; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
r107357 r109411 71 71 virtual bool initializeLayerRenderer() = 0; 72 72 73 // Attempts to recreate the context and layer renderer after a context lost. Returns false if the renderer couldn't be 74 // reinitialized. 75 virtual bool recreateContext() = 0; 76 73 77 virtual int compositorIdentifier() const = 0; 74 78 … … 96 100 97 101 // Testing hooks 98 virtual void loseCo mpositorContext(int numTimes) = 0;102 virtual void loseContext() = 0; 99 103 100 104 #ifndef NDEBUG -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
r108581 r109411 46 46 CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost) 47 47 : m_layerTreeHost(layerTreeHost) 48 , m_contextLost(false) 48 49 , m_compositorIdentifier(-1) 49 50 , m_layerRendererInitialized(false) 50 , m_numFailedRecreateAttempts(0)51 , m_graphicsContextLost(false)52 , m_timesRecreateShouldFail(0)53 51 , m_nextFrameIsNewlyCommittedFrame(false) 54 52 { … … 74 72 TRACE_EVENT("CCSingleThreadProxy::compositeAndReadback", this, 0); 75 73 ASSERT(CCProxy::isMainThread()); 76 77 if (!recreateContextIfNeeded()) {78 TRACE_EVENT("compositeAndReadback_EarlyOut_ContextLost", this, 0);79 return false;80 }81 74 82 75 if (!commitIfNeeded()) … … 126 119 { 127 120 ASSERT(CCProxy::isMainThread()); 128 RefPtr<GraphicsContext3D> context = m_layerTreeHost->create LayerTreeHostContext3D();121 RefPtr<GraphicsContext3D> context = m_layerTreeHost->createContext(); 129 122 if (!context) 130 123 return false; … … 149 142 } 150 143 144 bool CCSingleThreadProxy::recreateContext() 145 { 146 TRACE_EVENT0("cc", "CCSingleThreadProxy::recreateContext"); 147 ASSERT(CCProxy::isMainThread()); 148 ASSERT(m_contextLost); 149 150 RefPtr<GraphicsContext3D> context = m_layerTreeHost->createContext(); 151 if (!context) 152 return false; 153 154 ASSERT(context->hasOneRef()); 155 bool initialized; 156 { 157 DebugScopedSetImplThread impl; 158 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); 159 initialized = m_layerTreeHostImpl->initializeLayerRenderer(context); 160 if (initialized) 161 m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities(); 162 } 163 164 if (initialized) 165 m_contextLost = false; 166 167 return initialized; 168 } 169 151 170 const LayerRendererCapabilities& CCSingleThreadProxy::layerRendererCapabilities() const 152 171 { … … 156 175 } 157 176 158 void CCSingleThreadProxy::loseCompositorContext(int numTimes) 159 { 160 m_graphicsContextLost = true; 161 m_timesRecreateShouldFail = numTimes - 1; 177 void CCSingleThreadProxy::loseContext() 178 { 179 ASSERT(CCProxy::isMainThread()); 180 m_layerTreeHost->didLoseContext(); 181 m_contextLost = true; 162 182 } 163 183 … … 244 264 void CCSingleThreadProxy::compositeImmediately() 245 265 { 246 if (!recreateContextIfNeeded())247 return;248 249 266 if (!commitIfNeeded()) 250 267 return; … … 254 271 } 255 272 256 bool CCSingleThreadProxy::recreateContextIfNeeded()257 {258 ASSERT(CCProxy::isMainThread());259 260 if (!m_graphicsContextLost && m_layerTreeHostImpl->isContextLost()) {261 m_graphicsContextLost = true;262 m_numFailedRecreateAttempts = 0;263 }264 265 if (!m_graphicsContextLost)266 return true;267 RefPtr<GraphicsContext3D> context;268 if (!m_timesRecreateShouldFail)269 context = m_layerTreeHost->createLayerTreeHostContext3D();270 else271 m_timesRecreateShouldFail--;272 273 if (context) {274 ASSERT(context->hasOneRef());275 bool ok;276 {277 DebugScopedSetImplThread impl;278 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator());279 ok = m_layerTreeHostImpl->initializeLayerRenderer(context);280 if (ok)281 m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities();282 }283 if (ok) {284 m_layerTreeHost->didRecreateGraphicsContext(true);285 m_graphicsContextLost = false;286 return true;287 }288 }289 290 // Tolerate a certain number of recreation failures to work around races291 // in the context-lost machinery.292 m_numFailedRecreateAttempts++;293 if (m_numFailedRecreateAttempts < 5) {294 setNeedsCommit();295 return false;296 }297 298 // We have tried too many times to recreate the context. Tell the host to fall299 // back to software rendering.300 m_layerTreeHost->didRecreateGraphicsContext(false);301 return false;302 }303 304 273 bool CCSingleThreadProxy::commitIfNeeded() 305 274 { … … 315 284 bool CCSingleThreadProxy::doComposite() 316 285 { 317 ASSERT(!m_graphicsContextLost); 318 286 ASSERT(!m_contextLost); 319 287 { 320 288 DebugScopedSetImplThread impl; … … 325 293 326 294 if (m_layerTreeHostImpl->isContextLost()) { 327 // Trying to recover the context right here will not work if GPU process 328 // died. This is because GpuChannelHost::OnErrorMessage will only be 329 // called at the next iteration of the message loop, reverting our 330 // recovery attempts here. Instead, we detach the root layer from the 331 // renderer, recreate the renderer at the next message loop iteration 332 // and request a repaint yet again. 333 m_graphicsContextLost = true; 334 m_numFailedRecreateAttempts = 0; 335 setNeedsCommit(); 295 m_contextLost = true; 296 m_layerTreeHost->didLoseContext(); 336 297 return false; 337 298 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r108581 r109411 50 50 virtual bool initializeContext(); 51 51 virtual bool initializeLayerRenderer(); 52 virtual bool recreateContext(); 52 53 virtual int compositorIdentifier() const { return m_compositorIdentifier; } 53 54 virtual const LayerRendererCapabilities& layerRendererCapabilities() const; 54 virtual void loseCo mpositorContext(int numTimes);55 virtual void loseContext(); 55 56 virtual void setNeedsAnimate(); 56 57 virtual void setNeedsCommit(); … … 72 73 private: 73 74 explicit CCSingleThreadProxy(CCLayerTreeHost*); 74 bool recreateContextIfNeeded(); 75 75 76 bool commitIfNeeded(); 76 77 void doCommit(); … … 79 80 // Accessed on main thread only. 80 81 CCLayerTreeHost* m_layerTreeHost; 82 bool m_contextLost; 81 83 int m_compositorIdentifier; 82 84 … … 90 92 LayerRendererCapabilities m_layerRendererCapabilitiesForMainThread; 91 93 92 int m_numFailedRecreateAttempts;93 bool m_graphicsContextLost;94 int m_timesRecreateShouldFail; // Used during testing.95 94 bool m_nextFrameIsNewlyCommittedFrame; 96 95 }; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
r108581 r109411 171 171 { 172 172 TRACE_EVENT("CCThreadProxy::initializeContext", this, 0); 173 RefPtr<GraphicsContext3D> context = m_layerTreeHost->create LayerTreeHostContext3D();173 RefPtr<GraphicsContext3D> context = m_layerTreeHost->createContext(); 174 174 if (!context) 175 175 return false; … … 206 206 } 207 207 208 bool CCThreadProxy::recreateContext() 209 { 210 ASSERT_NOT_REACHED(); 211 return false; 212 } 213 208 214 int CCThreadProxy::compositorIdentifier() const 209 215 { … … 218 224 } 219 225 220 void CCThreadProxy::loseCo mpositorContext(int numTimes)226 void CCThreadProxy::loseContext() 221 227 { 222 228 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
r108581 r109411 57 57 virtual bool initializeContext(); 58 58 virtual bool initializeLayerRenderer(); 59 virtual bool recreateContext(); 59 60 virtual int compositorIdentifier() const; 60 61 virtual const LayerRendererCapabilities& layerRendererCapabilities() const; 61 virtual void loseCo mpositorContext(int numTimes);62 virtual void loseContext(); 62 63 virtual void setNeedsAnimate(); 63 64 virtual void setNeedsCommit(); -
trunk/Source/WebKit/chromium/ChangeLog
r109350 r109411 1 2012-02-29 Nat Duca <nduca@chromium.org> 2 3 [chromium] Move context lost control code from CCSingleThreadProxy to CCLayerTreeHost 4 https://bugs.webkit.org/show_bug.cgi?id=79964 5 6 Reviewed by James Robinson. 7 8 * src/WebLayerTreeView.cpp: 9 (WebKit::WebLayerTreeView::loseCompositorContext): 10 * src/WebLayerTreeViewImpl.cpp: 11 (WebKit::WebLayerTreeViewImpl::createContext): 12 (WebKit::WebLayerTreeViewImpl::didRecreateContext): 13 * src/WebLayerTreeViewImpl.h: 14 (WebLayerTreeViewImpl): 15 * tests/CCLayerTreeHostTest.cpp: 16 (WTF::MockLayerTreeHostClient::createContext): 17 (WTF::MockLayerTreeHostClient::didRecreateContext): 18 * tests/FakeCCLayerTreeHostClient.h: 19 (WebCore::FakeCCLayerTreeHostClient::createContext): 20 (WebCore::FakeCCLayerTreeHostClient::didRecreateContext): 21 1 22 2012-03-01 Kentaro Hara <haraken@chromium.org> 2 23 -
trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp
r108883 r109411 153 153 void WebLayerTreeView::loseCompositorContext(int numTimes) 154 154 { 155 m_private->loseCo mpositorContext(numTimes);155 m_private->loseContext(numTimes); 156 156 } 157 157 -
trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp
r108883 r109411 79 79 } 80 80 81 PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::create LayerTreeHostContext3D()81 PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::createContext() 82 82 { 83 83 if (!m_client) … … 90 90 } 91 91 92 void WebLayerTreeViewImpl::didRecreate GraphicsContext(bool success)92 void WebLayerTreeViewImpl::didRecreateContext(bool success) 93 93 { 94 94 if (m_client) -
trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h
r104248 r109411 45 45 virtual void layout(); 46 46 virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale); 47 virtual PassRefPtr<WebCore::GraphicsContext3D> create LayerTreeHostContext3D();48 virtual void didRecreate GraphicsContext(bool success);47 virtual PassRefPtr<WebCore::GraphicsContext3D> createContext(); 48 virtual void didRecreateContext(bool success); 49 49 virtual void didCommitAndDrawFrame(); 50 50 virtual void didCompleteSwapBuffers(); -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r108880 r109411 228 228 } 229 229 230 virtual PassRefPtr<GraphicsContext3D> create LayerTreeHostContext3D()230 virtual PassRefPtr<GraphicsContext3D> createContext() 231 231 { 232 232 GraphicsContext3D::Attributes attrs; … … 246 246 } 247 247 248 virtual void didRecreate GraphicsContext(bool)248 virtual void didRecreateContext(bool) 249 249 { 250 250 } -
trunk/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h
r106243 r109411 38 38 virtual void layout() { } 39 39 virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { } 40 virtual PassRefPtr<GraphicsContext3D> create LayerTreeHostContext3D()40 virtual PassRefPtr<GraphicsContext3D> createContext() 41 41 { 42 42 GraphicsContext3D::Attributes attrs; 43 43 return createCompositorMockGraphicsContext3D(attrs); 44 44 } 45 virtual void didRecreate GraphicsContext(bool success) { }45 virtual void didRecreateContext(bool success) { } 46 46 virtual void didCommitAndDrawFrame() { } 47 47 virtual void didCompleteSwapBuffers() { }
Note:
See TracChangeset
for help on using the changeset viewer.