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/trees/single_thread_proxy.h" | 5 #include "cc/trees/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/base/thread.h" | 9 #include "cc/base/thread.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| 11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
| 12 #include "cc/quads/draw_quad.h" | 12 #include "cc/quads/draw_quad.h" |
| 13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
| 14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
| 15 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
| 16 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 scoped_ptr<Proxy> SingleThreadProxy::Create(LayerTreeHost* layer_tree_host) { | 20 scoped_ptr<Proxy> SingleThreadProxy::Create(LayerTreeHost* layer_tree_host) { |
| 21 return make_scoped_ptr( | 21 return make_scoped_ptr( |
| 22 new SingleThreadProxy(layer_tree_host)).PassAs<Proxy>(); | 22 new SingleThreadProxy(layer_tree_host)).PassAs<Proxy>(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host) | 25 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host) |
| 26 : Proxy(scoped_ptr<Thread>(NULL)), | 26 : Proxy(scoped_ptr<Thread>(NULL)), |
| 27 layer_tree_host_(layer_tree_host), | 27 layer_tree_host_(layer_tree_host), |
| 28 created_offscreen_context_provider_(false), | 28 created_offscreen_context_provider_(false), |
| 29 initializing_new_output_surface_(false), | |
| 29 next_frame_is_newly_committed_frame_(false), | 30 next_frame_is_newly_committed_frame_(false), |
| 30 inside_draw_(false) { | 31 inside_draw_(false) { |
| 31 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 32 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 32 DCHECK(Proxy::IsMainThread()); | 33 DCHECK(Proxy::IsMainThread()); |
| 33 DCHECK(layer_tree_host); | 34 DCHECK(layer_tree_host); |
| 34 | 35 |
| 35 // Impl-side painting not supported without threaded compositing. | 36 // Impl-side painting not supported without threaded compositing. |
| 36 CHECK(!layer_tree_host->settings().impl_side_painting) | 37 CHECK(!layer_tree_host->settings().impl_side_painting) |
| 37 << "Threaded compositing must be enabled to use impl-side painting."; | 38 << "Threaded compositing must be enabled to use impl-side painting."; |
| 38 } | 39 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 layer_tree_host_impl_->resource_provider()); | 132 layer_tree_host_impl_->resource_provider()); |
| 132 } | 133 } |
| 133 | 134 |
| 134 bool initialized; | 135 bool initialized; |
| 135 { | 136 { |
| 136 DebugScopedSetImplThread impl(this); | 137 DebugScopedSetImplThread impl(this); |
| 137 | 138 |
| 138 DCHECK(output_surface); | 139 DCHECK(output_surface); |
| 139 initialized = layer_tree_host_impl_->InitializeRenderer( | 140 initialized = layer_tree_host_impl_->InitializeRenderer( |
| 140 output_surface.Pass()); | 141 output_surface.Pass()); |
| 141 if (initialized) { | 142 initializing_new_output_surface_ = true; |
|
danakj
2013/05/24 19:02:30
You can use base::AutoReset<bool> for a bit more c
| |
| 142 renderer_capabilities_for_main_thread_ = | 143 DidUpdateCapabilitiesOnImplThread(initialized, offscreen_context_provider); |
| 143 layer_tree_host_impl_->GetRendererCapabilities(); | 144 initializing_new_output_surface_ = false; |
| 144 | |
| 145 layer_tree_host_impl_->resource_provider()-> | |
| 146 set_offscreen_context_provider(offscreen_context_provider); | |
| 147 } else if (offscreen_context_provider) { | |
| 148 offscreen_context_provider->VerifyContexts(); | |
| 149 } | |
| 150 } | 145 } |
| 151 | 146 |
| 152 OnOutputSurfaceInitializeAttempted(initialized); | 147 OnOutputSurfaceInitializeAttempted(initialized); |
| 153 } | 148 } |
| 154 | 149 |
| 150 void SingleThreadProxy::DidUpdateCapabilitiesOnImplThread( | |
| 151 bool success, | |
| 152 scoped_refptr<ContextProvider> offscreen_context_provider) { | |
| 153 if (success) { | |
| 154 renderer_capabilities_for_main_thread_ = | |
| 155 layer_tree_host_impl_->GetRendererCapabilities(); | |
| 156 | |
| 157 layer_tree_host_impl_->resource_provider()-> | |
| 158 set_offscreen_context_provider(offscreen_context_provider); | |
| 159 | |
| 160 if (!initializing_new_output_surface_) { | |
| 161 DebugScopedSetMainThread main(this); | |
| 162 layer_tree_host_->DidUpdateCapabilities(); | |
| 163 } | |
| 164 } else if (offscreen_context_provider) { | |
| 165 offscreen_context_provider->VerifyContexts(); | |
| 166 } | |
| 167 } | |
| 168 | |
| 155 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { | 169 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { |
| 156 LayerTreeHost::CreateResult result = | 170 LayerTreeHost::CreateResult result = |
| 157 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 171 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
| 158 if (result == LayerTreeHost::CreateFailedButTryAgain) { | 172 if (result == LayerTreeHost::CreateFailedButTryAgain) { |
| 159 // Force another recreation attempt to happen by requesting another commit. | 173 // Force another recreation attempt to happen by requesting another commit. |
| 160 SetNeedsCommit(); | 174 SetNeedsCommit(); |
| 161 } | 175 } |
| 162 } | 176 } |
| 163 | 177 |
| 164 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 178 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 | 492 |
| 479 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 493 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 480 | 494 |
| 481 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { | 495 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { |
| 482 // Impl-side painting only. | 496 // Impl-side painting only. |
| 483 NOTREACHED(); | 497 NOTREACHED(); |
| 484 return skia::RefPtr<SkPicture>(); | 498 return skia::RefPtr<SkPicture>(); |
| 485 } | 499 } |
| 486 | 500 |
| 487 } // namespace cc | 501 } // namespace cc |
| OLD | NEW |