Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: ui/compositor/compositor.cc

Issue 1680613002: Adding momentum/overscroll to views:: ScrollViews Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Tableview layout. aaaand I think we are done Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_context.h" 42 #include "ui/gl/gl_context.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 bool IsRunningInMojoShell(base::CommandLine* command_line) { 50 bool IsRunningInMojoShell(base::CommandLine* command_line) {
50 const char kMojoShellFlag[] = "mojo-platform-channel-handle"; 51 const char kMojoShellFlag[] = "mojo-platform-channel-handle";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (context_factory->GetSurfaceManager()) { 96 if (context_factory->GetSurfaceManager()) {
96 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( 97 context_factory->GetSurfaceManager()->RegisterSurfaceClientId(
97 surface_id_allocator_->client_id()); 98 surface_id_allocator_->client_id());
98 } 99 }
99 root_web_layer_ = cc::Layer::Create(); 100 root_web_layer_ = cc::Layer::Create();
100 101
101 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 102 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
102 103
103 cc::LayerTreeSettings settings; 104 cc::LayerTreeSettings settings;
104 105
106 #if defined(OS_MACOSX)
107 settings.enable_elastic_overscroll = true;
108 #endif
109
105 // This will ensure PictureLayers always can have LCD text, to match the 110 // This will ensure PictureLayers always can have LCD text, to match the
106 // previous behaviour with ContentLayers, where LCD-not-allowed notifications 111 // previous behaviour with ContentLayers, where LCD-not-allowed notifications
107 // were ignored. 112 // were ignored.
108 settings.layers_always_allowed_lcd_text = true; 113 settings.layers_always_allowed_lcd_text = true;
109 // Use occlusion to allow more overlapping windows to take less memory. 114 // Use occlusion to allow more overlapping windows to take less memory.
110 settings.use_occlusion_for_tile_prioritization = true; 115 settings.use_occlusion_for_tile_prioritization = true;
111 settings.renderer_settings.refresh_rate = 116 settings.renderer_settings.refresh_rate =
112 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate 117 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate
113 : kDefaultRefreshRate; 118 : kDefaultRefreshRate;
114 settings.main_frame_before_activation_enabled = false; 119 settings.main_frame_before_activation_enabled = false;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 cc::LayerTreeHost::InitParams params; 207 cc::LayerTreeHost::InitParams params;
203 params.client = this; 208 params.client = this;
204 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); 209 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager();
205 params.gpu_memory_buffer_manager = 210 params.gpu_memory_buffer_manager =
206 context_factory_->GetGpuMemoryBufferManager(); 211 context_factory_->GetGpuMemoryBufferManager();
207 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); 212 params.task_graph_runner = context_factory_->GetTaskGraphRunner();
208 params.settings = &settings; 213 params.settings = &settings;
209 params.main_task_runner = task_runner_; 214 params.main_task_runner = task_runner_;
210 params.animation_host = cc::AnimationHost::CreateMainInstance(); 215 params.animation_host = cc::AnimationHost::CreateMainInstance();
211 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params); 216 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
217
218 // Tie composited scrolling with whether the platform wants elastic scrolling.
219 // TODO(tapted): Use composited scrolling on all platforms.
220 if (settings.enable_elastic_overscroll) {
221 scroll_input_manager_.reset(
222 new UIScrollInputManager(host_->GetInputHandler()));
223 }
224
212 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", 225 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor",
213 base::TimeTicks::Now() - before_create); 226 base::TimeTicks::Now() - before_create);
214 227
215 animation_timeline_ = 228 animation_timeline_ =
216 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); 229 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId());
217 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); 230 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get());
218 231
219 host_->SetRootLayer(root_web_layer_); 232 host_->SetRootLayer(root_web_layer_);
220 host_->set_surface_client_id(surface_id_allocator_->client_id()); 233 host_->set_surface_client_id(surface_id_allocator_->client_id());
221 host_->SetVisible(true); 234 host_->SetVisible(true);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 if (!compositor_lock_) { 508 if (!compositor_lock_) {
496 compositor_lock_ = new CompositorLock(this); 509 compositor_lock_ = new CompositorLock(this);
497 host_->SetDeferCommits(true); 510 host_->SetDeferCommits(true);
498 FOR_EACH_OBSERVER(CompositorObserver, 511 FOR_EACH_OBSERVER(CompositorObserver,
499 observer_list_, 512 observer_list_,
500 OnCompositingLockStateChanged(this)); 513 OnCompositingLockStateChanged(this));
501 } 514 }
502 return compositor_lock_; 515 return compositor_lock_;
503 } 516 }
504 517
518 bool Compositor::ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) {
519 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset);
520 }
521
505 void Compositor::UnlockCompositor() { 522 void Compositor::UnlockCompositor() {
506 DCHECK(compositor_lock_); 523 DCHECK(compositor_lock_);
507 compositor_lock_ = NULL; 524 compositor_lock_ = NULL;
508 host_->SetDeferCommits(false); 525 host_->SetDeferCommits(false);
509 FOR_EACH_OBSERVER(CompositorObserver, 526 FOR_EACH_OBSERVER(CompositorObserver,
510 observer_list_, 527 observer_list_,
511 OnCompositingLockStateChanged(this)); 528 OnCompositingLockStateChanged(this));
512 } 529 }
513 530
514 void Compositor::CancelCompositorLock() { 531 void Compositor::CancelCompositorLock() {
515 if (compositor_lock_) 532 if (compositor_lock_)
516 compositor_lock_->CancelLock(); 533 compositor_lock_->CancelLock();
517 } 534 }
518 535
519 } // namespace ui 536 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698