LCOV - code coverage report
Current view: directory - content/smil - nsSMILCompositor.h (source / functions) Found Hit Coverage
Test: app.info Lines: 13 0 0.0 %
Date: 2012-06-02 Functions: 7 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SMIL module.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is the Mozilla Corporation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2008
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Daniel Holbert <dholbert@mozilla.com>
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef NS_SMILCOMPOSITOR_H_
      39                 : #define NS_SMILCOMPOSITOR_H_
      40                 : 
      41                 : #include "nsTHashtable.h"
      42                 : #include "nsString.h"
      43                 : #include "nsSMILAnimationFunction.h"
      44                 : #include "nsSMILTargetIdentifier.h"
      45                 : #include "nsSMILCompositorTable.h"
      46                 : #include "pldhash.h"
      47                 : 
      48                 : //----------------------------------------------------------------------
      49                 : // nsSMILCompositor
      50                 : //
      51                 : // Performs the composition of the animation sandwich by combining the results
      52                 : // of a series animation functions according to the rules of SMIL composition
      53                 : // including prioritising animations.
      54                 : 
      55                 : class nsSMILCompositor : public PLDHashEntryHdr
      56                 : {
      57                 : public:
      58                 :   typedef nsSMILTargetIdentifier KeyType;
      59                 :   typedef const KeyType& KeyTypeRef;
      60                 :   typedef const KeyType* KeyTypePointer;
      61                 : 
      62               0 :   explicit nsSMILCompositor(KeyTypePointer aKey)
      63                 :    : mKey(*aKey),
      64               0 :      mForceCompositing(false)
      65               0 :   { }
      66               0 :   nsSMILCompositor(const nsSMILCompositor& toCopy)
      67                 :     : mKey(toCopy.mKey),
      68                 :       mAnimationFunctions(toCopy.mAnimationFunctions),
      69               0 :       mForceCompositing(false)
      70               0 :   { }
      71               0 :   ~nsSMILCompositor() { }
      72                 : 
      73                 :   // PLDHashEntryHdr methods
      74               0 :   KeyTypeRef GetKey() const { return mKey; }
      75                 :   bool KeyEquals(KeyTypePointer aKey) const;
      76               0 :   static KeyTypePointer KeyToPointer(KeyTypeRef aKey) { return &aKey; }
      77                 :   static PLDHashNumber HashKey(KeyTypePointer aKey);
      78                 :   enum { ALLOW_MEMMOVE = false };
      79                 : 
      80                 :   // Adds the given animation function to this Compositor's list of functions
      81                 :   void AddAnimationFunction(nsSMILAnimationFunction* aFunc);
      82                 : 
      83                 :   // Composes the attribute's current value with the list of animation
      84                 :   // functions, and assigns the resulting value to this compositor's target
      85                 :   // attribute
      86                 :   void ComposeAttribute();
      87                 : 
      88                 :   // Clears animation effects on my target attribute
      89                 :   void ClearAnimationEffects();
      90                 : 
      91                 :   // Cycle-collection support
      92                 :   void Traverse(nsCycleCollectionTraversalCallback* aCallback);
      93                 : 
      94                 :   // Toggles a bit that will force us to composite (bypassing early-return
      95                 :   // optimizations) when we hit ComposeAttribute.
      96               0 :   void ToggleForceCompositing() { mForceCompositing = true; }
      97                 : 
      98                 :   // Transfers |aOther|'s mCachedBaseValue to |this|
      99               0 :   void StealCachedBaseValue(nsSMILCompositor* aOther) {
     100               0 :     mCachedBaseValue = aOther->mCachedBaseValue;
     101               0 :   }
     102                 : 
     103                 :  private:
     104                 :   // Create a nsISMILAttr for my target, on the heap.  Caller is responsible
     105                 :   // for deallocating the returned object.
     106                 :   nsISMILAttr* CreateSMILAttr();
     107                 :   
     108                 :   // Finds the index of the first function that will affect our animation
     109                 :   // sandwich. Also toggles the 'mForceCompositing' flag if it finds that any
     110                 :   // (used) functions have changed.
     111                 :   PRUint32 GetFirstFuncToAffectSandwich();
     112                 : 
     113                 :   // If the passed-in base value differs from our cached base value, this
     114                 :   // method updates the cached value (and toggles the 'mForceCompositing' flag)
     115                 :   void UpdateCachedBaseValue(const nsSMILValue& aBaseValue);
     116                 : 
     117                 :   // Static callback methods
     118                 :   PR_STATIC_CALLBACK(PLDHashOperator) DoComposeAttribute(
     119                 :       nsSMILCompositor* aCompositor, void *aData);
     120                 : 
     121                 :   // The hash key (tuple of element/attributeName/attributeType)
     122                 :   KeyType mKey;
     123                 : 
     124                 :   // Hash Value: List of animation functions that animate the specified attr
     125                 :   nsTArray<nsSMILAnimationFunction*> mAnimationFunctions;
     126                 : 
     127                 :   // Member data for detecting when we need to force-recompose
     128                 :   // ---------------------------------------------------------
     129                 :   // Flag for tracking whether we need to compose. Initialized to false, but
     130                 :   // gets flipped to true if we detect that something has changed.
     131                 :   bool mForceCompositing;
     132                 : 
     133                 :   // Cached base value, so we can detect & force-recompose when it changes
     134                 :   // from one sample to the next. (nsSMILAnimationController copies this
     135                 :   // forward from the previous sample's compositor.)
     136                 :   nsAutoPtr<nsSMILValue> mCachedBaseValue;
     137                 : };
     138                 : 
     139                 : #endif // NS_SMILCOMPOSITOR_H_

Generated by: LCOV version 1.7