Chromium Code Reviews| 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" |
| 11 #include "cc/layer_tree_impl.h" | 11 #include "cc/layer_tree_impl.h" |
| 12 #include "cc/output_surface.h" | 12 #include "cc/output_surface.h" |
| 13 #include "cc/prioritized_resource_manager.h" | 13 #include "cc/prioritized_resource_manager.h" |
| 14 #include "cc/resource_update_controller.h" | 14 #include "cc/resource_update_controller.h" |
| 15 #include "cc/thread.h" | 15 #include "cc/thread.h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 | 19 |
| 19 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) | 20 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) |
| 20 { | 21 { |
| 21 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>() ; | 22 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>() ; |
| 22 } | 23 } |
| 23 | 24 |
| 24 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) | 25 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) |
| 25 : Proxy(scoped_ptr<Thread>(NULL)) | 26 : Proxy(scoped_ptr<Thread>(NULL)) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 133 |
| 133 bool SingleThreadProxy::recreateOutputSurface() | 134 bool SingleThreadProxy::recreateOutputSurface() |
| 134 { | 135 { |
| 135 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); | 136 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); |
| 136 DCHECK(Proxy::isMainThread()); | 137 DCHECK(Proxy::isMainThread()); |
| 137 DCHECK(m_outputSurfaceLost); | 138 DCHECK(m_outputSurfaceLost); |
| 138 | 139 |
| 139 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce(); | 140 scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurfa ce(); |
| 140 if (!outputSurface.get()) | 141 if (!outputSurface.get()) |
| 141 return false; | 142 return false; |
| 143 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL; | |
| 144 GrContext* offscreenGrContext = NULL; | |
| 145 if (m_RendererCapabilitiesForMainThread.usingOffscreenContext3d && m_layerTr eeHost->needsOffscreenContext()) { | |
| 146 offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForMai nThread(); | |
|
piman
2013/02/11 18:45:33
ForCompositorThread, no?
danakj
2013/02/11 18:58:13
No, this is single thread proxy, so it wants the m
| |
| 147 if (!offscreenContext3d || !offscreenContext3d->makeContextCurrent()) | |
| 148 return false; | |
| 149 offscreenGrContext = m_layerTreeHost->client()->OffscreenGrContextForMai nThread(); | |
| 150 } | |
| 142 | 151 |
| 143 bool initialized; | 152 bool initialized; |
| 144 { | 153 { |
| 145 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); | 154 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
| 146 DebugScopedSetImplThread impl(this); | 155 DebugScopedSetImplThread impl(this); |
| 147 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider()); | 156 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider()); |
| 148 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ()); | 157 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ()); |
| 149 if (initialized) { | 158 if (initialized) { |
| 150 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); | 159 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); |
| 160 m_layerTreeHostImpl->resourceProvider()->setGaneshContexts(offscreen Context3d, offscreenGrContext); | |
| 151 } | 161 } |
| 152 } | 162 } |
| 153 | 163 |
| 154 if (initialized) | 164 if (initialized) |
| 155 m_outputSurfaceLost = false; | 165 m_outputSurfaceLost = false; |
| 156 | 166 |
| 157 return initialized; | 167 return initialized; |
| 158 } | 168 } |
| 159 | 169 |
| 160 void SingleThreadProxy::renderingStats(RenderingStats* stats) | 170 void SingleThreadProxy::renderingStats(RenderingStats* stats) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 189 m_layerTreeHostImpl->beginCommit(); | 199 m_layerTreeHostImpl->beginCommit(); |
| 190 | 200 |
| 191 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackin gs(); | 201 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackin gs(); |
| 192 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); | 202 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); |
| 193 | 203 |
| 194 scoped_ptr<ResourceUpdateController> updateController = | 204 scoped_ptr<ResourceUpdateController> updateController = |
| 195 ResourceUpdateController::create( | 205 ResourceUpdateController::create( |
| 196 NULL, | 206 NULL, |
| 197 Proxy::mainThread(), | 207 Proxy::mainThread(), |
| 198 queue.Pass(), | 208 queue.Pass(), |
| 199 m_layerTreeHostImpl->resourceProvider(), | 209 m_layerTreeHostImpl->resourceProvider()); |
| 200 hasImplThread()); | |
| 201 updateController->finalize(); | 210 updateController->finalize(); |
| 202 | 211 |
| 203 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); | 212 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); |
| 204 | 213 |
| 205 m_layerTreeHostImpl->commitComplete(); | 214 m_layerTreeHostImpl->commitComplete(); |
| 206 | 215 |
| 207 #ifndef NDEBUG | 216 #ifndef NDEBUG |
| 208 // In the single-threaded case, the scroll deltas should never be | 217 // In the single-threaded case, the scroll deltas should never be |
| 209 // touched on the impl layer tree. | 218 // touched on the impl layer tree. |
| 210 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processS crollDeltas(); | 219 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_layerTreeHostImpl->processS crollDeltas(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 NOTREACHED(); | 370 NOTREACHED(); |
| 362 } | 371 } |
| 363 | 372 |
| 364 bool SingleThreadProxy::commitAndComposite() | 373 bool SingleThreadProxy::commitAndComposite() |
| 365 { | 374 { |
| 366 DCHECK(Proxy::isMainThread()); | 375 DCHECK(Proxy::isMainThread()); |
| 367 | 376 |
| 368 if (!m_layerTreeHost->initializeRendererIfNeeded()) | 377 if (!m_layerTreeHost->initializeRendererIfNeeded()) |
| 369 return false; | 378 return false; |
| 370 | 379 |
| 380 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL; | |
| 381 GrContext* offscreenGrContext = NULL; | |
| 382 if (m_RendererCapabilitiesForMainThread.usingOffscreenContext3d && m_layerTr eeHost->needsOffscreenContext()) { | |
| 383 offscreenContext3d = m_layerTreeHost->client()->OffscreenContext3dForMai nThread(); | |
| 384 offscreenGrContext = m_layerTreeHost->client()->OffscreenGrContextForMai nThread(); | |
| 385 } | |
| 386 | |
| 371 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); | 387 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); |
| 372 | 388 |
| 373 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue); | 389 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue); |
| 374 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll ocationLimitBytes()); | 390 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll ocationLimitBytes()); |
| 375 | 391 |
| 376 m_layerTreeHost->willCommit(); | 392 m_layerTreeHost->willCommit(); |
| 377 doCommit(queue.Pass()); | 393 doCommit(queue.Pass()); |
| 378 bool result = doComposite(); | 394 bool result = doComposite(offscreenContext3d, offscreenGrContext); |
| 379 m_layerTreeHost->didBeginFrame(); | 395 m_layerTreeHost->didBeginFrame(); |
| 380 return result; | 396 return result; |
| 381 } | 397 } |
| 382 | 398 |
| 383 bool SingleThreadProxy::doComposite() | 399 bool SingleThreadProxy::doComposite(WebKit::WebGraphicsContext3D* offscreenC ontext3d, GrContext* offscreenGrContext) |
| 384 { | 400 { |
| 385 DCHECK(!m_outputSurfaceLost); | 401 DCHECK(!m_outputSurfaceLost); |
| 386 { | 402 { |
| 387 DebugScopedSetImplThread impl(this); | 403 DebugScopedSetImplThread impl(this); |
| 388 base::AutoReset<bool> markInside(&m_insideDraw, true); | 404 base::AutoReset<bool> markInside(&m_insideDraw, true); |
| 389 | 405 |
| 406 m_layerTreeHostImpl->resourceProvider()->setGaneshContexts(offscreenCont ext3d, offscreenGrContext); | |
| 407 | |
| 390 if (!m_layerTreeHostImpl->visible()) | 408 if (!m_layerTreeHostImpl->visible()) |
| 391 return false; | 409 return false; |
| 392 | 410 |
| 393 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); | 411 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); |
| 394 | 412 |
| 395 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only | 413 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only |
| 396 // be used when such a frame is possible. Since drawLayers() depends on the result of | 414 // be used when such a frame is possible. Since drawLayers() depends on the result of |
| 397 // prepareToDraw(), it is guarded on canDraw() as well. | 415 // prepareToDraw(), it is guarded on canDraw() as well. |
| 398 if (!m_layerTreeHostImpl->canDraw()) | 416 if (!m_layerTreeHostImpl->canDraw()) |
| 399 return false; | 417 return false; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 429 } | 447 } |
| 430 | 448 |
| 431 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() | 449 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() |
| 432 { | 450 { |
| 433 // Requires impl-side painting, which is only supported in threaded composit ing. | 451 // Requires impl-side painting, which is only supported in threaded composit ing. |
| 434 NOTREACHED(); | 452 NOTREACHED(); |
| 435 return skia::RefPtr<SkPicture>(); | 453 return skia::RefPtr<SkPicture>(); |
| 436 } | 454 } |
| 437 | 455 |
| 438 } // namespace cc | 456 } // namespace cc |
| OLD | NEW |