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_layerTreeHost->needsOffscreenContext()) { | |
| 146 offscreenContext3d = m_layerTreeHost->client()->createOrGetOffscreenCont ext3dForMainThread(); | |
| 147 if (!offscreenContext3d || | |
| 148 !offscreenContext3d->makeContextCurrent() || | |
| 149 offscreenContext3d->getGraphicsResetStatusARB()) | |
| 150 { | |
|
piman
2013/02/05 22:42:48
nit: { on previous line
danakj
2013/02/05 22:56:00
Oh gosh this file has become a frankenstyle. :X
| |
| 151 return false; | |
| 152 } | |
| 153 offscreenGrContext = m_layerTreeHost->client()->createOrGetOffscreenGrCo ntextForMainThread(); | |
| 154 } | |
| 142 | 155 |
| 143 bool initialized; | 156 bool initialized; |
| 144 { | 157 { |
| 145 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); | 158 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
| 146 DebugScopedSetImplThread impl(this); | 159 DebugScopedSetImplThread impl(this); |
| 147 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider()); | 160 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider()); |
| 148 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ()); | 161 initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass ()); |
| 149 if (initialized) { | 162 if (initialized) { |
| 150 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); | 163 m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererC apabilities(); |
| 164 m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts( | |
| 165 offscreenContext3d, offscreenGrContext); | |
| 151 } | 166 } |
| 152 } | 167 } |
| 153 | 168 |
| 154 if (initialized) | 169 if (initialized) |
| 155 m_outputSurfaceLost = false; | 170 m_outputSurfaceLost = false; |
| 156 | 171 |
| 157 return initialized; | 172 return initialized; |
| 158 } | 173 } |
| 159 | 174 |
| 160 void SingleThreadProxy::renderingStats(RenderingStats* stats) | 175 void SingleThreadProxy::renderingStats(RenderingStats* stats) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 NOTREACHED(); | 376 NOTREACHED(); |
| 362 } | 377 } |
| 363 | 378 |
| 364 bool SingleThreadProxy::commitAndComposite() | 379 bool SingleThreadProxy::commitAndComposite() |
| 365 { | 380 { |
| 366 DCHECK(Proxy::isMainThread()); | 381 DCHECK(Proxy::isMainThread()); |
| 367 | 382 |
| 368 if (!m_layerTreeHost->initializeRendererIfNeeded()) | 383 if (!m_layerTreeHost->initializeRendererIfNeeded()) |
| 369 return false; | 384 return false; |
| 370 | 385 |
| 386 WebKit::WebGraphicsContext3D* offscreenContext3d = NULL; | |
| 387 GrContext* offscreenGrContext = NULL; | |
| 388 if (m_layerTreeHost->needsOffscreenContext()) { | |
| 389 offscreenContext3d = m_layerTreeHost->client()->createOrGetOffscreenCont ext3dForMainThread(); | |
| 390 offscreenGrContext = m_layerTreeHost->client()->createOrGetOffscreenGrCo ntextForMainThread(); | |
| 391 } | |
| 392 | |
| 371 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); | 393 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings(); |
| 372 | 394 |
| 373 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue); | 395 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue); |
| 374 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll ocationLimitBytes()); | 396 m_layerTreeHost->updateLayers(*(queue.get()), m_layerTreeHostImpl->memoryAll ocationLimitBytes()); |
| 375 | 397 |
| 376 m_layerTreeHost->willCommit(); | 398 m_layerTreeHost->willCommit(); |
| 377 doCommit(queue.Pass()); | 399 doCommit(queue.Pass()); |
| 378 bool result = doComposite(); | 400 bool result = doComposite(offscreenContext3d, offscreenGrContext); |
| 379 m_layerTreeHost->didBeginFrame(); | 401 m_layerTreeHost->didBeginFrame(); |
| 380 return result; | 402 return result; |
| 381 } | 403 } |
| 382 | 404 |
| 383 bool SingleThreadProxy::doComposite() | 405 bool SingleThreadProxy::doComposite(WebKit::WebGraphicsContext3D* offscreenC ontext3d, GrContext* offscreenGrContext) |
| 384 { | 406 { |
| 385 DCHECK(!m_outputSurfaceLost); | 407 DCHECK(!m_outputSurfaceLost); |
| 386 { | 408 { |
| 387 DebugScopedSetImplThread impl(this); | 409 DebugScopedSetImplThread impl(this); |
| 388 base::AutoReset<bool> markInside(&m_insideDraw, true); | 410 base::AutoReset<bool> markInside(&m_insideDraw, true); |
| 389 | 411 |
| 412 m_layerTreeHostImpl->resourceProvider()->setOffscreenContexts( | |
| 413 offscreenContext3d, offscreenGrContext); | |
| 414 | |
| 390 if (!m_layerTreeHostImpl->visible()) | 415 if (!m_layerTreeHostImpl->visible()) |
| 391 return false; | 416 return false; |
| 392 | 417 |
| 393 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); | 418 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); |
| 394 | 419 |
| 395 // We guard prepareToDraw() with canDraw() because it always returns a v alid frame, so can only | 420 // 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 | 421 // be used when such a frame is possible. Since drawLayers() depends on the result of |
| 397 // prepareToDraw(), it is guarded on canDraw() as well. | 422 // prepareToDraw(), it is guarded on canDraw() as well. |
| 398 if (!m_layerTreeHostImpl->canDraw()) | 423 if (!m_layerTreeHostImpl->canDraw()) |
| 399 return false; | 424 return false; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 429 } | 454 } |
| 430 | 455 |
| 431 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() | 456 skia::RefPtr<SkPicture> SingleThreadProxy::capturePicture() |
| 432 { | 457 { |
| 433 // Requires impl-side painting, which is only supported in threaded composit ing. | 458 // Requires impl-side painting, which is only supported in threaded composit ing. |
| 434 NOTREACHED(); | 459 NOTREACHED(); |
| 435 return skia::RefPtr<SkPicture>(); | 460 return skia::RefPtr<SkPicture>(); |
| 436 } | 461 } |
| 437 | 462 |
| 438 } // namespace cc | 463 } // namespace cc |
| OLD | NEW |