| 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> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
| 33 #include "cc/trees/layer_tree_host_in_process.h" | 33 #include "cc/trees/layer_tree_host_in_process.h" |
| 34 #include "cc/trees/layer_tree_settings.h" | 34 #include "cc/trees/layer_tree_settings.h" |
| 35 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
| 36 #include "ui/compositor/compositor_observer.h" | 36 #include "ui/compositor/compositor_observer.h" |
| 37 #include "ui/compositor/compositor_switches.h" | 37 #include "ui/compositor/compositor_switches.h" |
| 38 #include "ui/compositor/compositor_vsync_manager.h" | 38 #include "ui/compositor/compositor_vsync_manager.h" |
| 39 #include "ui/compositor/dip_util.h" | 39 #include "ui/compositor/dip_util.h" |
| 40 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
| 41 #include "ui/compositor/layer_animator_collection.h" | 41 #include "ui/compositor/layer_animator_collection.h" |
| 42 #include "ui/compositor/overscroll/ui_scroll_input_manager.h" |
| 42 #include "ui/gl/gl_switches.h" | 43 #include "ui/gl/gl_switches.h" |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 const double kDefaultRefreshRate = 60.0; | 47 const double kDefaultRefreshRate = 60.0; |
| 47 const double kTestRefreshRate = 200.0; | 48 const double kTestRefreshRate = 200.0; |
| 48 | 49 |
| 49 } // namespace | 50 } // namespace |
| 50 | 51 |
| 51 namespace ui { | 52 namespace ui { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 compositor_lock_(NULL), | 90 compositor_lock_(NULL), |
| 90 layer_animator_collection_(this), | 91 layer_animator_collection_(this), |
| 91 weak_ptr_factory_(this) { | 92 weak_ptr_factory_(this) { |
| 92 context_factory->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 93 context_factory->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
| 93 root_web_layer_ = cc::Layer::Create(); | 94 root_web_layer_ = cc::Layer::Create(); |
| 94 | 95 |
| 95 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 96 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 96 | 97 |
| 97 cc::LayerTreeSettings settings; | 98 cc::LayerTreeSettings settings; |
| 98 | 99 |
| 100 #if defined(OS_MACOSX) |
| 101 settings.enable_elastic_overscroll = true; |
| 102 #endif |
| 103 |
| 99 // This will ensure PictureLayers always can have LCD text, to match the | 104 // This will ensure PictureLayers always can have LCD text, to match the |
| 100 // previous behaviour with ContentLayers, where LCD-not-allowed notifications | 105 // previous behaviour with ContentLayers, where LCD-not-allowed notifications |
| 101 // were ignored. | 106 // were ignored. |
| 102 settings.layers_always_allowed_lcd_text = true; | 107 settings.layers_always_allowed_lcd_text = true; |
| 103 // Use occlusion to allow more overlapping windows to take less memory. | 108 // Use occlusion to allow more overlapping windows to take less memory. |
| 104 settings.use_occlusion_for_tile_prioritization = true; | 109 settings.use_occlusion_for_tile_prioritization = true; |
| 105 settings.renderer_settings.refresh_rate = | 110 settings.renderer_settings.refresh_rate = |
| 106 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate | 111 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate |
| 107 : kDefaultRefreshRate; | 112 : kDefaultRefreshRate; |
| 108 settings.main_frame_before_activation_enabled = false; | 113 settings.main_frame_before_activation_enabled = false; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 cc::LayerTreeHostInProcess::InitParams params; | 193 cc::LayerTreeHostInProcess::InitParams params; |
| 189 params.client = this; | 194 params.client = this; |
| 190 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); | 195 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); |
| 191 params.gpu_memory_buffer_manager = | 196 params.gpu_memory_buffer_manager = |
| 192 context_factory_->GetGpuMemoryBufferManager(); | 197 context_factory_->GetGpuMemoryBufferManager(); |
| 193 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); | 198 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); |
| 194 params.settings = &settings; | 199 params.settings = &settings; |
| 195 params.main_task_runner = task_runner_; | 200 params.main_task_runner = task_runner_; |
| 196 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 201 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
| 197 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); | 202 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); |
| 203 |
| 204 // Tie composited scrolling with whether the platform wants elastic scrolling. |
| 205 // TODO(tapted): Use composited scrolling on all platforms. |
| 206 if (settings.enable_elastic_overscroll) { |
| 207 scroll_input_manager_.reset( |
| 208 new UIScrollInputManager(host_->GetInputHandler())); |
| 209 } |
| 210 |
| 198 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 211 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
| 199 base::TimeTicks::Now() - before_create); | 212 base::TimeTicks::Now() - before_create); |
| 200 | 213 |
| 201 animation_timeline_ = | 214 animation_timeline_ = |
| 202 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); | 215 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
| 203 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( | 216 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( |
| 204 animation_timeline_.get()); | 217 animation_timeline_.get()); |
| 205 | 218 |
| 206 host_->GetLayerTree()->SetRootLayer(root_web_layer_); | 219 host_->GetLayerTree()->SetRootLayer(root_web_layer_); |
| 207 host_->SetFrameSinkId(frame_sink_id_); | 220 host_->SetFrameSinkId(frame_sink_id_); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 observer_list_, | 557 observer_list_, |
| 545 OnCompositingLockStateChanged(this)); | 558 OnCompositingLockStateChanged(this)); |
| 546 } | 559 } |
| 547 | 560 |
| 548 void Compositor::CancelCompositorLock() { | 561 void Compositor::CancelCompositorLock() { |
| 549 if (compositor_lock_) | 562 if (compositor_lock_) |
| 550 compositor_lock_->CancelLock(); | 563 compositor_lock_->CancelLock(); |
| 551 } | 564 } |
| 552 | 565 |
| 553 } // namespace ui | 566 } // namespace ui |
| OLD | NEW |