| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 command_line->HasSwitch(cc::switches::kUIShowSurfaceDamageRects); | 278 command_line->HasSwitch(cc::switches::kUIShowSurfaceDamageRects); |
| 279 settings.initial_debug_state.show_screen_space_rects = | 279 settings.initial_debug_state.show_screen_space_rects = |
| 280 command_line->HasSwitch(cc::switches::kUIShowScreenSpaceRects); | 280 command_line->HasSwitch(cc::switches::kUIShowScreenSpaceRects); |
| 281 settings.initial_debug_state.show_replica_screen_space_rects = | 281 settings.initial_debug_state.show_replica_screen_space_rects = |
| 282 command_line->HasSwitch(cc::switches::kUIShowReplicaScreenSpaceRects); | 282 command_line->HasSwitch(cc::switches::kUIShowReplicaScreenSpaceRects); |
| 283 settings.initial_debug_state.show_occluding_rects = | 283 settings.initial_debug_state.show_occluding_rects = |
| 284 command_line->HasSwitch(cc::switches::kUIShowOccludingRects); | 284 command_line->HasSwitch(cc::switches::kUIShowOccludingRects); |
| 285 settings.initial_debug_state.show_non_occluding_rects = | 285 settings.initial_debug_state.show_non_occluding_rects = |
| 286 command_line->HasSwitch(cc::switches::kUIShowNonOccludingRects); | 286 command_line->HasSwitch(cc::switches::kUIShowNonOccludingRects); |
| 287 | 287 |
| 288 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner = | 288 if (!!g_compositor_thread) { |
| 289 g_compositor_thread ? g_compositor_thread->message_loop_proxy() : NULL; | 289 host_ = cc::LayerTreeHost::CreateThreaded( |
| 290 | 290 this, NULL, settings, g_compositor_thread->message_loop_proxy()); |
| 291 host_ = | 291 } else { |
| 292 cc::LayerTreeHost::Create(this, NULL, settings, compositor_task_runner); | 292 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings); |
| 293 } |
| 293 host_->SetRootLayer(root_web_layer_); | 294 host_->SetRootLayer(root_web_layer_); |
| 294 host_->SetLayerTreeHostClientReady(); | 295 host_->SetLayerTreeHostClientReady(); |
| 295 } | 296 } |
| 296 | 297 |
| 297 Compositor::~Compositor() { | 298 Compositor::~Compositor() { |
| 298 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 299 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 299 | 300 |
| 300 DCHECK(g_compositor_initialized); | 301 DCHECK(g_compositor_initialized); |
| 301 | 302 |
| 302 CancelCompositorLock(); | 303 CancelCompositorLock(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 FOR_EACH_OBSERVER(CompositorObserver, | 551 FOR_EACH_OBSERVER(CompositorObserver, |
| 551 observer_list_, | 552 observer_list_, |
| 552 OnCompositingStarted(this, start_time)); | 553 OnCompositingStarted(this, start_time)); |
| 553 } | 554 } |
| 554 | 555 |
| 555 void Compositor::DidCompleteSwapBuffers() { | 556 void Compositor::DidCompleteSwapBuffers() { |
| 556 DCHECK(g_compositor_thread); | 557 DCHECK(g_compositor_thread); |
| 557 NotifyEnd(); | 558 NotifyEnd(); |
| 558 } | 559 } |
| 559 | 560 |
| 561 scoped_refptr<cc::ContextProvider> Compositor::OffscreenContextProvider() { |
| 562 return ContextFactory::GetInstance()->OffscreenCompositorContextProvider(); |
| 563 } |
| 564 |
| 560 void Compositor::ScheduleComposite() { | 565 void Compositor::ScheduleComposite() { |
| 561 if (!disable_schedule_composite_) | 566 if (!disable_schedule_composite_) |
| 562 ScheduleDraw(); | 567 ScheduleDraw(); |
| 563 } | 568 } |
| 564 | 569 |
| 565 scoped_refptr<cc::ContextProvider> Compositor::OffscreenContextProvider() { | |
| 566 return ContextFactory::GetInstance()->OffscreenCompositorContextProvider(); | |
| 567 } | |
| 568 | |
| 569 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { | 570 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
| 570 return host_->debug_state(); | 571 return host_->debug_state(); |
| 571 } | 572 } |
| 572 | 573 |
| 573 void Compositor::SetLayerTreeDebugState( | 574 void Compositor::SetLayerTreeDebugState( |
| 574 const cc::LayerTreeDebugState& debug_state) { | 575 const cc::LayerTreeDebugState& debug_state) { |
| 575 host_->SetDebugState(debug_state); | 576 host_->SetDebugState(debug_state); |
| 576 } | 577 } |
| 577 | 578 |
| 578 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { | 579 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // CompositorObservers to be notified before starting another | 614 // CompositorObservers to be notified before starting another |
| 614 // draw cycle. | 615 // draw cycle. |
| 615 ScheduleDraw(); | 616 ScheduleDraw(); |
| 616 } | 617 } |
| 617 FOR_EACH_OBSERVER(CompositorObserver, | 618 FOR_EACH_OBSERVER(CompositorObserver, |
| 618 observer_list_, | 619 observer_list_, |
| 619 OnCompositingEnded(this)); | 620 OnCompositingEnded(this)); |
| 620 } | 621 } |
| 621 | 622 |
| 622 } // namespace ui | 623 } // namespace ui |
| OLD | NEW |