| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "cc/animation/animation_host.h" | 21 #include "cc/animation/animation_host.h" |
| 22 #include "cc/animation/animation_id_provider.h" | 22 #include "cc/animation/animation_id_provider.h" |
| 23 #include "cc/animation/animation_timeline.h" | 23 #include "cc/animation/animation_timeline.h" |
| 24 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
| 25 #include "cc/input/input_handler.h" | 25 #include "cc/input/input_handler.h" |
| 26 #include "cc/layers/layer.h" | 26 #include "cc/layers/layer.h" |
| 27 #include "cc/layers/layer_settings.h" | |
| 28 #include "cc/output/begin_frame_args.h" | 27 #include "cc/output/begin_frame_args.h" |
| 29 #include "cc/output/context_provider.h" | 28 #include "cc/output/context_provider.h" |
| 30 #include "cc/output/latency_info_swap_promise.h" | 29 #include "cc/output/latency_info_swap_promise.h" |
| 31 #include "cc/scheduler/begin_frame_source.h" | 30 #include "cc/scheduler/begin_frame_source.h" |
| 32 #include "cc/surfaces/surface_id_allocator.h" | 31 #include "cc/surfaces/surface_id_allocator.h" |
| 33 #include "cc/trees/layer_tree_host.h" | 32 #include "cc/trees/layer_tree_host.h" |
| 34 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
| 35 #include "ui/compositor/compositor_observer.h" | 34 #include "ui/compositor/compositor_observer.h" |
| 36 #include "ui/compositor/compositor_switches.h" | 35 #include "ui/compositor/compositor_switches.h" |
| 37 #include "ui/compositor/compositor_vsync_manager.h" | 36 #include "ui/compositor/compositor_vsync_manager.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), | 80 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), |
| 82 task_runner_(task_runner), | 81 task_runner_(task_runner), |
| 83 vsync_manager_(new CompositorVSyncManager()), | 82 vsync_manager_(new CompositorVSyncManager()), |
| 84 device_scale_factor_(0.0f), | 83 device_scale_factor_(0.0f), |
| 85 last_started_frame_(0), | 84 last_started_frame_(0), |
| 86 last_ended_frame_(0), | 85 last_ended_frame_(0), |
| 87 locks_will_time_out_(true), | 86 locks_will_time_out_(true), |
| 88 compositor_lock_(NULL), | 87 compositor_lock_(NULL), |
| 89 layer_animator_collection_(this), | 88 layer_animator_collection_(this), |
| 90 weak_ptr_factory_(this) { | 89 weak_ptr_factory_(this) { |
| 91 root_web_layer_ = cc::Layer::Create(cc::LayerSettings()); | 90 root_web_layer_ = cc::Layer::Create(); |
| 92 | 91 |
| 93 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 92 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 94 | 93 |
| 95 cc::LayerTreeSettings settings; | 94 cc::LayerTreeSettings settings; |
| 96 | 95 |
| 97 // This will ensure PictureLayers always can have LCD text, to match the | 96 // This will ensure PictureLayers always can have LCD text, to match the |
| 98 // previous behaviour with ContentLayers, where LCD-not-allowed notifications | 97 // previous behaviour with ContentLayers, where LCD-not-allowed notifications |
| 99 // were ignored. | 98 // were ignored. |
| 100 settings.layers_always_allowed_lcd_text = true; | 99 settings.layers_always_allowed_lcd_text = true; |
| 101 // Use occlusion to allow more overlapping windows to take less memory. | 100 // Use occlusion to allow more overlapping windows to take less memory. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); | 187 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); |
| 189 params.gpu_memory_buffer_manager = | 188 params.gpu_memory_buffer_manager = |
| 190 context_factory_->GetGpuMemoryBufferManager(); | 189 context_factory_->GetGpuMemoryBufferManager(); |
| 191 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); | 190 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); |
| 192 params.settings = &settings; | 191 params.settings = &settings; |
| 193 params.main_task_runner = task_runner_; | 192 params.main_task_runner = task_runner_; |
| 194 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 193 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
| 195 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 194 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
| 196 base::TimeTicks::Now() - before_create); | 195 base::TimeTicks::Now() - before_create); |
| 197 | 196 |
| 198 if (settings.use_compositor_animation_timelines) { | 197 animation_timeline_ = |
| 199 animation_timeline_ = cc::AnimationTimeline::Create( | 198 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
| 200 cc::AnimationIdProvider::NextTimelineId()); | 199 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); |
| 201 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); | 200 |
| 202 } | |
| 203 host_->SetRootLayer(root_web_layer_); | 201 host_->SetRootLayer(root_web_layer_); |
| 204 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); | 202 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); |
| 205 host_->SetVisible(true); | 203 host_->SetVisible(true); |
| 206 } | 204 } |
| 207 | 205 |
| 208 Compositor::~Compositor() { | 206 Compositor::~Compositor() { |
| 209 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 207 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 210 | 208 |
| 211 CancelCompositorLock(); | 209 CancelCompositorLock(); |
| 212 DCHECK(!compositor_lock_); | 210 DCHECK(!compositor_lock_); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 observer_list_, | 518 observer_list_, |
| 521 OnCompositingLockStateChanged(this)); | 519 OnCompositingLockStateChanged(this)); |
| 522 } | 520 } |
| 523 | 521 |
| 524 void Compositor::CancelCompositorLock() { | 522 void Compositor::CancelCompositorLock() { |
| 525 if (compositor_lock_) | 523 if (compositor_lock_) |
| 526 compositor_lock_->CancelLock(); | 524 compositor_lock_->CancelLock(); |
| 527 } | 525 } |
| 528 | 526 |
| 529 } // namespace ui | 527 } // namespace ui |
| OLD | NEW |