Bug 1887774 pass a track to EnsureAudioProcessing() r=pehrsons
[gecko.git] / dom / smil / SMILValue.h
blobd57daa5eb38efc2208231a99b2499ee12013a964
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_SMIL_SMILVALUE_H_
8 #define DOM_SMIL_SMILVALUE_H_
10 #include "mozilla/SMILNullType.h"
11 #include "mozilla/SMILType.h"
13 namespace mozilla {
15 /**
16 * Although objects of this type are generally only created on the stack and
17 * only exist during the taking of a new time sample, that's not always the
18 * case. The SMILValue objects obtained from attributes' base values are
19 * cached so that the SMIL engine can make certain optimizations during a
20 * sample if the base value has not changed since the last sample (potentially
21 * avoiding recomposing). These SMILValue objects typically live much longer
22 * than a single sample.
24 class SMILValue {
25 public:
26 SMILValue() : mU(), mType(SMILNullType::Singleton()) {}
27 explicit SMILValue(const SMILType* aType);
28 SMILValue(const SMILValue& aVal);
30 ~SMILValue() { mType->Destroy(*this); }
32 const SMILValue& operator=(const SMILValue& aVal);
34 // Move constructor / reassignment operator:
35 SMILValue(SMILValue&& aVal) noexcept;
36 SMILValue& operator=(SMILValue&& aVal) noexcept;
38 // Equality operators. These are allowed to be conservative (return false
39 // more than you'd expect) - see comment above SMILType::IsEqual.
40 bool operator==(const SMILValue& aVal) const;
41 bool operator!=(const SMILValue& aVal) const { return !(*this == aVal); }
43 bool IsNull() const { return (mType == SMILNullType::Singleton()); }
45 nsresult Add(const SMILValue& aValueToAdd, uint32_t aCount = 1);
46 nsresult SandwichAdd(const SMILValue& aValueToAdd);
47 nsresult ComputeDistance(const SMILValue& aTo, double& aDistance) const;
48 nsresult Interpolate(const SMILValue& aEndVal, double aUnitDistance,
49 SMILValue& aResult) const;
51 union {
52 bool mBool;
53 uint64_t mUint;
54 int64_t mInt;
55 double mDouble;
56 struct {
57 float mAngle;
58 uint16_t mUnit;
59 uint16_t mOrientType;
60 } mOrient;
61 int32_t mIntPair[2];
62 float mNumberPair[2];
63 void* mPtr;
64 } mU;
65 const SMILType* mType;
67 protected:
68 void InitAndCheckPostcondition(const SMILType* aNewType);
69 void DestroyAndCheckPostcondition();
70 void DestroyAndReinit(const SMILType* aNewType);
73 } // namespace mozilla
75 #endif // DOM_SMIL_SMILVALUE_H_