Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef NS_SMILCOMPOSITOR_H_ |
michael@0 | 7 | #define NS_SMILCOMPOSITOR_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsTHashtable.h" |
michael@0 | 10 | #include "nsString.h" |
michael@0 | 11 | #include "nsSMILAnimationFunction.h" |
michael@0 | 12 | #include "nsSMILTargetIdentifier.h" |
michael@0 | 13 | #include "nsSMILCompositorTable.h" |
michael@0 | 14 | #include "pldhash.h" |
michael@0 | 15 | |
michael@0 | 16 | //---------------------------------------------------------------------- |
michael@0 | 17 | // nsSMILCompositor |
michael@0 | 18 | // |
michael@0 | 19 | // Performs the composition of the animation sandwich by combining the results |
michael@0 | 20 | // of a series animation functions according to the rules of SMIL composition |
michael@0 | 21 | // including prioritising animations. |
michael@0 | 22 | |
michael@0 | 23 | class nsSMILCompositor : public PLDHashEntryHdr |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | typedef nsSMILTargetIdentifier KeyType; |
michael@0 | 27 | typedef const KeyType& KeyTypeRef; |
michael@0 | 28 | typedef const KeyType* KeyTypePointer; |
michael@0 | 29 | |
michael@0 | 30 | explicit nsSMILCompositor(KeyTypePointer aKey) |
michael@0 | 31 | : mKey(*aKey), |
michael@0 | 32 | mForceCompositing(false) |
michael@0 | 33 | { } |
michael@0 | 34 | nsSMILCompositor(const nsSMILCompositor& toCopy) |
michael@0 | 35 | : mKey(toCopy.mKey), |
michael@0 | 36 | mAnimationFunctions(toCopy.mAnimationFunctions), |
michael@0 | 37 | mForceCompositing(false) |
michael@0 | 38 | { } |
michael@0 | 39 | ~nsSMILCompositor() { } |
michael@0 | 40 | |
michael@0 | 41 | // PLDHashEntryHdr methods |
michael@0 | 42 | KeyTypeRef GetKey() const { return mKey; } |
michael@0 | 43 | bool KeyEquals(KeyTypePointer aKey) const; |
michael@0 | 44 | static KeyTypePointer KeyToPointer(KeyTypeRef aKey) { return &aKey; } |
michael@0 | 45 | static PLDHashNumber HashKey(KeyTypePointer aKey); |
michael@0 | 46 | enum { ALLOW_MEMMOVE = false }; |
michael@0 | 47 | |
michael@0 | 48 | // Adds the given animation function to this Compositor's list of functions |
michael@0 | 49 | void AddAnimationFunction(nsSMILAnimationFunction* aFunc); |
michael@0 | 50 | |
michael@0 | 51 | // Composes the attribute's current value with the list of animation |
michael@0 | 52 | // functions, and assigns the resulting value to this compositor's target |
michael@0 | 53 | // attribute |
michael@0 | 54 | void ComposeAttribute(); |
michael@0 | 55 | |
michael@0 | 56 | // Clears animation effects on my target attribute |
michael@0 | 57 | void ClearAnimationEffects(); |
michael@0 | 58 | |
michael@0 | 59 | // Cycle-collection support |
michael@0 | 60 | void Traverse(nsCycleCollectionTraversalCallback* aCallback); |
michael@0 | 61 | |
michael@0 | 62 | // Toggles a bit that will force us to composite (bypassing early-return |
michael@0 | 63 | // optimizations) when we hit ComposeAttribute. |
michael@0 | 64 | void ToggleForceCompositing() { mForceCompositing = true; } |
michael@0 | 65 | |
michael@0 | 66 | // Transfers |aOther|'s mCachedBaseValue to |this| |
michael@0 | 67 | void StealCachedBaseValue(nsSMILCompositor* aOther) { |
michael@0 | 68 | mCachedBaseValue = aOther->mCachedBaseValue; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | private: |
michael@0 | 72 | // Create a nsISMILAttr for my target, on the heap. Caller is responsible |
michael@0 | 73 | // for deallocating the returned object. |
michael@0 | 74 | nsISMILAttr* CreateSMILAttr(); |
michael@0 | 75 | |
michael@0 | 76 | // Finds the index of the first function that will affect our animation |
michael@0 | 77 | // sandwich. Also toggles the 'mForceCompositing' flag if it finds that any |
michael@0 | 78 | // (used) functions have changed. |
michael@0 | 79 | uint32_t GetFirstFuncToAffectSandwich(); |
michael@0 | 80 | |
michael@0 | 81 | // If the passed-in base value differs from our cached base value, this |
michael@0 | 82 | // method updates the cached value (and toggles the 'mForceCompositing' flag) |
michael@0 | 83 | void UpdateCachedBaseValue(const nsSMILValue& aBaseValue); |
michael@0 | 84 | |
michael@0 | 85 | // Static callback methods |
michael@0 | 86 | static PLDHashOperator DoComposeAttribute( |
michael@0 | 87 | nsSMILCompositor* aCompositor, void *aData); |
michael@0 | 88 | |
michael@0 | 89 | // The hash key (tuple of element/attributeName/attributeType) |
michael@0 | 90 | KeyType mKey; |
michael@0 | 91 | |
michael@0 | 92 | // Hash Value: List of animation functions that animate the specified attr |
michael@0 | 93 | nsTArray<nsSMILAnimationFunction*> mAnimationFunctions; |
michael@0 | 94 | |
michael@0 | 95 | // Member data for detecting when we need to force-recompose |
michael@0 | 96 | // --------------------------------------------------------- |
michael@0 | 97 | // Flag for tracking whether we need to compose. Initialized to false, but |
michael@0 | 98 | // gets flipped to true if we detect that something has changed. |
michael@0 | 99 | bool mForceCompositing; |
michael@0 | 100 | |
michael@0 | 101 | // Cached base value, so we can detect & force-recompose when it changes |
michael@0 | 102 | // from one sample to the next. (nsSMILAnimationController copies this |
michael@0 | 103 | // forward from the previous sample's compositor.) |
michael@0 | 104 | nsAutoPtr<nsSMILValue> mCachedBaseValue; |
michael@0 | 105 | }; |
michael@0 | 106 | |
michael@0 | 107 | #endif // NS_SMILCOMPOSITOR_H_ |