| 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 20 matching lines...) Expand all Loading... |
| 31 #include "cc/surfaces/surface_id_allocator.h" | 31 #include "cc/surfaces/surface_id_allocator.h" |
| 32 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
| 33 #include "cc/trees/layer_tree_host.h" | 33 #include "cc/trees/layer_tree_host.h" |
| 34 #include "third_party/skia/include/core/SkBitmap.h" | 34 #include "third_party/skia/include/core/SkBitmap.h" |
| 35 #include "ui/compositor/compositor_observer.h" | 35 #include "ui/compositor/compositor_observer.h" |
| 36 #include "ui/compositor/compositor_switches.h" | 36 #include "ui/compositor/compositor_switches.h" |
| 37 #include "ui/compositor/compositor_vsync_manager.h" | 37 #include "ui/compositor/compositor_vsync_manager.h" |
| 38 #include "ui/compositor/dip_util.h" | 38 #include "ui/compositor/dip_util.h" |
| 39 #include "ui/compositor/layer.h" | 39 #include "ui/compositor/layer.h" |
| 40 #include "ui/compositor/layer_animator_collection.h" | 40 #include "ui/compositor/layer_animator_collection.h" |
| 41 #include "ui/compositor/overscroll/ui_scroll_input_manager.h" |
| 41 #include "ui/gl/gl_switches.h" | 42 #include "ui/gl/gl_switches.h" |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 const double kDefaultRefreshRate = 60.0; | 46 const double kDefaultRefreshRate = 60.0; |
| 46 const double kTestRefreshRate = 200.0; | 47 const double kTestRefreshRate = 200.0; |
| 47 | 48 |
| 48 bool IsRunningInMojoShell(base::CommandLine* command_line) { | 49 bool IsRunningInMojoShell(base::CommandLine* command_line) { |
| 49 const char kMojoShellFlag[] = "mojo-platform-channel-handle"; | 50 const char kMojoShellFlag[] = "mojo-platform-channel-handle"; |
| 50 return command_line->HasSwitch(kMojoShellFlag); | 51 return command_line->HasSwitch(kMojoShellFlag); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (context_factory->GetSurfaceManager()) { | 95 if (context_factory->GetSurfaceManager()) { |
| 95 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( | 96 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( |
| 96 surface_id_allocator_->client_id()); | 97 surface_id_allocator_->client_id()); |
| 97 } | 98 } |
| 98 root_web_layer_ = cc::Layer::Create(); | 99 root_web_layer_ = cc::Layer::Create(); |
| 99 | 100 |
| 100 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 101 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 101 | 102 |
| 102 cc::LayerTreeSettings settings; | 103 cc::LayerTreeSettings settings; |
| 103 | 104 |
| 105 #if defined(OS_MACOSX) |
| 106 settings.enable_elastic_overscroll = true; |
| 107 #endif |
| 108 |
| 104 // This will ensure PictureLayers always can have LCD text, to match the | 109 // This will ensure PictureLayers always can have LCD text, to match the |
| 105 // previous behaviour with ContentLayers, where LCD-not-allowed notifications | 110 // previous behaviour with ContentLayers, where LCD-not-allowed notifications |
| 106 // were ignored. | 111 // were ignored. |
| 107 settings.layers_always_allowed_lcd_text = true; | 112 settings.layers_always_allowed_lcd_text = true; |
| 108 // Use occlusion to allow more overlapping windows to take less memory. | 113 // Use occlusion to allow more overlapping windows to take less memory. |
| 109 settings.use_occlusion_for_tile_prioritization = true; | 114 settings.use_occlusion_for_tile_prioritization = true; |
| 110 settings.renderer_settings.refresh_rate = | 115 settings.renderer_settings.refresh_rate = |
| 111 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate | 116 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate |
| 112 : kDefaultRefreshRate; | 117 : kDefaultRefreshRate; |
| 113 settings.main_frame_before_activation_enabled = false; | 118 settings.main_frame_before_activation_enabled = false; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 cc::LayerTreeHost::InitParams params; | 206 cc::LayerTreeHost::InitParams params; |
| 202 params.client = this; | 207 params.client = this; |
| 203 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); | 208 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); |
| 204 params.gpu_memory_buffer_manager = | 209 params.gpu_memory_buffer_manager = |
| 205 context_factory_->GetGpuMemoryBufferManager(); | 210 context_factory_->GetGpuMemoryBufferManager(); |
| 206 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); | 211 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); |
| 207 params.settings = &settings; | 212 params.settings = &settings; |
| 208 params.main_task_runner = task_runner_; | 213 params.main_task_runner = task_runner_; |
| 209 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 214 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
| 210 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 215 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
| 216 |
| 217 // Tie composited scrolling with whether the platform wants elastic scrolling. |
| 218 // TODO(tapted): Use composited scrolling on all platforms. |
| 219 if (settings.enable_elastic_overscroll) { |
| 220 scroll_input_manager_.reset( |
| 221 new UIScrollInputManager(host_->GetInputHandler())); |
| 222 } |
| 223 |
| 211 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 224 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
| 212 base::TimeTicks::Now() - before_create); | 225 base::TimeTicks::Now() - before_create); |
| 213 | 226 |
| 214 animation_timeline_ = | 227 animation_timeline_ = |
| 215 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); | 228 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
| 216 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); | 229 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); |
| 217 | 230 |
| 218 host_->SetRootLayer(root_web_layer_); | 231 host_->SetRootLayer(root_web_layer_); |
| 219 host_->set_surface_client_id(surface_id_allocator_->client_id()); | 232 host_->set_surface_client_id(surface_id_allocator_->client_id()); |
| 220 host_->SetVisible(true); | 233 host_->SetVisible(true); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 391 } |
| 379 | 392 |
| 380 void Compositor::SetVisible(bool visible) { | 393 void Compositor::SetVisible(bool visible) { |
| 381 host_->SetVisible(visible); | 394 host_->SetVisible(visible); |
| 382 } | 395 } |
| 383 | 396 |
| 384 bool Compositor::IsVisible() { | 397 bool Compositor::IsVisible() { |
| 385 return host_->visible(); | 398 return host_->visible(); |
| 386 } | 399 } |
| 387 | 400 |
| 401 bool Compositor::ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) { |
| 402 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset); |
| 403 } |
| 404 |
| 405 gfx::ScrollOffset Compositor::GetScrollOffsetForLayer(int layer_id) const { |
| 406 return host_->GetInputHandler()->GetScrollOffsetForLayer(layer_id); |
| 407 } |
| 408 |
| 388 void Compositor::SetAuthoritativeVSyncInterval( | 409 void Compositor::SetAuthoritativeVSyncInterval( |
| 389 const base::TimeDelta& interval) { | 410 const base::TimeDelta& interval) { |
| 390 context_factory_->SetAuthoritativeVSyncInterval(this, interval); | 411 context_factory_->SetAuthoritativeVSyncInterval(this, interval); |
| 391 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 412 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 392 cc::switches::kDisableBeginFrameScheduling)) { | 413 cc::switches::kDisableBeginFrameScheduling)) { |
| 393 vsync_manager_->SetAuthoritativeVSyncInterval(interval); | 414 vsync_manager_->SetAuthoritativeVSyncInterval(interval); |
| 394 } | 415 } |
| 395 } | 416 } |
| 396 | 417 |
| 397 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { | 418 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 observer_list_, | 579 observer_list_, |
| 559 OnCompositingLockStateChanged(this)); | 580 OnCompositingLockStateChanged(this)); |
| 560 } | 581 } |
| 561 | 582 |
| 562 void Compositor::CancelCompositorLock() { | 583 void Compositor::CancelCompositorLock() { |
| 563 if (compositor_lock_) | 584 if (compositor_lock_) |
| 564 compositor_lock_->CancelLock(); | 585 compositor_lock_->CancelLock(); |
| 565 } | 586 } |
| 566 | 587 |
| 567 } // namespace ui | 588 } // namespace ui |
| OLD | NEW |