Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/client/gl_cursor_feedback.h" | 5 #include "remoting/client/gl_cursor_feedback.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <array> | 8 #include <array> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "remoting/client/gl_canvas.h" | 11 #include "remoting/client/gl_canvas.h" |
| 12 #include "remoting/client/gl_cursor_feedback_texture.h" | 12 #include "remoting/client/gl_cursor_feedback_texture.h" |
| 13 #include "remoting/client/gl_math.h" | 13 #include "remoting/client/gl_math.h" |
| 14 #include "remoting/client/gl_render_layer.h" | 14 #include "remoting/client/gl_render_layer.h" |
| 15 #include "remoting/client/gl_texture_ids.h" | 15 #include "remoting/client/gl_texture_ids.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 const float kAnimationDurationMs = 220.f; | 18 |
| 19 const float kAnimationDurationMs = 300.f; | |
| 20 const float kExpansionBase = 400.f; | |
|
joedow
2016/08/22 22:22:21
Perhaps there isn't a better name, but kExpansionB
Yuwei
2016/08/22 23:46:22
Not sure what is the best description for this con
| |
| 21 const float kExpansionNormalization = (1.f - pow(kExpansionBase, -1)); | |
|
joedow
2016/08/22 22:22:22
I think this might be clearer to create an anonymo
Yuwei
2016/08/22 23:46:22
Done.
BTW nice timestamp, 22 22:22:22 :P
| |
| 22 | |
| 19 } // namespace | 23 } // namespace |
| 20 | 24 |
| 21 namespace remoting { | 25 namespace remoting { |
| 22 | 26 |
| 23 GlCursorFeedback::GlCursorFeedback() {} | 27 GlCursorFeedback::GlCursorFeedback() {} |
| 24 | 28 |
| 25 GlCursorFeedback::~GlCursorFeedback() {} | 29 GlCursorFeedback::~GlCursorFeedback() {} |
| 26 | 30 |
| 27 void GlCursorFeedback::SetCanvas(GlCanvas* canvas) { | 31 void GlCursorFeedback::SetCanvas(GlCanvas* canvas) { |
| 28 if (!canvas) { | 32 if (!canvas) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 47 if (!layer_ || animation_start_time_.is_null()) { | 51 if (!layer_ || animation_start_time_.is_null()) { |
| 48 return false; | 52 return false; |
| 49 } | 53 } |
| 50 float progress = | 54 float progress = |
| 51 (base::TimeTicks::Now() - animation_start_time_).InMilliseconds() / | 55 (base::TimeTicks::Now() - animation_start_time_).InMilliseconds() / |
| 52 kAnimationDurationMs; | 56 kAnimationDurationMs; |
| 53 if (progress > 1) { | 57 if (progress > 1) { |
| 54 animation_start_time_ = base::TimeTicks(); | 58 animation_start_time_ = base::TimeTicks(); |
| 55 return false; | 59 return false; |
| 56 } | 60 } |
| 57 float diameter = progress * max_diameter_; | 61 // Decelerating Expansion: (1 - 400^(-t)) / (1 - 400^(-1)) |
|
joedow
2016/08/22 22:22:21
Can you update the comment a bit here? The commen
Yuwei
2016/08/22 23:46:22
Just removed the comment here. It doesn't seem use
| |
| 62 float expansion_coeff = | |
| 63 (1.f - pow(kExpansionBase, -progress)) / kExpansionNormalization; | |
| 64 float diameter = expansion_coeff * max_diameter_; | |
| 58 std::array<float, 8> positions; | 65 std::array<float, 8> positions; |
| 59 FillRectangleVertexPositions(cursor_x_ - diameter / 2, | 66 FillRectangleVertexPositions(cursor_x_ - diameter / 2, |
| 60 cursor_y_ - diameter / 2, | 67 cursor_y_ - diameter / 2, |
| 61 diameter, diameter, &positions); | 68 diameter, diameter, &positions); |
| 62 layer_->SetVertexPositions(positions); | 69 layer_->SetVertexPositions(positions); |
| 70 | |
| 71 // Linear fade-out. | |
| 63 layer_->Draw(1.f - progress); | 72 layer_->Draw(1.f - progress); |
| 64 return true; | 73 return true; |
| 65 } | 74 } |
| 66 | 75 |
| 67 } // namespace remoting | 76 } // namespace remoting |
| OLD | NEW |