| 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/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.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/blocking_task_runner.h" | 15 #include "cc/trees/blocking_task_runner.h" |
| 16 #include "cc/trees/layer_tree_host.h" | 16 #include "cc/trees/layer_tree_host.h" |
| 17 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 17 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
| 18 #include "ui/gfx/frame_time.h" | 19 #include "ui/gfx/frame_time.h" |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 | 22 |
| 22 scoped_ptr<Proxy> SingleThreadProxy::Create(LayerTreeHost* layer_tree_host) { | 23 scoped_ptr<Proxy> SingleThreadProxy::Create( |
| 24 LayerTreeHost* layer_tree_host, |
| 25 LayerTreeHostSingleThreadClient* client) { |
| 23 return make_scoped_ptr( | 26 return make_scoped_ptr( |
| 24 new SingleThreadProxy(layer_tree_host)).PassAs<Proxy>(); | 27 new SingleThreadProxy(layer_tree_host, client)).PassAs<Proxy>(); |
| 25 } | 28 } |
| 26 | 29 |
| 27 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host) | 30 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, |
| 31 LayerTreeHostSingleThreadClient* client) |
| 28 : Proxy(NULL), | 32 : Proxy(NULL), |
| 29 layer_tree_host_(layer_tree_host), | 33 layer_tree_host_(layer_tree_host), |
| 34 client_(client), |
| 30 created_offscreen_context_provider_(false), | 35 created_offscreen_context_provider_(false), |
| 31 next_frame_is_newly_committed_frame_(false), | 36 next_frame_is_newly_committed_frame_(false), |
| 32 inside_draw_(false) { | 37 inside_draw_(false) { |
| 33 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 38 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 34 DCHECK(Proxy::IsMainThread()); | 39 DCHECK(Proxy::IsMainThread()); |
| 35 DCHECK(layer_tree_host); | 40 DCHECK(layer_tree_host); |
| 36 | 41 |
| 37 // Impl-side painting not supported without threaded compositing. | 42 // Impl-side painting not supported without threaded compositing. |
| 38 CHECK(!layer_tree_host->settings().impl_side_painting) | 43 CHECK(!layer_tree_host->settings().impl_side_painting) |
| 39 << "Threaded compositing must be enabled to use impl-side painting."; | 44 << "Threaded compositing must be enabled to use impl-side painting."; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return renderer_capabilities_for_main_thread_; | 176 return renderer_capabilities_for_main_thread_; |
| 172 } | 177 } |
| 173 | 178 |
| 174 void SingleThreadProxy::SetNeedsAnimate() { | 179 void SingleThreadProxy::SetNeedsAnimate() { |
| 175 // Thread-only feature. | 180 // Thread-only feature. |
| 176 NOTREACHED(); | 181 NOTREACHED(); |
| 177 } | 182 } |
| 178 | 183 |
| 179 void SingleThreadProxy::SetNeedsUpdateLayers() { | 184 void SingleThreadProxy::SetNeedsUpdateLayers() { |
| 180 DCHECK(Proxy::IsMainThread()); | 185 DCHECK(Proxy::IsMainThread()); |
| 181 layer_tree_host_->ScheduleComposite(); | 186 client_->ScheduleComposite(); |
| 182 } | 187 } |
| 183 | 188 |
| 184 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { | 189 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { |
| 185 DCHECK(Proxy::IsMainThread()); | 190 DCHECK(Proxy::IsMainThread()); |
| 186 // Commit immediately. | 191 // Commit immediately. |
| 187 { | 192 { |
| 188 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 193 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 189 DebugScopedSetImplThread impl(this); | 194 DebugScopedSetImplThread impl(this); |
| 190 | 195 |
| 191 // This CapturePostTasks should be destroyed before CommitComplete() is | 196 // This CapturePostTasks should be destroyed before CommitComplete() is |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( | 235 BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( |
| 231 stats_instrumentation->main_thread_rendering_stats()); | 236 stats_instrumentation->main_thread_rendering_stats()); |
| 232 stats_instrumentation->AccumulateAndClearMainThreadStats(); | 237 stats_instrumentation->AccumulateAndClearMainThreadStats(); |
| 233 } | 238 } |
| 234 layer_tree_host_->CommitComplete(); | 239 layer_tree_host_->CommitComplete(); |
| 235 next_frame_is_newly_committed_frame_ = true; | 240 next_frame_is_newly_committed_frame_ = true; |
| 236 } | 241 } |
| 237 | 242 |
| 238 void SingleThreadProxy::SetNeedsCommit() { | 243 void SingleThreadProxy::SetNeedsCommit() { |
| 239 DCHECK(Proxy::IsMainThread()); | 244 DCHECK(Proxy::IsMainThread()); |
| 240 layer_tree_host_->ScheduleComposite(); | 245 client_->ScheduleComposite(); |
| 241 } | 246 } |
| 242 | 247 |
| 243 void SingleThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) { | 248 void SingleThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) { |
| 244 SetNeedsRedrawRectOnImplThread(damage_rect); | 249 SetNeedsRedrawRectOnImplThread(damage_rect); |
| 250 client_->ScheduleComposite(); |
| 245 } | 251 } |
| 246 | 252 |
| 247 void SingleThreadProxy::SetNextCommitWaitsForActivation() { | 253 void SingleThreadProxy::SetNextCommitWaitsForActivation() { |
| 248 // There is no activation here other than commit. So do nothing. | 254 // There is no activation here other than commit. So do nothing. |
| 249 } | 255 } |
| 250 | 256 |
| 251 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { | 257 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
| 252 // Thread-only feature. | 258 // Thread-only feature. |
| 253 NOTREACHED(); | 259 NOTREACHED(); |
| 254 } | 260 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 279 DCHECK(Proxy::IsImplThread()); | 285 DCHECK(Proxy::IsImplThread()); |
| 280 UpdateBackgroundAnimateTicking(); | 286 UpdateBackgroundAnimateTicking(); |
| 281 } | 287 } |
| 282 | 288 |
| 283 void SingleThreadProxy::NotifyReadyToActivate() { | 289 void SingleThreadProxy::NotifyReadyToActivate() { |
| 284 // Thread-only feature. | 290 // Thread-only feature. |
| 285 NOTREACHED(); | 291 NOTREACHED(); |
| 286 } | 292 } |
| 287 | 293 |
| 288 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 294 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
| 289 layer_tree_host_->ScheduleComposite(); | 295 client_->ScheduleComposite(); |
| 290 } | 296 } |
| 291 | 297 |
| 292 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { | 298 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { |
| 293 // Thread-only/Impl-side-painting-only feature. | 299 // Thread-only/Impl-side-painting-only feature. |
| 294 NOTREACHED(); | 300 NOTREACHED(); |
| 295 } | 301 } |
| 296 | 302 |
| 297 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) { | 303 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) { |
| 298 // TODO(brianderson): Once we move render_widget scheduling into this class, | 304 // TODO(brianderson): Once we move render_widget scheduling into this class, |
| 299 // we can treat redraw requests more efficiently than CommitAndRedraw | 305 // we can treat redraw requests more efficiently than CommitAndRedraw |
| 300 // requests. | 306 // requests. |
| 301 layer_tree_host_impl_->SetViewportDamage(damage_rect); | 307 layer_tree_host_impl_->SetViewportDamage(damage_rect); |
| 302 SetNeedsCommit(); | 308 SetNeedsCommit(); |
| 303 } | 309 } |
| 304 | 310 |
| 305 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { | 311 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { |
| 306 // Impl-side painting only. | 312 // Impl-side painting only. |
| 307 NOTREACHED(); | 313 NOTREACHED(); |
| 308 } | 314 } |
| 309 | 315 |
| 310 void SingleThreadProxy::SetNeedsCommitOnImplThread() { | 316 void SingleThreadProxy::SetNeedsCommitOnImplThread() { |
| 311 layer_tree_host_->ScheduleComposite(); | 317 client_->ScheduleComposite(); |
| 312 } | 318 } |
| 313 | 319 |
| 314 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 320 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| 315 scoped_ptr<AnimationEventsVector> events, | 321 scoped_ptr<AnimationEventsVector> events, |
| 316 base::Time wall_clock_time) { | 322 base::Time wall_clock_time) { |
| 317 DCHECK(Proxy::IsImplThread()); | 323 DCHECK(Proxy::IsImplThread()); |
| 318 DebugScopedSetMainThread main(this); | 324 DebugScopedSetMainThread main(this); |
| 319 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); | 325 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); |
| 320 } | 326 } |
| 321 | 327 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 void SingleThreadProxy::DidSwapFrame() { | 533 void SingleThreadProxy::DidSwapFrame() { |
| 528 if (next_frame_is_newly_committed_frame_) { | 534 if (next_frame_is_newly_committed_frame_) { |
| 529 next_frame_is_newly_committed_frame_ = false; | 535 next_frame_is_newly_committed_frame_ = false; |
| 530 layer_tree_host_->DidCommitAndDrawFrame(); | 536 layer_tree_host_->DidCommitAndDrawFrame(); |
| 531 } | 537 } |
| 532 } | 538 } |
| 533 | 539 |
| 534 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 540 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 535 | 541 |
| 536 } // namespace cc | 542 } // namespace cc |
| OLD | NEW |