| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "platform/exported/WebActiveGestureAnimation.h" | 26 #include "platform/exported/WebActiveGestureAnimation.h" |
| 27 | 27 |
| 28 #include <memory> | 28 #include <memory> |
| 29 #include "platform/wtf/PtrUtil.h" | 29 #include "platform/wtf/PtrUtil.h" |
| 30 #include "public/platform/WebGestureCurve.h" | 30 #include "public/platform/WebGestureCurve.h" |
| 31 #include "public/platform/WebGestureCurveTarget.h" | 31 #include "public/platform/WebGestureCurveTarget.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 std::unique_ptr<WebActiveGestureAnimation> | 35 std::unique_ptr<WebActiveGestureAnimation> |
| 36 WebActiveGestureAnimation::CreateAtAnimationStart( |
| 37 std::unique_ptr<WebGestureCurve> curve, |
| 38 WebGestureCurveTarget* target) { |
| 39 return WTF::WrapUnique( |
| 40 new WebActiveGestureAnimation(std::move(curve), target, 0, true)); |
| 41 } |
| 42 |
| 43 std::unique_ptr<WebActiveGestureAnimation> |
| 36 WebActiveGestureAnimation::CreateWithTimeOffset( | 44 WebActiveGestureAnimation::CreateWithTimeOffset( |
| 37 std::unique_ptr<WebGestureCurve> curve, | 45 std::unique_ptr<WebGestureCurve> curve, |
| 38 WebGestureCurveTarget* target, | 46 WebGestureCurveTarget* target, |
| 39 double start_time) { | 47 double start_time) { |
| 40 return WTF::WrapUnique( | 48 return WTF::WrapUnique(new WebActiveGestureAnimation(std::move(curve), target, |
| 41 new WebActiveGestureAnimation(std::move(curve), target, start_time)); | 49 start_time, false)); |
| 42 } | 50 } |
| 43 | 51 |
| 44 WebActiveGestureAnimation::~WebActiveGestureAnimation() {} | 52 WebActiveGestureAnimation::~WebActiveGestureAnimation() {} |
| 45 | 53 |
| 46 WebActiveGestureAnimation::WebActiveGestureAnimation( | 54 WebActiveGestureAnimation::WebActiveGestureAnimation( |
| 47 std::unique_ptr<WebGestureCurve> curve, | 55 std::unique_ptr<WebGestureCurve> curve, |
| 48 WebGestureCurveTarget* target, | 56 WebGestureCurveTarget* target, |
| 49 double start_time) | 57 double start_time, |
| 50 : start_time_(start_time), curve_(std::move(curve)), target_(target) {} | 58 bool waiting_for_first_tick) |
| 59 : start_time_(start_time), |
| 60 waiting_for_first_tick_(waiting_for_first_tick), |
| 61 curve_(std::move(curve)), |
| 62 target_(target) {} |
| 51 | 63 |
| 52 bool WebActiveGestureAnimation::Animate(double time) { | 64 bool WebActiveGestureAnimation::Animate(double time) { |
| 65 if (waiting_for_first_tick_) { |
| 66 start_time_ = time; |
| 67 waiting_for_first_tick_ = false; |
| 68 } |
| 53 // All WebGestureCurves assume zero-based time, so we subtract | 69 // All WebGestureCurves assume zero-based time, so we subtract |
| 54 // the animation start time before passing to the curve. | 70 // the animation start time before passing to the curve. |
| 55 return curve_->Apply(time - start_time_, target_); | 71 return curve_->Apply(time - start_time_, target_); |
| 56 } | 72 } |
| 57 | 73 |
| 58 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |