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

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

Issue 377013002: android: Use UIResource for overscroll glow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments. moved system_ui_resource* implementation to content Created 6 years, 5 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/edge_effect.h" 5 #include "content/browser/android/edge_effect.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 gfx::Size bounds = ComputeBounds(edge, window_size, height); 136 gfx::Size bounds = ComputeBounds(edge, window_size, height);
137 layer->SetTransformOrigin( 137 layer->SetTransformOrigin(
138 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0)); 138 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0));
139 layer->SetTransform(ComputeTransform(edge, window_size, offset, height)); 139 layer->SetTransform(ComputeTransform(edge, window_size, offset, height));
140 layer->SetBounds(bounds); 140 layer->SetBounds(bounds);
141 layer->SetOpacity(Clamp(opacity, 0.f, 1.f)); 141 layer->SetOpacity(Clamp(opacity, 0.f, 1.f));
142 } 142 }
143 143
144 } // namespace 144 } // namespace
145 145
146 EdgeEffect::EdgeEffect(scoped_refptr<cc::Layer> edge, 146 EdgeEffect::EdgeEffect(scoped_ptr<LayerWrapper> edge,
147 scoped_refptr<cc::Layer> glow) 147 scoped_ptr<LayerWrapper> glow)
148 : edge_(edge) 148 : edge_(edge.Pass()),
149 , glow_(glow) 149 glow_(glow.Pass()),
150 , edge_alpha_(0) 150 edge_alpha_(0),
151 , edge_scale_y_(0) 151 edge_scale_y_(0),
152 , glow_alpha_(0) 152 glow_alpha_(0),
153 , glow_scale_y_(0) 153 glow_scale_y_(0),
154 , edge_alpha_start_(0) 154 edge_alpha_start_(0),
155 , edge_alpha_finish_(0) 155 edge_alpha_finish_(0),
156 , edge_scale_y_start_(0) 156 edge_scale_y_start_(0),
157 , edge_scale_y_finish_(0) 157 edge_scale_y_finish_(0),
158 , glow_alpha_start_(0) 158 glow_alpha_start_(0),
159 , glow_alpha_finish_(0) 159 glow_alpha_finish_(0),
160 , glow_scale_y_start_(0) 160 glow_scale_y_start_(0),
161 , glow_scale_y_finish_(0) 161 glow_scale_y_finish_(0),
162 , state_(STATE_IDLE) 162 state_(STATE_IDLE),
163 , pull_distance_(0) { 163 pull_distance_(0) {
164 // Prevent the provided layers from drawing until the effect is activated. 164 // Prevent the provided layers from drawing until the effect is activated.
165 DisableLayer(edge_.get()); 165 DisableLayer(edge_->layer());
166 DisableLayer(glow_.get()); 166 DisableLayer(glow_->layer());
167 } 167 }
168 168
169 EdgeEffect::~EdgeEffect() { } 169 EdgeEffect::~EdgeEffect() { }
170 170
171 bool EdgeEffect::IsFinished() const { 171 bool EdgeEffect::IsFinished() const {
172 return state_ == STATE_IDLE; 172 return state_ == STATE_IDLE;
173 } 173 }
174 174
175 void EdgeEffect::Finish() { 175 void EdgeEffect::Finish() {
176 DisableLayer(edge_.get()); 176 DisableLayer(edge_->layer());
177 DisableLayer(glow_.get()); 177 DisableLayer(glow_->layer());
178 pull_distance_ = 0; 178 pull_distance_ = 0;
179 state_ = STATE_IDLE; 179 state_ = STATE_IDLE;
180 } 180 }
181 181
182 void EdgeEffect::Pull(base::TimeTicks current_time, float delta_distance) { 182 void EdgeEffect::Pull(base::TimeTicks current_time, float delta_distance) {
183 if (state_ == STATE_PULL_DECAY && current_time - start_time_ < duration_) { 183 if (state_ == STATE_PULL_DECAY && current_time - start_time_ < duration_) {
184 return; 184 return;
185 } 185 }
186 if (state_ != STATE_PULL) { 186 if (state_ != STATE_PULL) {
187 glow_scale_y_ = kPullGlowBegin; 187 glow_scale_y_ = kPullGlowBegin;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 Edge edge, 352 Edge edge,
353 float edge_height, 353 float edge_height,
354 float glow_height, 354 float glow_height,
355 float offset) { 355 float offset) {
356 if (IsFinished()) 356 if (IsFinished())
357 return; 357 return;
358 358
359 // An empty window size, while meaningless, is also relatively harmless, and 359 // An empty window size, while meaningless, is also relatively harmless, and
360 // will simply prevent any drawing of the layers. 360 // will simply prevent any drawing of the layers.
361 if (window_size.IsEmpty()) { 361 if (window_size.IsEmpty()) {
362 DisableLayer(edge_.get()); 362 DisableLayer(edge_->layer());
363 DisableLayer(glow_.get()); 363 DisableLayer(glow_->layer());
364 return; 364 return;
365 } 365 }
366 366
367 // Glow 367 // Glow
368 const int scaled_glow_height = static_cast<int>( 368 const int scaled_glow_height = static_cast<int>(
369 std::min(glow_height * glow_scale_y_ * kGlowHeightToWidthRatio * 0.6f, 369 std::min(glow_height * glow_scale_y_ * kGlowHeightToWidthRatio * 0.6f,
370 glow_height * kMaxGlowHeight) + 0.5f); 370 glow_height * kMaxGlowHeight) + 0.5f);
371 UpdateLayer( 371 UpdateLayer(glow_->layer(),
372 glow_.get(), edge, window_size, offset, scaled_glow_height, glow_alpha_); 372 edge,
373 window_size,
374 offset,
375 scaled_glow_height,
376 glow_alpha_);
373 377
374 // Edge 378 // Edge
375 const int scaled_edge_height = static_cast<int>(edge_height * edge_scale_y_); 379 const int scaled_edge_height = static_cast<int>(edge_height * edge_scale_y_);
376 UpdateLayer( 380 UpdateLayer(edge_->layer(),
377 edge_.get(), edge, window_size, offset, scaled_edge_height, edge_alpha_); 381 edge,
382 window_size,
383 offset,
384 scaled_edge_height,
385 edge_alpha_);
378 } 386 }
379 387
380 } // namespace content 388 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698