2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2018-12-28 13:34:35 +03:00
|
|
|
/* implementation of SMILType for use by <animateMotion> element */
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_SVGMOTIONSMILTYPE_H_
|
|
|
|
#define MOZILLA_SVGMOTIONSMILTYPE_H_
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-01-09 03:34:14 +03:00
|
|
|
#include "mozilla/SMILType.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
class SMILValue;
|
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
/**
|
|
|
|
* MotionRotateType: Enum to indicate the type of our "rotate" attribute.
|
|
|
|
*/
|
|
|
|
enum RotateType {
|
|
|
|
eRotateType_Explicit, // for e.g. rotate="45"/"45deg"/"0.785rad"
|
|
|
|
eRotateType_Auto, // for rotate="auto"
|
|
|
|
eRotateType_AutoReverse // for rotate="auto-reverse"
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2018-12-28 13:34:35 +03:00
|
|
|
* SVGMotionSMILType: Implements the SMILType interface for SMIL animations
|
2010-04-29 03:00:54 +04:00
|
|
|
* from <animateMotion>.
|
|
|
|
*
|
|
|
|
* NOTE: Even though there's technically no "motion" attribute, we behave in
|
|
|
|
* many ways as if there were, for simplicity.
|
|
|
|
*/
|
2018-12-28 13:34:35 +03:00
|
|
|
class SVGMotionSMILType : public SMILType {
|
2013-11-18 05:29:06 +04:00
|
|
|
typedef mozilla::gfx::Path Path;
|
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
public:
|
2019-01-23 16:48:08 +03:00
|
|
|
// Singleton for SMILValue objects to hold onto.
|
2010-04-29 03:00:54 +04:00
|
|
|
static SVGMotionSMILType sSingleton;
|
|
|
|
|
|
|
|
protected:
|
2018-12-28 13:34:35 +03:00
|
|
|
// SMILType Methods
|
2010-04-29 03:00:54 +04:00
|
|
|
// -------------------
|
2019-01-23 16:48:08 +03:00
|
|
|
virtual void Init(SMILValue& aValue) const override;
|
|
|
|
virtual void Destroy(SMILValue& aValue) const override;
|
|
|
|
virtual nsresult Assign(SMILValue& aDest,
|
|
|
|
const SMILValue& aSrc) const override;
|
|
|
|
virtual bool IsEqual(const SMILValue& aLeft,
|
|
|
|
const SMILValue& aRight) const override;
|
|
|
|
virtual nsresult Add(SMILValue& aDest, const SMILValue& aValueToAdd,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aCount) const override;
|
2019-01-23 16:48:08 +03:00
|
|
|
virtual nsresult SandwichAdd(SMILValue& aDest,
|
|
|
|
const SMILValue& aValueToAdd) const override;
|
|
|
|
virtual nsresult ComputeDistance(const SMILValue& aFrom, const SMILValue& aTo,
|
2015-03-21 19:28:04 +03:00
|
|
|
double& aDistance) const override;
|
2019-01-23 16:48:08 +03:00
|
|
|
virtual nsresult Interpolate(const SMILValue& aStartVal,
|
|
|
|
const SMILValue& aEndVal, double aUnitDistance,
|
|
|
|
SMILValue& aResult) const override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
public:
|
2019-01-23 16:48:08 +03:00
|
|
|
// Used to generate a transform matrix from an <animateMotion> SMILValue.
|
|
|
|
static gfx::Matrix CreateMatrix(const SMILValue& aSMILVal);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2019-01-23 16:48:08 +03:00
|
|
|
// Used to generate a SMILValue for the point at the given distance along
|
2010-04-29 03:00:54 +04:00
|
|
|
// the given path.
|
2019-01-23 16:48:08 +03:00
|
|
|
static SMILValue ConstructSMILValue(Path* aPath, float aDist,
|
|
|
|
RotateType aRotateType,
|
|
|
|
float aRotateAngle);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
private:
|
2013-08-12 18:13:34 +04:00
|
|
|
// Private constructor: prevent instances beyond my singleton.
|
2019-04-10 07:34:35 +03:00
|
|
|
constexpr SVGMotionSMILType() = default;
|
2010-04-29 03:00:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_SVGMOTIONSMILTYPE_H_
|