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

Side by Side Diff: content/browser/android/overscroll_glow.cc

Issue 230223006: Move nonscrollable axis gloweffect suppression to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up and modified as per review comments Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/android/overscroll_glow.h" 5 #include "content/browser/android/overscroll_glow.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/threading/worker_pool.h" 9 #include "base/threading/worker_pool.h"
10 #include "cc/layers/image_layer.h" 10 #include "cc/layers/image_layer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Don't block the main thread with effect resource loading during creation. 90 // Don't block the main thread with effect resource loading during creation.
91 // Effect instantiation is deferred until the effect overscrolls, in which 91 // Effect instantiation is deferred until the effect overscrolls, in which
92 // case the main thread may block until the resource has loaded. 92 // case the main thread may block until the resource has loaded.
93 if (enabled && g_overscroll_resources == NULL) 93 if (enabled && g_overscroll_resources == NULL)
94 base::WorkerPool::PostTask(FROM_HERE, base::Bind(EnsureResources), true); 94 base::WorkerPool::PostTask(FROM_HERE, base::Bind(EnsureResources), true);
95 95
96 return make_scoped_ptr(new OverscrollGlow(enabled)); 96 return make_scoped_ptr(new OverscrollGlow(enabled));
97 } 97 }
98 98
99 OverscrollGlow::OverscrollGlow(bool enabled) 99 OverscrollGlow::OverscrollGlow(bool enabled)
100 : enabled_(enabled), 100 : enabled_(enabled), initialized_(false) {}
101 initialized_(false),
102 horizontal_overscroll_enabled_(true),
103 vertical_overscroll_enabled_(true) {}
104 101
105 OverscrollGlow::~OverscrollGlow() { 102 OverscrollGlow::~OverscrollGlow() {
106 Detach(); 103 Detach();
107 } 104 }
108 105
109 void OverscrollGlow::Enable() { 106 void OverscrollGlow::Enable() {
110 enabled_ = true; 107 enabled_ = true;
111 } 108 }
112 109
113 void OverscrollGlow::Disable() { 110 void OverscrollGlow::Disable() {
(...skipping 14 matching lines...) Expand all
128 DCHECK(overscrolling_layer); 125 DCHECK(overscrolling_layer);
129 126
130 if (!enabled_) 127 if (!enabled_)
131 return false; 128 return false;
132 129
133 // The size of the glow determines the relative effect of the inputs; an 130 // The size of the glow determines the relative effect of the inputs; an
134 // empty-sized effect is effectively disabled. 131 // empty-sized effect is effectively disabled.
135 if (size_.IsEmpty()) 132 if (size_.IsEmpty())
136 return false; 133 return false;
137 134
138 if (!horizontal_overscroll_enabled_) {
139 overscroll.set_x(0);
140 velocity.set_x(0);
141 }
142 if (!vertical_overscroll_enabled_) {
143 overscroll.set_y(0);
144 velocity.set_y(0);
145 }
146
147 // Ignore sufficiently small values that won't meaningfuly affect animation. 135 // Ignore sufficiently small values that won't meaningfuly affect animation.
148 overscroll = ZeroSmallComponents(overscroll); 136 overscroll = ZeroSmallComponents(overscroll);
149 velocity = ZeroSmallComponents(velocity); 137 velocity = ZeroSmallComponents(velocity);
150 138
151 if (overscroll.IsZero()) { 139 if (overscroll.IsZero()) {
152 if (initialized_) { 140 if (initialized_) {
153 Release(current_time); 141 Release(current_time);
154 UpdateLayerAttachment(overscrolling_layer); 142 UpdateLayerAttachment(overscrolling_layer);
155 } 143 }
156 return NeedsAnimate(); 144 return NeedsAnimate();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 }; 332 };
345 } 333 }
346 334
347 EdgeEffect* OverscrollGlow::GetOppositeEdge(int edge_index) { 335 EdgeEffect* OverscrollGlow::GetOppositeEdge(int edge_index) {
348 DCHECK(initialized_); 336 DCHECK(initialized_);
349 return edge_effects_[(edge_index + 2) % EdgeEffect::EDGE_COUNT].get(); 337 return edge_effects_[(edge_index + 2) % EdgeEffect::EDGE_COUNT].get();
350 } 338 }
351 339
352 } // namespace content 340 } // namespace content
353 341
OLDNEW
« no previous file with comments | « content/browser/android/overscroll_glow.h ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698