| 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/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.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 "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.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/output/latency_info_swap_promise.h" | 23 #include "cc/output/latency_info_swap_promise.h" |
| 24 #include "cc/scheduler/begin_frame_source.h" | 24 #include "cc/scheduler/begin_frame_source.h" |
| 25 #include "cc/surfaces/surface_id_allocator.h" | 25 #include "cc/surfaces/surface_id_allocator.h" |
| 26 #include "cc/trees/layer_tree_host.h" | 26 #include "cc/trees/layer_tree_host.h" |
| 27 #include "third_party/skia/include/core/SkBitmap.h" | 27 #include "third_party/skia/include/core/SkBitmap.h" |
| 28 #include "ui/compositor/compositor_observer.h" | 28 #include "ui/compositor/compositor_observer.h" |
| 29 #include "ui/compositor/compositor_switches.h" | 29 #include "ui/compositor/compositor_switches.h" |
| 30 #include "ui/compositor/compositor_vsync_manager.h" | |
| 31 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
| 32 #include "ui/compositor/layer.h" | 31 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/layer_animator_collection.h" | 32 #include "ui/compositor/layer_animator_collection.h" |
| 34 #include "ui/gfx/frame_time.h" | 33 #include "ui/gfx/frame_time.h" |
| 35 #include "ui/gl/gl_context.h" | 34 #include "ui/gl/gl_context.h" |
| 36 #include "ui/gl/gl_switches.h" | 35 #include "ui/gl/gl_switches.h" |
| 37 | 36 |
| 38 namespace { | 37 namespace { |
| 39 | 38 |
| 40 const double kDefaultRefreshRate = 60.0; | 39 const double kDefaultRefreshRate = 60.0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 } | 67 } |
| 69 | 68 |
| 70 Compositor::Compositor(gfx::AcceleratedWidget widget, | 69 Compositor::Compositor(gfx::AcceleratedWidget widget, |
| 71 ui::ContextFactory* context_factory, | 70 ui::ContextFactory* context_factory, |
| 72 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 73 : context_factory_(context_factory), | 72 : context_factory_(context_factory), |
| 74 root_layer_(NULL), | 73 root_layer_(NULL), |
| 75 widget_(widget), | 74 widget_(widget), |
| 76 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), | 75 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), |
| 77 task_runner_(task_runner), | 76 task_runner_(task_runner), |
| 78 vsync_manager_(new CompositorVSyncManager()), | |
| 79 device_scale_factor_(0.0f), | 77 device_scale_factor_(0.0f), |
| 80 last_started_frame_(0), | 78 last_started_frame_(0), |
| 81 last_ended_frame_(0), | 79 last_ended_frame_(0), |
| 82 locks_will_time_out_(true), | 80 locks_will_time_out_(true), |
| 83 compositor_lock_(NULL), | 81 compositor_lock_(NULL), |
| 84 layer_animator_collection_(this), | 82 layer_animator_collection_(this), |
| 85 weak_ptr_factory_(this) { | 83 weak_ptr_factory_(this) { |
| 86 root_web_layer_ = cc::Layer::Create(); | 84 root_web_layer_ = cc::Layer::Create(); |
| 87 | 85 |
| 88 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 86 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 245 } |
| 248 | 246 |
| 249 void Compositor::SetVisible(bool visible) { | 247 void Compositor::SetVisible(bool visible) { |
| 250 host_->SetVisible(visible); | 248 host_->SetVisible(visible); |
| 251 } | 249 } |
| 252 | 250 |
| 253 bool Compositor::IsVisible() { | 251 bool Compositor::IsVisible() { |
| 254 return host_->visible(); | 252 return host_->visible(); |
| 255 } | 253 } |
| 256 | 254 |
| 257 scoped_refptr<CompositorVSyncManager> Compositor::vsync_manager() const { | 255 void Compositor::SetAuthoritativeVSyncInterval( |
| 258 return vsync_manager_; | 256 const base::TimeDelta& interval) { |
| 257 host_->SetAuthoritativeVSyncInterval(interval); |
| 259 } | 258 } |
| 260 | 259 |
| 261 void Compositor::AddObserver(CompositorObserver* observer) { | 260 void Compositor::AddObserver(CompositorObserver* observer) { |
| 262 observer_list_.AddObserver(observer); | 261 observer_list_.AddObserver(observer); |
| 263 } | 262 } |
| 264 | 263 |
| 265 void Compositor::RemoveObserver(CompositorObserver* observer) { | 264 void Compositor::RemoveObserver(CompositorObserver* observer) { |
| 266 observer_list_.RemoveObserver(observer); | 265 observer_list_.RemoveObserver(observer); |
| 267 } | 266 } |
| 268 | 267 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 observer_list_, | 413 observer_list_, |
| 415 OnCompositingLockStateChanged(this)); | 414 OnCompositingLockStateChanged(this)); |
| 416 } | 415 } |
| 417 | 416 |
| 418 void Compositor::CancelCompositorLock() { | 417 void Compositor::CancelCompositorLock() { |
| 419 if (compositor_lock_) | 418 if (compositor_lock_) |
| 420 compositor_lock_->CancelLock(); | 419 compositor_lock_->CancelLock(); |
| 421 } | 420 } |
| 422 | 421 |
| 423 } // namespace ui | 422 } // namespace ui |
| OLD | NEW |