OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/single_thread_proxy.h" | 5 #include "cc/single_thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/draw_quad.h" | 9 #include "cc/draw_quad.h" |
10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 bool SingleThreadProxy::recreateOutputSurface() | 133 bool SingleThreadProxy::recreateOutputSurface() |
134 { | 134 { |
135 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); | 135 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); |
136 DCHECK(Proxy::isMainThread()); | 136 DCHECK(Proxy::isMainThread()); |
137 DCHECK(m_outputSurfaceLost); | 137 DCHECK(m_outputSurfaceLost); |
138 | 138 |
139 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa
ce(); | 139 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa
ce(); |
140 if (!outputSurface.get()) | 140 if (!outputSurface.get()) |
141 return false; | 141 return false; |
| 142 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL; |
| 143 GrContext* offscreenGrContext = NULL; |
| 144 if (m_RendererCapabilitiesForMainThread.usingOffscreenContext3d && m_layerTr
eeHost->needsOffscreenContext()) { |
| 145 offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForMai
nThread(); |
| 146 if (!offscreenContext3d) |
| 147 return false; |
| 148 offscreenGrContext = m_layerTreeHost->client()->OffscreenGrContextForMai
nThread(); |
| 149 } |
142 | 150 |
143 bool initialized; | 151 bool initialized; |
144 { | 152 { |
145 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); | 153 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
146 DebugScopedSetImplThread impl(this); | 154 DebugScopedSetImplThread impl(this); |
147 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl-
>resourceProvider()); | 155 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl-
>resourceProvider()); |
148 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass
()); | 156 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass
()); |
149 if (initialized) { | 157 if (initialized) { |
150 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC
apabilities(); | 158 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC
apabilities(); |
| 159 m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts(offscr
eenContext3d, offscreenGrContext); |
151 } | 160 } |
152 } | 161 } |
153 | 162 |
154 if (initialized) | 163 if (initialized) |
155 m_outputSurfaceLost = false; | 164 m_outputSurfaceLost = false; |
156 | 165 |
157 return initialized; | 166 return initialized; |
158 } | 167 } |
159 | 168 |
160 void SingleThreadProxy::renderingStats(RenderingStats* stats) | 169 void SingleThreadProxy::renderingStats(RenderingStats* stats) |
(...skipping 28 matching lines...) Expand all Loading... |
189 m_layerTreeHostImpl->beginCommit(); | 198 m_layerTreeHostImpl->beginCommit(); |
190 | 199 |
191 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackin
gs(); | 200 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackin
gs(); |
192 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); | 201 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); |
193 | 202 |
194 scoped_ptr<ResourceUpdateController> updateController = | 203 scoped_ptr<ResourceUpdateController> updateController = |
195 ResourceUpdateController::create( | 204 ResourceUpdateController::create( |
196 NULL, | 205 NULL, |
197 Proxy::mainThread(), | 206 Proxy::mainThread(), |
198 queue.Pass(), | 207 queue.Pass(), |
199 m_layerTreeHostImpl->resourceProvider(), | 208 m_layerTreeHostImpl->resourceProvider()); |
200 hasImplThread()); | |
201 updateController->finalize(); | 209 updateController->finalize(); |
202 | 210 |
203 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); | 211 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); |
204 | 212 |
205 m_layerTreeHostImpl->commitComplete(); | 213 m_layerTreeHostImpl->commitComplete(); |
206 | 214 |
207 #ifndef NDEBUG | 215 #ifndef NDEBUG |
208 // In the single-threaded case, the scroll deltas should never be | 216 // In the single-threaded case, the scroll deltas should never be |
209 // touched on the impl layer tree. | 217 // touched on the impl layer tree. |
210 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processS
crollDeltas(); | 218 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processS
crollDeltas(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 NOTREACHED(); | 383 NOTREACHED(); |
376 } | 384 } |
377 | 385 |
378 bool SingleThreadProxy::commitAndComposite() | 386 bool SingleThreadProxy::commitAndComposite() |
379 { | 387 { |
380 DCHECK(Proxy::isMainThread()); | 388 DCHECK(Proxy::isMainThread()); |
381 | 389 |
382 if (!m_layerTreeHost->initializeRendererIfNeeded()) | 390 if (!m_layerTreeHost->initializeRendererIfNeeded()) |
383 return false; | 391 return false; |
384 | 392 |
| 393 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL; |
| 394 GrContext* offscreenGrContext = NULL; |
| 395 if (m_RendererCapabilitiesForMainThread.usingOffscreenContext3d && m_layerTr
eeHost->needsOffscreenContext()) { |
| 396 offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForMai
nThread(); |
| 397 offscreenGrContext = m_layerTreeHost->client()->OffscreenGrContextForMai
nThread(); |
| 398 } |
| 399 |
385 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); | 400 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); |
386 | 401 |
387 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu
eue); | 402 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu
eue); |
388 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll
ocationLimitBytes()); | 403 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll
ocationLimitBytes()); |
389 | 404 |
390 m_layerTreeHost->willCommit(); | 405 m_layerTreeHost->willCommit(); |
391 doCommit(queue.Pass()); | 406 doCommit(queue.Pass()); |
392 bool result = doComposite(); | 407 bool result = doComposite(offscreenContext3d, offscreenGrContext); |
393 m_layerTreeHost->didBeginFrame(); | 408 m_layerTreeHost->didBeginFrame(); |
394 return result; | 409 return result; |
395 } | 410 } |
396 | 411 |
397 bool SingleThreadProxy::doComposite() | 412 bool SingleThreadProxy::doComposite(WebKit::WebGraphicsContext3D* offscreenC
ontext3d, GrContext* offscreenGrContext) |
398 { | 413 { |
399 DCHECK(!m_outputSurfaceLost); | 414 DCHECK(!m_outputSurfaceLost); |
400 { | 415 { |
401 DebugScopedSetImplThread impl(this); | 416 DebugScopedSetImplThread impl(this); |
402 base::AutoReset<bool> markInside(&m_insideDraw, true); | 417 base::AutoReset<bool> markInside(&m_insideDraw, true); |
403 | 418 |
| 419 m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts(offscreenC
ontext3d, offscreenGrContext); |
| 420 |
404 if (!m_layerTreeHostImpl->visible()) | 421 if (!m_layerTreeHostImpl->visible()) |
405 return false; | 422 return false; |
406 | 423 |
407 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); | 424 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); |
408 | 425 |
409 // We guard prepareToDraw() with canDraw() because it always returns a v
alid frame, so can only | 426 // We guard prepareToDraw() with canDraw() because it always returns a v
alid frame, so can only |
410 // be used when such a frame is possible. Since drawLayers() depends on
the result of | 427 // be used when such a frame is possible. Since drawLayers() depends on
the result of |
411 // prepareToDraw(), it is guarded on canDraw() as well. | 428 // prepareToDraw(), it is guarded on canDraw() as well. |
412 if (!m_layerTreeHostImpl->canDraw()) | 429 if (!m_layerTreeHostImpl->canDraw()) |
413 return false; | 430 return false; |
(...skipping 29 matching lines...) Expand all Loading... |
443 } | 460 } |
444 | 461 |
445 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() | 462 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() |
446 { | 463 { |
447 // Requires impl-side painting, which is only supported in threaded composit
ing. | 464 // Requires impl-side painting, which is only supported in threaded composit
ing. |
448 NOTREACHED(); | 465 NOTREACHED(); |
449 return skia::RefPtr<SkPicture>(); | 466 return skia::RefPtr<SkPicture>(); |
450 } | 467 } |
451 | 468 |
452 } // namespace cc | 469 } // namespace cc |
OLD | NEW |