2009-01-14 20:38:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
#ifndef NS_SMILCOMPOSITOR_H_
|
|
|
|
#define NS_SMILCOMPOSITOR_H_
|
|
|
|
|
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsSMILAnimationFunction.h"
|
2010-02-20 13:13:11 -08:00
|
|
|
#include "nsSMILTargetIdentifier.h"
|
2009-01-14 20:38:07 -08:00
|
|
|
#include "nsSMILCompositorTable.h"
|
|
|
|
#include "pldhash.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSMILCompositor
|
|
|
|
//
|
|
|
|
// Performs the composition of the animation sandwich by combining the results
|
|
|
|
// of a series animation functions according to the rules of SMIL composition
|
|
|
|
// including prioritising animations.
|
|
|
|
|
|
|
|
class nsSMILCompositor : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
2010-02-20 13:13:11 -08:00
|
|
|
typedef nsSMILTargetIdentifier KeyType;
|
|
|
|
typedef const KeyType& KeyTypeRef;
|
|
|
|
typedef const KeyType* KeyTypePointer;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-02-20 13:13:11 -08:00
|
|
|
explicit nsSMILCompositor(KeyTypePointer aKey)
|
|
|
|
: mKey(*aKey),
|
2011-10-17 07:59:28 -07:00
|
|
|
mForceCompositing(false)
|
2010-02-20 13:13:11 -08:00
|
|
|
{ }
|
2009-01-14 20:38:07 -08:00
|
|
|
nsSMILCompositor(const nsSMILCompositor& toCopy)
|
|
|
|
: mKey(toCopy.mKey),
|
2010-02-20 13:13:11 -08:00
|
|
|
mAnimationFunctions(toCopy.mAnimationFunctions),
|
2011-10-17 07:59:28 -07:00
|
|
|
mForceCompositing(false)
|
2009-01-14 20:38:07 -08:00
|
|
|
{ }
|
|
|
|
~nsSMILCompositor() { }
|
|
|
|
|
|
|
|
// PLDHashEntryHdr methods
|
2010-02-20 13:13:11 -08:00
|
|
|
KeyTypeRef GetKey() const { return mKey; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool KeyEquals(KeyTypePointer aKey) const;
|
2010-02-20 13:13:11 -08:00
|
|
|
static KeyTypePointer KeyToPointer(KeyTypeRef aKey) { return &aKey; }
|
2009-01-14 20:38:07 -08:00
|
|
|
static PLDHashNumber HashKey(KeyTypePointer aKey);
|
2011-10-17 07:59:28 -07:00
|
|
|
enum { ALLOW_MEMMOVE = false };
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
// Adds the given animation function to this Compositor's list of functions
|
|
|
|
void AddAnimationFunction(nsSMILAnimationFunction* aFunc);
|
2009-07-15 11:33:31 -07:00
|
|
|
|
2009-07-14 12:33:29 -07:00
|
|
|
// Composes the attribute's current value with the list of animation
|
|
|
|
// functions, and assigns the resulting value to this compositor's target
|
|
|
|
// attribute
|
|
|
|
void ComposeAttribute();
|
|
|
|
|
|
|
|
// Clears animation effects on my target attribute
|
|
|
|
void ClearAnimationEffects();
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
// Cycle-collection support
|
|
|
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
|
|
|
|
2010-02-20 13:13:11 -08:00
|
|
|
// Toggles a bit that will force us to composite (bypassing early-return
|
|
|
|
// optimizations) when we hit ComposeAttribute.
|
2011-10-17 07:59:28 -07:00
|
|
|
void ToggleForceCompositing() { mForceCompositing = true; }
|
2010-02-20 13:13:11 -08:00
|
|
|
|
2010-02-20 13:13:11 -08:00
|
|
|
// Transfers |aOther|'s mCachedBaseValue to |this|
|
|
|
|
void StealCachedBaseValue(nsSMILCompositor* aOther) {
|
|
|
|
mCachedBaseValue = aOther->mCachedBaseValue;
|
|
|
|
}
|
|
|
|
|
2009-01-14 20:38:07 -08:00
|
|
|
private:
|
2009-07-14 12:33:29 -07:00
|
|
|
// Create a nsISMILAttr for my target, on the heap. Caller is responsible
|
|
|
|
// for deallocating the returned object.
|
|
|
|
nsISMILAttr* CreateSMILAttr();
|
2010-02-20 13:13:11 -08:00
|
|
|
|
|
|
|
// Finds the index of the first function that will affect our animation
|
|
|
|
// sandwich. Also toggles the 'mForceCompositing' flag if it finds that any
|
|
|
|
// (used) functions have changed.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetFirstFuncToAffectSandwich();
|
2010-02-20 13:13:11 -08:00
|
|
|
|
|
|
|
// If the passed-in base value differs from our cached base value, this
|
|
|
|
// method updates the cached value (and toggles the 'mForceCompositing' flag)
|
|
|
|
void UpdateCachedBaseValue(const nsSMILValue& aBaseValue);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
// Static callback methods
|
|
|
|
PR_STATIC_CALLBACK(PLDHashOperator) DoComposeAttribute(
|
|
|
|
nsSMILCompositor* aCompositor, void *aData);
|
|
|
|
|
2010-02-20 13:13:11 -08:00
|
|
|
// The hash key (tuple of element/attributeName/attributeType)
|
|
|
|
KeyType mKey;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-02-20 13:13:11 -08:00
|
|
|
// Hash Value: List of animation functions that animate the specified attr
|
2009-01-14 20:38:07 -08:00
|
|
|
nsTArray<nsSMILAnimationFunction*> mAnimationFunctions;
|
2010-02-20 13:13:11 -08:00
|
|
|
|
|
|
|
// Member data for detecting when we need to force-recompose
|
|
|
|
// ---------------------------------------------------------
|
2011-10-17 07:59:28 -07:00
|
|
|
// Flag for tracking whether we need to compose. Initialized to false, but
|
|
|
|
// gets flipped to true if we detect that something has changed.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mForceCompositing;
|
2010-02-20 13:13:11 -08:00
|
|
|
|
|
|
|
// Cached base value, so we can detect & force-recompose when it changes
|
2012-02-23 16:45:40 -08:00
|
|
|
// from one sample to the next. (nsSMILAnimationController copies this
|
2010-02-20 13:13:11 -08:00
|
|
|
// forward from the previous sample's compositor.)
|
|
|
|
nsAutoPtr<nsSMILValue> mCachedBaseValue;
|
2009-01-14 20:38:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NS_SMILCOMPOSITOR_H_
|