Chromium Code Reviews| Index: remoting/client/gl_cursor_feedback.cc |
| diff --git a/remoting/client/gl_cursor_feedback.cc b/remoting/client/gl_cursor_feedback.cc |
| index 8306933013e18f2919a50b45db7ba4c878fe731a..5cb796afb4c649ffdcc898dadad26f3281f2a5e8 100644 |
| --- a/remoting/client/gl_cursor_feedback.cc |
| +++ b/remoting/client/gl_cursor_feedback.cc |
| @@ -5,6 +5,7 @@ |
| #include "remoting/client/gl_cursor_feedback.h" |
| #include <math.h> |
| + |
| #include <array> |
| #include "base/logging.h" |
| @@ -15,7 +16,32 @@ |
| #include "remoting/client/gl_texture_ids.h" |
| namespace { |
| -const float kAnimationDurationMs = 220.f; |
| + |
| +const float kAnimationDurationMs = 300.f; |
| + |
| +// progress: [0, 1], indicating the progress of the animation. |
|
joedow
2016/08/23 01:27:20
params are referenced like this |progress|. It wo
Yuwei
2016/08/23 01:56:23
Done.
|
| +// Returns a coefficient ([0, 1]) to be multiplied with the maximum diameter to |
| +// get the current diameter of the animation. |
| +float GetExpansionCoeff(float progress) { |
|
joedow
2016/08/23 01:27:20
Coeff should be spelled out (GetExpansionCoefficie
Yuwei
2016/08/23 01:56:23
Done.
|
| + // Decelerating expansion. This is conforming to the material design spec. |
| + // More time will be spent showing the larger circle and the animation will |
| + // look more rapid given the same time duration. |
| + auto get_unnormalized_coeff = [](float progress) { |
| + static const float expansion_base = 400.f; |
|
joedow
2016/08/23 01:27:20
const values should use the same format as above (
Yuwei
2016/08/23 01:56:23
Done.
|
| + return 1.f - pow(expansion_base, -progress); |
| + }; |
| + static const float expansion_normalization = get_unnormalized_coeff(1); |
| + return get_unnormalized_coeff(progress) / expansion_normalization; |
| +} |
| + |
| +// progress: [0, 1], indicating the progress of the animation. |
| +// Returns a coefficient ([0, 1]) to be multiplied with the alpha channel of the |
| +// texture. |
| +float GetAlphaCoeff(float progress) { |
|
joedow
2016/08/23 01:27:20
I don't think this needs to be a separate function
Yuwei
2016/08/23 01:56:23
Done.
|
| + // Linear fade-out. |
| + return 1.f - progress; |
| +} |
| + |
| } // namespace |
| namespace remoting { |
| @@ -54,13 +80,13 @@ bool GlCursorFeedback::Draw() { |
| animation_start_time_ = base::TimeTicks(); |
| return false; |
| } |
| - float diameter = progress * max_diameter_; |
| + float diameter = GetExpansionCoeff(progress) * max_diameter_; |
| std::array<float, 8> positions; |
| FillRectangleVertexPositions(cursor_x_ - diameter / 2, |
| cursor_y_ - diameter / 2, |
| diameter, diameter, &positions); |
| layer_->SetVertexPositions(positions); |
| - layer_->Draw(1.f - progress); |
| + layer_->Draw(GetAlphaCoeff(progress)); |
| return true; |
| } |