| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
| 17 #include "cc/base/latency_info_swap_promise.h" | 17 #include "cc/base/latency_info_swap_promise.h" |
| 18 #include "cc/base/switches.h" | 18 #include "cc/base/switches.h" |
| 19 #include "cc/input/input_handler.h" | 19 #include "cc/input/input_handler.h" |
| 20 #include "cc/layers/layer.h" | 20 #include "cc/layers/layer.h" |
| 21 #include "cc/output/begin_frame_args.h" | 21 #include "cc/output/begin_frame_args.h" |
| 22 #include "cc/output/context_provider.h" | 22 #include "cc/output/context_provider.h" |
| 23 #include "cc/scheduler/begin_frame_source.h" |
| 23 #include "cc/surfaces/surface_id_allocator.h" | 24 #include "cc/surfaces/surface_id_allocator.h" |
| 24 #include "cc/trees/layer_tree_host.h" | 25 #include "cc/trees/layer_tree_host.h" |
| 25 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
| 26 #include "ui/compositor/compositor_observer.h" | 27 #include "ui/compositor/compositor_observer.h" |
| 27 #include "ui/compositor/compositor_switches.h" | 28 #include "ui/compositor/compositor_switches.h" |
| 28 #include "ui/compositor/compositor_vsync_manager.h" | 29 #include "ui/compositor/compositor_vsync_manager.h" |
| 29 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
| 30 #include "ui/compositor/layer.h" | 31 #include "ui/compositor/layer.h" |
| 31 #include "ui/compositor/layer_animator_collection.h" | 32 #include "ui/compositor/layer_animator_collection.h" |
| 32 #include "ui/gfx/frame_time.h" | 33 #include "ui/gfx/frame_time.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 58 | 59 |
| 59 void CompositorLock::CancelLock() { | 60 void CompositorLock::CancelLock() { |
| 60 if (!compositor_) | 61 if (!compositor_) |
| 61 return; | 62 return; |
| 62 compositor_->UnlockCompositor(); | 63 compositor_->UnlockCompositor(); |
| 63 compositor_ = NULL; | 64 compositor_ = NULL; |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace ui | 67 } // namespace ui |
| 67 | 68 |
| 68 namespace {} // namespace | |
| 69 | |
| 70 namespace ui { | 69 namespace ui { |
| 71 | 70 |
| 72 class SatisfySwapPromise : public cc::SwapPromise { | 71 class SatisfySwapPromise : public cc::SwapPromise { |
| 73 public: | 72 public: |
| 74 explicit SatisfySwapPromise(uint32_t id) : id_(id) {} | 73 explicit SatisfySwapPromise(uint32_t id) : id_(id) {} |
| 75 | 74 |
| 76 private: | 75 private: |
| 77 virtual void DidSwap(cc::CompositorFrameMetadata* metadata) OVERRIDE { | 76 virtual void DidSwap(cc::CompositorFrameMetadata* metadata) OVERRIDE { |
| 78 metadata->satisfies_sequences.push_back(id_); | 77 metadata->satisfies_sequences.push_back(id_); |
| 79 } | 78 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 settings.use_zero_copy = IsUIZeroCopyEnabled(); | 156 settings.use_zero_copy = IsUIZeroCopyEnabled(); |
| 158 settings.single_thread_proxy_scheduler = false; | 157 settings.single_thread_proxy_scheduler = false; |
| 159 | 158 |
| 160 base::TimeTicks before_create = base::TimeTicks::Now(); | 159 base::TimeTicks before_create = base::TimeTicks::Now(); |
| 161 if (compositor_thread_loop_.get()) { | 160 if (compositor_thread_loop_.get()) { |
| 162 host_ = cc::LayerTreeHost::CreateThreaded( | 161 host_ = cc::LayerTreeHost::CreateThreaded( |
| 163 this, | 162 this, |
| 164 context_factory_->GetSharedBitmapManager(), | 163 context_factory_->GetSharedBitmapManager(), |
| 165 settings, | 164 settings, |
| 166 task_runner_, | 165 task_runner_, |
| 167 compositor_thread_loop_); | 166 compositor_thread_loop_, |
| 167 scoped_ptr<cc::ExternalBeginFrameSource>()); |
| 168 } else { | 168 } else { |
| 169 host_ = cc::LayerTreeHost::CreateSingleThreaded( | 169 host_ = cc::LayerTreeHost::CreateSingleThreaded( |
| 170 this, | 170 this, |
| 171 this, | 171 this, |
| 172 context_factory_->GetSharedBitmapManager(), | 172 context_factory_->GetSharedBitmapManager(), |
| 173 settings, | 173 settings, |
| 174 task_runner_); | 174 task_runner_, |
| 175 scoped_ptr<cc::ExternalBeginFrameSource>()); |
| 175 } | 176 } |
| 176 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 177 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
| 177 base::TimeTicks::Now() - before_create); | 178 base::TimeTicks::Now() - before_create); |
| 178 host_->SetRootLayer(root_web_layer_); | 179 host_->SetRootLayer(root_web_layer_); |
| 179 host_->SetLayerTreeHostClientReady(); | 180 host_->SetLayerTreeHostClientReady(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 Compositor::~Compositor() { | 183 Compositor::~Compositor() { |
| 183 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 184 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 184 | 185 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // Call ScheduleDraw() instead of Draw() in order to allow other | 474 // Call ScheduleDraw() instead of Draw() in order to allow other |
| 474 // CompositorObservers to be notified before starting another | 475 // CompositorObservers to be notified before starting another |
| 475 // draw cycle. | 476 // draw cycle. |
| 476 ScheduleDraw(); | 477 ScheduleDraw(); |
| 477 } | 478 } |
| 478 FOR_EACH_OBSERVER( | 479 FOR_EACH_OBSERVER( |
| 479 CompositorObserver, observer_list_, OnCompositingEnded(this)); | 480 CompositorObserver, observer_list_, OnCompositingEnded(this)); |
| 480 } | 481 } |
| 481 | 482 |
| 482 } // namespace ui | 483 } // namespace ui |
| OLD | NEW |