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

Side by Side Diff: third_party/WebKit/Source/platform/animation/TimingFunction.h

Issue 2775143002: Implement frames() timing function (Closed)
Patch Set: Fix behaviour outside input range [0,1] Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 StepPosition GetStepPosition() const { return steps_->step_position(); } 215 StepPosition GetStepPosition() const { return steps_->step_position(); }
216 216
217 private: 217 private:
218 StepsTimingFunction(int steps, StepPosition step_position) 218 StepsTimingFunction(int steps, StepPosition step_position)
219 : TimingFunction(Type::STEPS), 219 : TimingFunction(Type::STEPS),
220 steps_(cc::StepsTimingFunction::Create(steps, step_position)) {} 220 steps_(cc::StepsTimingFunction::Create(steps, step_position)) {}
221 221
222 std::unique_ptr<cc::StepsTimingFunction> steps_; 222 std::unique_ptr<cc::StepsTimingFunction> steps_;
223 }; 223 };
224 224
225 class PLATFORM_EXPORT FramesTimingFunction final : public TimingFunction {
226 public:
227 static PassRefPtr<FramesTimingFunction> Create(int frames) {
228 return AdoptRef(new FramesTimingFunction(frames));
229 }
230
231 ~FramesTimingFunction() override {}
232
233 // TimingFunction implementation.
234 String ToString() const override;
235 double Evaluate(double fraction, double) const override;
236 void Range(double* min_value, double* max_value) const override;
237 std::unique_ptr<cc::TimingFunction> CloneToCC() const override;
238
239 int NumberOfFrames() const { return frames_->frames(); }
240
241 private:
242 FramesTimingFunction(int frames)
243 : TimingFunction(Type::FRAMES),
244 frames_(cc::FramesTimingFunction::Create(frames)) {}
245
246 std::unique_ptr<cc::FramesTimingFunction> frames_;
247 };
248
225 PLATFORM_EXPORT PassRefPtr<TimingFunction> CreateCompositorTimingFunctionFromCC( 249 PLATFORM_EXPORT PassRefPtr<TimingFunction> CreateCompositorTimingFunctionFromCC(
226 const cc::TimingFunction*); 250 const cc::TimingFunction*);
227 251
228 PLATFORM_EXPORT bool operator==(const LinearTimingFunction&, 252 PLATFORM_EXPORT bool operator==(const LinearTimingFunction&,
229 const TimingFunction&); 253 const TimingFunction&);
230 PLATFORM_EXPORT bool operator==(const CubicBezierTimingFunction&, 254 PLATFORM_EXPORT bool operator==(const CubicBezierTimingFunction&,
231 const TimingFunction&); 255 const TimingFunction&);
232 PLATFORM_EXPORT bool operator==(const StepsTimingFunction&, 256 PLATFORM_EXPORT bool operator==(const StepsTimingFunction&,
233 const TimingFunction&); 257 const TimingFunction&);
258 PLATFORM_EXPORT bool operator==(const FramesTimingFunction&,
259 const TimingFunction&);
234 260
235 PLATFORM_EXPORT bool operator==(const TimingFunction&, const TimingFunction&); 261 PLATFORM_EXPORT bool operator==(const TimingFunction&, const TimingFunction&);
236 PLATFORM_EXPORT bool operator!=(const TimingFunction&, const TimingFunction&); 262 PLATFORM_EXPORT bool operator!=(const TimingFunction&, const TimingFunction&);
237 263
238 #define DEFINE_TIMING_FUNCTION_TYPE_CASTS(typeName, enumName) \ 264 #define DEFINE_TIMING_FUNCTION_TYPE_CASTS(typeName, enumName) \
239 DEFINE_TYPE_CASTS(typeName##TimingFunction, TimingFunction, value, \ 265 DEFINE_TYPE_CASTS(typeName##TimingFunction, TimingFunction, value, \
240 value->GetType() == TimingFunction::Type::enumName, \ 266 value->GetType() == TimingFunction::Type::enumName, \
241 value.GetType() == TimingFunction::Type::enumName) 267 value.GetType() == TimingFunction::Type::enumName)
242 268
243 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear, LINEAR); 269 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear, LINEAR);
244 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier, CUBIC_BEZIER); 270 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier, CUBIC_BEZIER);
245 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps, STEPS); 271 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps, STEPS);
272 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Frames, FRAMES);
246 273
247 } // namespace blink 274 } // namespace blink
248 275
249 #endif // TimingFunction_h 276 #endif // TimingFunction_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698