OLD | NEW |
---|---|
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/ui_resource_layer.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 enum State { | 13 enum State { |
14 STATE_IDLE = 0, | 14 STATE_IDLE = 0, |
15 STATE_PULL, | 15 STATE_PULL, |
16 STATE_ABSORB, | 16 STATE_ABSORB, |
17 STATE_RECEDE, | 17 STATE_RECEDE, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_refptr<cc::UIResourceLayer> edge, |
147 scoped_refptr<cc::Layer> glow) | 147 scoped_refptr<cc::UIResourceLayer> glow) |
148 : edge_(edge) | 148 : edge_(edge), |
149 , glow_(glow) | 149 glow_(glow), |
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) { |
powei
2014/07/08 19:12:43
result of clang-format. Let me know if the other
jdduke (slow)
2014/07/08 20:10:11
It's not, this is great.
| |
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_.get()); |
166 DisableLayer(glow_.get()); | 166 DisableLayer(glow_.get()); |
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 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 glow_height * kMaxGlowHeight) + 0.5f); | 370 glow_height * kMaxGlowHeight) + 0.5f); |
371 UpdateLayer( | 371 UpdateLayer( |
372 glow_.get(), edge, window_size, offset, scaled_glow_height, glow_alpha_); | 372 glow_.get(), edge, window_size, offset, scaled_glow_height, glow_alpha_); |
373 | 373 |
374 // Edge | 374 // Edge |
375 const int scaled_edge_height = static_cast<int>(edge_height * edge_scale_y_); | 375 const int scaled_edge_height = static_cast<int>(edge_height * edge_scale_y_); |
376 UpdateLayer( | 376 UpdateLayer( |
377 edge_.get(), edge, window_size, offset, scaled_edge_height, edge_alpha_); | 377 edge_.get(), edge, window_size, offset, scaled_edge_height, edge_alpha_); |
378 } | 378 } |
379 | 379 |
380 } // namespace content | 380 void EdgeEffect::SetUIResources(cc::UIResourceId edge_resource, |
381 cc::UIResourceId glow_resource) { | |
382 edge_->SetUIResourceId(edge_resource); | |
383 glow_->SetUIResourceId(glow_resource); | |
384 } | |
385 | |
386 } // namespace content | |
OLD | NEW |