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