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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 context_factory_->GetGpuMemoryBufferManager(), | 164 context_factory_->GetGpuMemoryBufferManager(), |
166 settings, | 165 settings, |
167 task_runner_, | 166 task_runner_, |
168 compositor_thread_loop_); | 167 compositor_thread_loop_, |
| 168 nullptr); |
169 } else { | 169 } else { |
170 host_ = cc::LayerTreeHost::CreateSingleThreaded( | 170 host_ = cc::LayerTreeHost::CreateSingleThreaded( |
171 this, | 171 this, |
172 this, | 172 this, |
173 context_factory_->GetSharedBitmapManager(), | 173 context_factory_->GetSharedBitmapManager(), |
174 context_factory_->GetGpuMemoryBufferManager(), | 174 context_factory_->GetGpuMemoryBufferManager(), |
175 settings, | 175 settings, |
176 task_runner_); | 176 task_runner_, |
| 177 nullptr); |
177 } | 178 } |
178 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 179 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
179 base::TimeTicks::Now() - before_create); | 180 base::TimeTicks::Now() - before_create); |
180 host_->SetRootLayer(root_web_layer_); | 181 host_->SetRootLayer(root_web_layer_); |
181 host_->SetLayerTreeHostClientReady(); | 182 host_->SetLayerTreeHostClientReady(); |
182 } | 183 } |
183 | 184 |
184 Compositor::~Compositor() { | 185 Compositor::~Compositor() { |
185 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 186 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
186 | 187 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 // Call ScheduleDraw() instead of Draw() in order to allow other | 476 // Call ScheduleDraw() instead of Draw() in order to allow other |
476 // CompositorObservers to be notified before starting another | 477 // CompositorObservers to be notified before starting another |
477 // draw cycle. | 478 // draw cycle. |
478 ScheduleDraw(); | 479 ScheduleDraw(); |
479 } | 480 } |
480 FOR_EACH_OBSERVER( | 481 FOR_EACH_OBSERVER( |
481 CompositorObserver, observer_list_, OnCompositingEnded(this)); | 482 CompositorObserver, observer_list_, OnCompositingEnded(this)); |
482 } | 483 } |
483 | 484 |
484 } // namespace ui | 485 } // namespace ui |
OLD | NEW |