LCOV - code coverage report
Current view: top level - gfx/2d - RecordedEventImpl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1373 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 903 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef MOZILLA_GFX_RECORDEDEVENTIMPL_H_
       7             : #define MOZILLA_GFX_RECORDEDEVENTIMPL_H_
       8             : 
       9             : #include "RecordedEvent.h"
      10             : 
      11             : #include "PathRecording.h"
      12             : #include "RecordingTypes.h"
      13             : #include "Tools.h"
      14             : #include "Filters.h"
      15             : #include "Logging.h"
      16             : #include "ScaledFontBase.h"
      17             : #include "SFNTData.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace gfx {
      21             : 
      22             : template<class Derived>
      23           0 : class RecordedEventDerived : public RecordedEvent {
      24           0 :   using RecordedEvent::RecordedEvent;
      25           0 :   void RecordToStream(std::ostream &aStream) const {
      26           0 :     static_cast<const Derived*>(this)->Record(aStream);
      27           0 :   }
      28           0 :   void RecordToStream(MemStream &aStream) const {
      29           0 :     SizeCollector size;
      30           0 :     static_cast<const Derived*>(this)->Record(size);
      31           0 :     aStream.Resize(aStream.mLength + size.mTotalSize);
      32           0 :     MemWriter writer(aStream.mData + aStream.mLength - size.mTotalSize);
      33           0 :     static_cast<const Derived*>(this)->Record(writer);
      34           0 :   }
      35             : };
      36             : 
      37             : template<class Derived>
      38           0 : class RecordedDrawingEvent : public RecordedEventDerived<Derived>
      39             : {
      40             : public:
      41           0 :    virtual ReferencePtr GetDestinedDT() { return mDT; }
      42             : 
      43             : protected:
      44           0 :   RecordedDrawingEvent(RecordedEvent::EventType aType, DrawTarget *aTarget)
      45           0 :     : RecordedEventDerived<Derived>(aType), mDT(aTarget)
      46             :   {
      47           0 :   }
      48             : 
      49             :   template<class S>
      50             :   RecordedDrawingEvent(RecordedEvent::EventType aType, S &aStream);
      51             :   template<class S>
      52             :   void Record(S &aStream) const;
      53             : 
      54             :   virtual ReferencePtr GetObjectRef() const;
      55             : 
      56             :   ReferencePtr mDT;
      57             : };
      58             : 
      59           0 : class RecordedDrawTargetCreation : public RecordedEventDerived<RecordedDrawTargetCreation> {
      60             : public:
      61           0 :   RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType, const IntSize &aSize, SurfaceFormat aFormat,
      62             :                              bool aHasExistingData = false, SourceSurface *aExistingData = nullptr)
      63           0 :     : RecordedEventDerived(DRAWTARGETCREATION), mRefPtr(aRefPtr), mBackendType(aType), mSize(aSize), mFormat(aFormat)
      64           0 :     , mHasExistingData(aHasExistingData), mExistingData(aExistingData)
      65           0 :   {}
      66             : 
      67             :   virtual bool PlayEvent(Translator *aTranslator) const;
      68             : 
      69             :   template<class S>
      70             :   void Record(S &aStream) const;
      71             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
      72             : 
      73           0 :   virtual std::string GetName() const { return "DrawTarget Creation"; }
      74           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
      75             : 
      76             :   ReferencePtr mRefPtr;
      77             :   BackendType mBackendType;
      78             :   IntSize mSize;
      79             :   SurfaceFormat mFormat;
      80             :   bool mHasExistingData;
      81             :   RefPtr<SourceSurface> mExistingData;
      82             :   
      83             : private:
      84             :   friend class RecordedEvent;
      85             : 
      86             :   template<class S>
      87             :   MOZ_IMPLICIT RecordedDrawTargetCreation(S &aStream);
      88             : };
      89             : 
      90           0 : class RecordedDrawTargetDestruction : public RecordedEventDerived<RecordedDrawTargetDestruction> {
      91             : public:
      92           0 :   MOZ_IMPLICIT RecordedDrawTargetDestruction(ReferencePtr aRefPtr)
      93           0 :     : RecordedEventDerived(DRAWTARGETDESTRUCTION), mRefPtr(aRefPtr)
      94           0 :   {}
      95             : 
      96             :   virtual bool PlayEvent(Translator *aTranslator) const;
      97             : 
      98             :   template<class S>
      99             :   void Record(S &aStream) const;
     100             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     101             : 
     102           0 :   virtual std::string GetName() const { return "DrawTarget Destruction"; }
     103           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     104             : 
     105             :   ReferencePtr mRefPtr;
     106             : 
     107             :   BackendType mBackendType;
     108             : private:
     109             :   friend class RecordedEvent;
     110             : 
     111             :   template<class S>
     112             :   MOZ_IMPLICIT RecordedDrawTargetDestruction(S &aStream);
     113             : };
     114             : 
     115           0 : class RecordedCreateSimilarDrawTarget : public RecordedEventDerived<RecordedCreateSimilarDrawTarget> {
     116             : public:
     117           0 :   RecordedCreateSimilarDrawTarget(ReferencePtr aRefPtr, const IntSize &aSize,
     118             :                                   SurfaceFormat aFormat)
     119           0 :     : RecordedEventDerived(CREATESIMILARDRAWTARGET)
     120           0 :     , mRefPtr(aRefPtr) , mSize(aSize), mFormat(aFormat)
     121             :   {
     122           0 :   }
     123             : 
     124             :   virtual bool PlayEvent(Translator *aTranslator) const;
     125             : 
     126             :   template<class S>
     127             :   void Record(S &aStream) const;
     128             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     129             : 
     130           0 :   virtual std::string GetName() const { return "CreateSimilarDrawTarget"; }
     131           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     132             : 
     133             :   ReferencePtr mRefPtr;
     134             :   IntSize mSize;
     135             :   SurfaceFormat mFormat;
     136             : 
     137             : private:
     138             :   friend class RecordedEvent;
     139             : 
     140             :   template<class S>
     141             :   MOZ_IMPLICIT RecordedCreateSimilarDrawTarget(S &aStream);
     142             : };
     143             : 
     144           0 : class RecordedFillRect : public RecordedDrawingEvent<RecordedFillRect> {
     145             : public:
     146           0 :   RecordedFillRect(DrawTarget *aDT, const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions)
     147           0 :     : RecordedDrawingEvent(FILLRECT, aDT), mRect(aRect), mOptions(aOptions)
     148             :   {
     149           0 :     StorePattern(mPattern, aPattern);
     150           0 :   }
     151             : 
     152             :   virtual bool PlayEvent(Translator *aTranslator) const;
     153             : 
     154             :   template<class S>
     155             :   void Record(S &aStream) const;
     156             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     157             : 
     158           0 :   virtual std::string GetName() const { return "FillRect"; }
     159             : private:
     160             :   friend class RecordedEvent;
     161             : 
     162             :   template<class S>
     163             :   MOZ_IMPLICIT RecordedFillRect(S &aStream);
     164             : 
     165             :   Rect mRect;
     166             :   PatternStorage mPattern;
     167             :   DrawOptions mOptions;
     168             : };
     169             : 
     170           0 : class RecordedStrokeRect : public RecordedDrawingEvent<RecordedStrokeRect> {
     171             : public:
     172           0 :   RecordedStrokeRect(DrawTarget *aDT, const Rect &aRect, const Pattern &aPattern,
     173             :                      const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
     174           0 :     : RecordedDrawingEvent(STROKERECT, aDT), mRect(aRect),
     175           0 :       mStrokeOptions(aStrokeOptions), mOptions(aOptions)
     176             :   {
     177           0 :     StorePattern(mPattern, aPattern);
     178           0 :   }
     179             : 
     180             :   virtual bool PlayEvent(Translator *aTranslator) const;
     181             : 
     182             :   template<class S>
     183             :   void Record(S &aStream) const;
     184             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     185             : 
     186           0 :   virtual std::string GetName() const { return "StrokeRect"; }
     187             : private:
     188             :   friend class RecordedEvent;
     189             : 
     190             :   template<class S>
     191             :   MOZ_IMPLICIT RecordedStrokeRect(S &aStream);
     192             : 
     193             :   Rect mRect;
     194             :   PatternStorage mPattern;
     195             :   StrokeOptions mStrokeOptions;
     196             :   DrawOptions mOptions;
     197             : };
     198             : 
     199           0 : class RecordedStrokeLine : public RecordedDrawingEvent<RecordedStrokeLine> {
     200             : public:
     201           0 :   RecordedStrokeLine(DrawTarget *aDT, const Point &aBegin, const Point &aEnd,
     202             :                      const Pattern &aPattern, const StrokeOptions &aStrokeOptions,
     203             :                      const DrawOptions &aOptions)
     204           0 :     : RecordedDrawingEvent(STROKELINE, aDT), mBegin(aBegin), mEnd(aEnd),
     205           0 :       mStrokeOptions(aStrokeOptions), mOptions(aOptions)
     206             :   {
     207           0 :     StorePattern(mPattern, aPattern);
     208           0 :   }
     209             : 
     210             :   virtual bool PlayEvent(Translator *aTranslator) const;
     211             : 
     212             :   template<class S>
     213             :   void Record(S &aStream) const;
     214             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     215             : 
     216           0 :   virtual std::string GetName() const { return "StrokeLine"; }
     217             : private:
     218             :   friend class RecordedEvent;
     219             : 
     220             :   template<class S>
     221             :   MOZ_IMPLICIT RecordedStrokeLine(S &aStream);
     222             : 
     223             :   Point mBegin;
     224             :   Point mEnd;
     225             :   PatternStorage mPattern;
     226             :   StrokeOptions mStrokeOptions;
     227             :   DrawOptions mOptions;
     228             : };
     229             : 
     230           0 : class RecordedFill : public RecordedDrawingEvent<RecordedFill> {
     231             : public:
     232           0 :   RecordedFill(DrawTarget *aDT, ReferencePtr aPath, const Pattern &aPattern, const DrawOptions &aOptions)
     233           0 :     : RecordedDrawingEvent(FILL, aDT), mPath(aPath), mOptions(aOptions)
     234             :   {
     235           0 :     StorePattern(mPattern, aPattern);
     236           0 :   }
     237             : 
     238             :   virtual bool PlayEvent(Translator *aTranslator) const;
     239             : 
     240             :   template<class S> void Record(S &aStream) const;
     241             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     242             : 
     243           0 :   virtual std::string GetName() const { return "Fill"; }
     244             : private:
     245             :   friend class RecordedEvent;
     246             : 
     247             :   template<class S>
     248             :   MOZ_IMPLICIT RecordedFill(S &aStream);
     249             : 
     250             :   ReferencePtr mPath;
     251             :   PatternStorage mPattern;
     252             :   DrawOptions mOptions;
     253             : };
     254             : 
     255             : class RecordedFillGlyphs : public RecordedDrawingEvent<RecordedFillGlyphs> {
     256             : public:
     257           0 :   RecordedFillGlyphs(DrawTarget *aDT, ReferencePtr aScaledFont, const Pattern &aPattern, const DrawOptions &aOptions,
     258             :                      const Glyph *aGlyphs, uint32_t aNumGlyphs)
     259           0 :     : RecordedDrawingEvent(FILLGLYPHS, aDT), mScaledFont(aScaledFont), mOptions(aOptions)
     260             :   {
     261           0 :     StorePattern(mPattern, aPattern);
     262           0 :     mNumGlyphs = aNumGlyphs;
     263           0 :     mGlyphs = new Glyph[aNumGlyphs];
     264           0 :     memcpy(mGlyphs, aGlyphs, sizeof(Glyph) * aNumGlyphs);
     265           0 :   }
     266             :   virtual ~RecordedFillGlyphs();
     267             : 
     268             :   virtual bool PlayEvent(Translator *aTranslator) const;
     269             : 
     270             :   template<class S> void Record(S &aStream) const;
     271             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     272             : 
     273           0 :   virtual std::string GetName() const { return "FillGlyphs"; }
     274             : private:
     275             :   friend class RecordedEvent;
     276             : 
     277             :   template<class S>
     278             :   MOZ_IMPLICIT RecordedFillGlyphs(S &aStream);
     279             : 
     280             :   ReferencePtr mScaledFont;
     281             :   PatternStorage mPattern;
     282             :   DrawOptions mOptions;
     283             :   Glyph *mGlyphs;
     284             :   uint32_t mNumGlyphs;
     285             : };
     286             : 
     287           0 : class RecordedMask : public RecordedDrawingEvent<RecordedMask> {
     288             : public:
     289           0 :   RecordedMask(DrawTarget *aDT, const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions)
     290           0 :     : RecordedDrawingEvent(MASK, aDT), mOptions(aOptions)
     291             :   {
     292           0 :     StorePattern(mSource, aSource);
     293           0 :     StorePattern(mMask, aMask);
     294           0 :   }
     295             : 
     296             :   virtual bool PlayEvent(Translator *aTranslator) const;
     297             : 
     298             :   template<class S> void Record(S &aStream) const;
     299             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     300             : 
     301           0 :   virtual std::string GetName() const { return "Mask"; }
     302             : private:
     303             :   friend class RecordedEvent;
     304             : 
     305             :   template<class S>
     306             :   MOZ_IMPLICIT RecordedMask(S &aStream);
     307             : 
     308             :   PatternStorage mSource;
     309             :   PatternStorage mMask;
     310             :   DrawOptions mOptions;
     311             : };
     312             : 
     313           0 : class RecordedStroke : public RecordedDrawingEvent<RecordedStroke> {
     314             : public:
     315           0 :   RecordedStroke(DrawTarget *aDT, ReferencePtr aPath, const Pattern &aPattern,
     316             :                      const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
     317           0 :     : RecordedDrawingEvent(STROKE, aDT), mPath(aPath),
     318           0 :       mStrokeOptions(aStrokeOptions), mOptions(aOptions)
     319             :   {
     320           0 :     StorePattern(mPattern, aPattern);
     321           0 :   }
     322             : 
     323             :   virtual bool PlayEvent(Translator *aTranslator) const;
     324             : 
     325             :   template<class S> void Record(S &aStream) const;
     326             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     327             : 
     328           0 :   virtual std::string GetName() const { return "Stroke"; }
     329             : private:
     330             :   friend class RecordedEvent;
     331             : 
     332             :   template<class S>
     333             :   MOZ_IMPLICIT RecordedStroke(S &aStream);
     334             : 
     335             :   ReferencePtr mPath;
     336             :   PatternStorage mPattern;
     337             :   StrokeOptions mStrokeOptions;
     338             :   DrawOptions mOptions;
     339             : };
     340             : 
     341           0 : class RecordedClearRect : public RecordedDrawingEvent<RecordedClearRect> {
     342             : public:
     343           0 :   RecordedClearRect(DrawTarget *aDT, const Rect &aRect)
     344           0 :     : RecordedDrawingEvent(CLEARRECT, aDT), mRect(aRect)
     345             :   {
     346           0 :   }
     347             : 
     348             :   virtual bool PlayEvent(Translator *aTranslator) const;
     349             : 
     350             :   template<class S> void Record(S &aStream) const;
     351             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     352             : 
     353           0 :   virtual std::string GetName() const { return "ClearRect"; }
     354             : private:
     355             :   friend class RecordedEvent;
     356             : 
     357             :   template<class S>
     358             :   MOZ_IMPLICIT RecordedClearRect(S &aStream);
     359             : 
     360             :   Rect mRect;
     361             : };
     362             : 
     363           0 : class RecordedCopySurface : public RecordedDrawingEvent<RecordedCopySurface> {
     364             : public:
     365           0 :   RecordedCopySurface(DrawTarget *aDT, ReferencePtr aSourceSurface,
     366             :                       const IntRect &aSourceRect, const IntPoint &aDest)
     367           0 :     : RecordedDrawingEvent(COPYSURFACE, aDT), mSourceSurface(aSourceSurface),
     368           0 :           mSourceRect(aSourceRect), mDest(aDest)
     369             :   {
     370           0 :   }
     371             : 
     372             :   virtual bool PlayEvent(Translator *aTranslator) const;
     373             : 
     374             :   template<class S> void Record(S &aStream) const;
     375             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     376             : 
     377           0 :   virtual std::string GetName() const { return "CopySurface"; }
     378             : private:
     379             :   friend class RecordedEvent;
     380             : 
     381             :   template<class S>
     382             :   MOZ_IMPLICIT RecordedCopySurface(S &aStream);
     383             : 
     384             :   ReferencePtr mSourceSurface;
     385             :   IntRect mSourceRect;
     386             :   IntPoint mDest;
     387             : };
     388             : 
     389           0 : class RecordedPushClip : public RecordedDrawingEvent<RecordedPushClip> {
     390             : public:
     391           0 :   RecordedPushClip(DrawTarget *aDT, ReferencePtr aPath)
     392           0 :     : RecordedDrawingEvent(PUSHCLIP, aDT), mPath(aPath)
     393             :   {
     394           0 :   }
     395             : 
     396             :   virtual bool PlayEvent(Translator *aTranslator) const;
     397             : 
     398             :   template<class S> void Record(S &aStream) const;
     399             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     400             : 
     401           0 :   virtual std::string GetName() const { return "PushClip"; }
     402             : private:
     403             :   friend class RecordedEvent;
     404             : 
     405             :   template<class S>
     406             :   MOZ_IMPLICIT RecordedPushClip(S &aStream);
     407             : 
     408             :   ReferencePtr mPath;
     409             : };
     410             : 
     411           0 : class RecordedPushClipRect : public RecordedDrawingEvent<RecordedPushClipRect> {
     412             : public:
     413           0 :   RecordedPushClipRect(DrawTarget *aDT, const Rect &aRect)
     414           0 :     : RecordedDrawingEvent(PUSHCLIPRECT, aDT), mRect(aRect)
     415             :   {
     416           0 :   }
     417             : 
     418             :   virtual bool PlayEvent(Translator *aTranslator) const;
     419             : 
     420             :   template<class S> void Record(S &aStream) const;
     421             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     422             : 
     423           0 :   virtual std::string GetName() const { return "PushClipRect"; }
     424             : private:
     425             :   friend class RecordedEvent;
     426             : 
     427             :   template<class S>
     428             :   MOZ_IMPLICIT RecordedPushClipRect(S &aStream);
     429             : 
     430             :   Rect mRect;
     431             : };
     432             : 
     433           0 : class RecordedPopClip : public RecordedDrawingEvent<RecordedPopClip> {
     434             : public:
     435           0 :   MOZ_IMPLICIT RecordedPopClip(DrawTarget *aDT)
     436           0 :     : RecordedDrawingEvent(POPCLIP, aDT)
     437           0 :   {}
     438             : 
     439             :   virtual bool PlayEvent(Translator *aTranslator) const;
     440             : 
     441             :   template<class S> void Record(S &aStream) const;
     442             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     443             : 
     444           0 :   virtual std::string GetName() const { return "PopClip"; }
     445             : private:
     446             :   friend class RecordedEvent;
     447             : 
     448             :   template<class S>
     449             :   MOZ_IMPLICIT RecordedPopClip(S &aStream);
     450             : };
     451             : 
     452           0 : class RecordedPushLayer : public RecordedDrawingEvent<RecordedPushLayer> {
     453             : public:
     454           0 :   RecordedPushLayer(DrawTarget* aDT, bool aOpaque, Float aOpacity,
     455             :                     SourceSurface* aMask, const Matrix& aMaskTransform,
     456             :                     const IntRect& aBounds, bool aCopyBackground)
     457           0 :     : RecordedDrawingEvent(PUSHLAYER, aDT), mOpaque(aOpaque)
     458             :     , mOpacity(aOpacity), mMask(aMask), mMaskTransform(aMaskTransform)
     459           0 :     , mBounds(aBounds), mCopyBackground(aCopyBackground)
     460             :   {
     461           0 :   }
     462             : 
     463             :   virtual bool PlayEvent(Translator *aTranslator) const;
     464             : 
     465             :   template<class S> void Record(S &aStream) const;
     466             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     467             : 
     468           0 :   virtual std::string GetName() const { return "PushLayer"; }
     469             : private:
     470             :   friend class RecordedEvent;
     471             : 
     472             :   template<class S>
     473             :   MOZ_IMPLICIT RecordedPushLayer(S &aStream);
     474             : 
     475             :   bool mOpaque;
     476             :   Float mOpacity;
     477             :   ReferencePtr mMask;
     478             :   Matrix mMaskTransform;
     479             :   IntRect mBounds;
     480             :   bool mCopyBackground;
     481             : };
     482             : 
     483           0 : class RecordedPopLayer : public RecordedDrawingEvent<RecordedPopLayer> {
     484             : public:
     485           0 :   MOZ_IMPLICIT RecordedPopLayer(DrawTarget* aDT)
     486           0 :     : RecordedDrawingEvent(POPLAYER, aDT)
     487             :   {
     488           0 :   }
     489             : 
     490             :   virtual bool PlayEvent(Translator *aTranslator) const;
     491             : 
     492             :   template<class S> void Record(S &aStream) const;
     493             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     494             : 
     495           0 :   virtual std::string GetName() const { return "PopLayer"; }
     496             : private:
     497             :   friend class RecordedEvent;
     498             : 
     499             :   template<class S>
     500             :   MOZ_IMPLICIT RecordedPopLayer(S &aStream);
     501             : };
     502             : 
     503           0 : class RecordedSetTransform : public RecordedDrawingEvent<RecordedSetTransform> {
     504             : public:
     505           0 :   RecordedSetTransform(DrawTarget *aDT, const Matrix &aTransform)
     506           0 :     : RecordedDrawingEvent(SETTRANSFORM, aDT), mTransform(aTransform)
     507             :   {
     508           0 :   }
     509             : 
     510             :   virtual bool PlayEvent(Translator *aTranslator) const;
     511             : 
     512             :   template<class S> void Record(S &aStream) const;
     513             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     514             :   
     515           0 :   virtual std::string GetName() const { return "SetTransform"; }
     516             : 
     517             :   Matrix mTransform;
     518             : private:
     519             :   friend class RecordedEvent;
     520             : 
     521             :    template<class S>
     522             :   MOZ_IMPLICIT RecordedSetTransform(S &aStream);
     523             : };
     524             : 
     525           0 : class RecordedDrawSurface : public RecordedDrawingEvent<RecordedDrawSurface> {
     526             : public:
     527           0 :   RecordedDrawSurface(DrawTarget *aDT, ReferencePtr aRefSource, const Rect &aDest,
     528             :                       const Rect &aSource, const DrawSurfaceOptions &aDSOptions,
     529             :                       const DrawOptions &aOptions)
     530           0 :     : RecordedDrawingEvent(DRAWSURFACE, aDT), mRefSource(aRefSource), mDest(aDest)
     531           0 :     , mSource(aSource), mDSOptions(aDSOptions), mOptions(aOptions)
     532             :   {
     533           0 :   }
     534             : 
     535             :   virtual bool PlayEvent(Translator *aTranslator) const;
     536             : 
     537             :   template<class S> void Record(S &aStream) const;
     538             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     539             :   
     540           0 :   virtual std::string GetName() const { return "DrawSurface"; }
     541             : private:
     542             :   friend class RecordedEvent;
     543             : 
     544             :    template<class S>
     545             :   MOZ_IMPLICIT RecordedDrawSurface(S &aStream);
     546             : 
     547             :   ReferencePtr mRefSource;
     548             :   Rect mDest;
     549             :   Rect mSource;
     550             :   DrawSurfaceOptions mDSOptions;
     551             :   DrawOptions mOptions;
     552             : };
     553             : 
     554           0 : class RecordedDrawSurfaceWithShadow : public RecordedDrawingEvent<RecordedDrawSurfaceWithShadow> {
     555             : public:
     556           0 :   RecordedDrawSurfaceWithShadow(DrawTarget *aDT, ReferencePtr aRefSource, const Point &aDest,
     557             :                                 const Color &aColor, const Point &aOffset,
     558             :                                 Float aSigma, CompositionOp aOp)
     559           0 :     : RecordedDrawingEvent(DRAWSURFACEWITHSHADOW, aDT), mRefSource(aRefSource), mDest(aDest)
     560           0 :     , mColor(aColor), mOffset(aOffset), mSigma(aSigma), mOp(aOp)
     561             :   {
     562           0 :   }
     563             : 
     564             :   virtual bool PlayEvent(Translator *aTranslator) const;
     565             : 
     566             :   template<class S> void Record(S &aStream) const;
     567             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     568             :   
     569           0 :   virtual std::string GetName() const { return "DrawSurfaceWithShadow"; }
     570             : private:
     571             :   friend class RecordedEvent;
     572             : 
     573             :   template<class S>
     574             :   MOZ_IMPLICIT RecordedDrawSurfaceWithShadow(S &aStream);
     575             : 
     576             :   ReferencePtr mRefSource;
     577             :   Point mDest;
     578             :   Color mColor;
     579             :   Point mOffset;
     580             :   Float mSigma;
     581             :   CompositionOp mOp;
     582             : };
     583             : 
     584           0 : class RecordedDrawFilter : public RecordedDrawingEvent<RecordedDrawFilter> {
     585             : public:
     586           0 :   RecordedDrawFilter(DrawTarget *aDT, ReferencePtr aNode,
     587             :                      const Rect &aSourceRect,
     588             :                      const Point &aDestPoint,
     589             :                      const DrawOptions &aOptions)
     590           0 :     : RecordedDrawingEvent(DRAWFILTER, aDT), mNode(aNode), mSourceRect(aSourceRect)
     591           0 :     , mDestPoint(aDestPoint), mOptions(aOptions)
     592             :   {
     593           0 :   }
     594             : 
     595             :   virtual bool PlayEvent(Translator *aTranslator) const;
     596             : 
     597             :   template<class S> void Record(S &aStream) const;
     598             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     599             : 
     600           0 :   virtual std::string GetName() const { return "DrawFilter"; }
     601             : private:
     602             :   friend class RecordedEvent;
     603             : 
     604             :   template<class S>
     605             :   MOZ_IMPLICIT RecordedDrawFilter(S &aStream);
     606             : 
     607             :   ReferencePtr mNode;
     608             :   Rect mSourceRect;
     609             :   Point mDestPoint;
     610             :   DrawOptions mOptions;
     611             : };
     612             : 
     613             : class RecordedPathCreation : public RecordedEventDerived<RecordedPathCreation> {
     614             : public:
     615             :   MOZ_IMPLICIT RecordedPathCreation(PathRecording *aPath);
     616             :   ~RecordedPathCreation();
     617             :   
     618             :   virtual bool PlayEvent(Translator *aTranslator) const;
     619             : 
     620             :   template<class S> void Record(S &aStream) const;
     621             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     622             :   
     623           0 :   virtual std::string GetName() const { return "Path Creation"; }
     624           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     625             : private:
     626             :   friend class RecordedEvent;
     627             : 
     628             :   ReferencePtr mRefPtr;
     629             :   FillRule mFillRule;
     630             :   std::vector<PathOp> mPathOps;
     631             : 
     632             :   template<class S>
     633             :   MOZ_IMPLICIT RecordedPathCreation(S &aStream);
     634             : };
     635             : 
     636           0 : class RecordedPathDestruction : public RecordedEventDerived<RecordedPathDestruction> {
     637             : public:
     638           0 :   MOZ_IMPLICIT RecordedPathDestruction(PathRecording *aPath)
     639           0 :     : RecordedEventDerived(PATHDESTRUCTION), mRefPtr(aPath)
     640             :   {
     641           0 :   }
     642             :   
     643             :   virtual bool PlayEvent(Translator *aTranslator) const;
     644             : 
     645             :   template<class S> void Record(S &aStream) const;
     646             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     647             :   
     648           0 :   virtual std::string GetName() const { return "Path Destruction"; }
     649           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     650             : private:
     651             :   friend class RecordedEvent;
     652             : 
     653             :   ReferencePtr mRefPtr;
     654             : 
     655             :   template<class S>
     656             :   MOZ_IMPLICIT RecordedPathDestruction(S &aStream);
     657             : };
     658             : 
     659             : class RecordedSourceSurfaceCreation : public RecordedEventDerived<RecordedSourceSurfaceCreation> {
     660             : public:
     661           0 :   RecordedSourceSurfaceCreation(ReferencePtr aRefPtr, uint8_t *aData, int32_t aStride,
     662             :                                 const IntSize &aSize, SurfaceFormat aFormat)
     663           0 :     : RecordedEventDerived(SOURCESURFACECREATION), mRefPtr(aRefPtr), mData(aData)
     664           0 :     , mStride(aStride), mSize(aSize), mFormat(aFormat), mDataOwned(false)
     665             :   {
     666           0 :   }
     667             : 
     668             :   ~RecordedSourceSurfaceCreation();
     669             : 
     670             :   virtual bool PlayEvent(Translator *aTranslator) const;
     671             : 
     672             :   template<class S> void Record(S &aStream) const;
     673             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     674             :   
     675           0 :   virtual std::string GetName() const { return "SourceSurface Creation"; }
     676           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     677             : private:
     678             :   friend class RecordedEvent;
     679             : 
     680             :   ReferencePtr mRefPtr;
     681             :   uint8_t *mData;
     682             :   int32_t mStride;
     683             :   IntSize mSize;
     684             :   SurfaceFormat mFormat;
     685             :   bool mDataOwned;
     686             : 
     687             :   template<class S>
     688             :   MOZ_IMPLICIT RecordedSourceSurfaceCreation(S &aStream);
     689             : };
     690             : 
     691           0 : class RecordedSourceSurfaceDestruction : public RecordedEventDerived<RecordedSourceSurfaceDestruction> {
     692             : public:
     693           0 :   MOZ_IMPLICIT RecordedSourceSurfaceDestruction(ReferencePtr aRefPtr)
     694           0 :     : RecordedEventDerived(SOURCESURFACEDESTRUCTION), mRefPtr(aRefPtr)
     695             :   {
     696           0 :   }
     697             : 
     698             :   virtual bool PlayEvent(Translator *aTranslator) const;
     699             : 
     700             :   template<class S> void Record(S &aStream) const;
     701             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     702             :   
     703           0 :   virtual std::string GetName() const { return "SourceSurface Destruction"; }
     704           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     705             : private:
     706             :   friend class RecordedEvent;
     707             : 
     708             :   ReferencePtr mRefPtr;
     709             : 
     710             :   template<class S>
     711             :   MOZ_IMPLICIT RecordedSourceSurfaceDestruction(S &aStream);
     712             : };
     713             : 
     714             : class RecordedFilterNodeCreation : public RecordedEventDerived<RecordedFilterNodeCreation> {
     715             : public:
     716           0 :   RecordedFilterNodeCreation(ReferencePtr aRefPtr, FilterType aType)
     717           0 :     : RecordedEventDerived(FILTERNODECREATION), mRefPtr(aRefPtr), mType(aType)
     718             :   {
     719           0 :   }
     720             : 
     721             :   ~RecordedFilterNodeCreation();
     722             : 
     723             :   virtual bool PlayEvent(Translator *aTranslator) const;
     724             : 
     725             :   template<class S> void Record(S &aStream) const;
     726             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     727             : 
     728           0 :   virtual std::string GetName() const { return "FilterNode Creation"; }
     729           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     730             : private:
     731             :   friend class RecordedEvent;
     732             : 
     733             :   ReferencePtr mRefPtr;
     734             :   FilterType mType;
     735             : 
     736             :   template<class S>
     737             :   MOZ_IMPLICIT RecordedFilterNodeCreation(S &aStream);
     738             : };
     739             : 
     740           0 : class RecordedFilterNodeDestruction : public RecordedEventDerived<RecordedFilterNodeDestruction> {
     741             : public:
     742           0 :   MOZ_IMPLICIT RecordedFilterNodeDestruction(ReferencePtr aRefPtr)
     743           0 :     : RecordedEventDerived(FILTERNODEDESTRUCTION), mRefPtr(aRefPtr)
     744             :   {
     745           0 :   }
     746             : 
     747             :   virtual bool PlayEvent(Translator *aTranslator) const;
     748             : 
     749             :   template<class S> void Record(S &aStream) const;
     750             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     751             : 
     752           0 :   virtual std::string GetName() const { return "FilterNode Destruction"; }
     753           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     754             : private:
     755             :   friend class RecordedEvent;
     756             : 
     757             :   ReferencePtr mRefPtr;
     758             : 
     759             :   template<class S>
     760             :   MOZ_IMPLICIT RecordedFilterNodeDestruction(S &aStream);
     761             : };
     762             : 
     763             : class RecordedGradientStopsCreation : public RecordedEventDerived<RecordedGradientStopsCreation> {
     764             : public:
     765           0 :   RecordedGradientStopsCreation(ReferencePtr aRefPtr, GradientStop *aStops,
     766             :                                 uint32_t aNumStops, ExtendMode aExtendMode)
     767           0 :     : RecordedEventDerived(GRADIENTSTOPSCREATION), mRefPtr(aRefPtr), mStops(aStops)
     768           0 :     , mNumStops(aNumStops), mExtendMode(aExtendMode), mDataOwned(false)
     769             :   {
     770           0 :   }
     771             : 
     772             :   ~RecordedGradientStopsCreation();
     773             : 
     774             :   virtual bool PlayEvent(Translator *aTranslator) const;
     775             : 
     776             :   template<class S> void Record(S &aStream) const;
     777             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     778             :   
     779           0 :   virtual std::string GetName() const { return "GradientStops Creation"; }
     780           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     781             : private:
     782             :   friend class RecordedEvent;
     783             : 
     784             :   ReferencePtr mRefPtr;
     785             :   GradientStop *mStops;
     786             :   uint32_t mNumStops;
     787             :   ExtendMode mExtendMode;
     788             :   bool mDataOwned;
     789             : 
     790             :   template<class S>
     791             :   MOZ_IMPLICIT RecordedGradientStopsCreation(S &aStream);
     792             : };
     793             : 
     794           0 : class RecordedGradientStopsDestruction : public RecordedEventDerived<RecordedGradientStopsDestruction> {
     795             : public:
     796           0 :   MOZ_IMPLICIT RecordedGradientStopsDestruction(ReferencePtr aRefPtr)
     797           0 :     : RecordedEventDerived(GRADIENTSTOPSDESTRUCTION), mRefPtr(aRefPtr)
     798             :   {
     799           0 :   }
     800             : 
     801             :   virtual bool PlayEvent(Translator *aTranslator) const;
     802             : 
     803             :   template<class S> void Record(S &aStream) const;
     804             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     805             :   
     806           0 :   virtual std::string GetName() const { return "GradientStops Destruction"; }
     807           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     808             : private:
     809             :   friend class RecordedEvent;
     810             : 
     811             :   ReferencePtr mRefPtr;
     812             : 
     813             :   template<class S>
     814             :   MOZ_IMPLICIT RecordedGradientStopsDestruction(S &aStream);
     815             : };
     816             : 
     817           0 : class RecordedSnapshot : public RecordedEventDerived<RecordedSnapshot> {
     818             : public:
     819           0 :   RecordedSnapshot(ReferencePtr aRefPtr, DrawTarget *aDT)
     820           0 :     : RecordedEventDerived(SNAPSHOT), mRefPtr(aRefPtr), mDT(aDT)
     821             :   {
     822           0 :   }
     823             : 
     824             :   virtual bool PlayEvent(Translator *aTranslator) const;
     825             : 
     826             :   template<class S> void Record(S &aStream) const;
     827             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     828             :   
     829           0 :   virtual std::string GetName() const { return "Snapshot"; }
     830           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     831             : private:
     832             :   friend class RecordedEvent;
     833             : 
     834             :   ReferencePtr mRefPtr;
     835             :   ReferencePtr mDT;
     836             : 
     837             :   template<class S>
     838             :   MOZ_IMPLICIT RecordedSnapshot(S &aStream);
     839             : };
     840             : 
     841           0 : class RecordedIntoLuminanceSource : public RecordedEventDerived<RecordedIntoLuminanceSource> {
     842             : public:
     843           0 :   RecordedIntoLuminanceSource(ReferencePtr aRefPtr, DrawTarget *aDT,
     844             :                               LuminanceType aLuminanceType, float aOpacity)
     845           0 :     : RecordedEventDerived(SNAPSHOT), mRefPtr(aRefPtr), mDT(aDT),
     846           0 :       mLuminanceType(aLuminanceType), mOpacity(aOpacity)
     847             :   {
     848           0 :   }
     849             : 
     850             :   virtual bool PlayEvent(Translator *aTranslator) const;
     851             : 
     852             :   template<class S> void Record(S &aStream) const;
     853             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     854             : 
     855           0 :   virtual std::string GetName() const { return "IntoLuminanceSource"; }
     856           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     857             : private:
     858             :   friend class RecordedEvent;
     859             : 
     860             :   ReferencePtr mRefPtr;
     861             :   ReferencePtr mDT;
     862             :   LuminanceType mLuminanceType;
     863             :   float mOpacity;
     864             : 
     865             :   template<class S>
     866             :   MOZ_IMPLICIT RecordedIntoLuminanceSource(S &aStream);
     867             : };
     868             : 
     869             : class RecordedFontData : public RecordedEventDerived<RecordedFontData> {
     870             : public:
     871             : 
     872           0 :   static void FontDataProc(const uint8_t *aData, uint32_t aSize,
     873             :                            uint32_t aIndex, void* aBaton)
     874             :   {
     875           0 :     auto recordedFontData = static_cast<RecordedFontData*>(aBaton);
     876           0 :     recordedFontData->SetFontData(aData, aSize, aIndex);
     877           0 :   }
     878             : 
     879           0 :   explicit RecordedFontData(UnscaledFont *aUnscaledFont)
     880           0 :     : RecordedEventDerived(FONTDATA)
     881           0 :     , mType(aUnscaledFont->GetType())
     882           0 :     , mData(nullptr)
     883             :   {
     884           0 :     mGetFontFileDataSucceeded = aUnscaledFont->GetFontFileData(&FontDataProc, this);
     885           0 :   }
     886             : 
     887             :   ~RecordedFontData();
     888             : 
     889             :   bool IsValid() const { return mGetFontFileDataSucceeded; }
     890             : 
     891             :   virtual bool PlayEvent(Translator *aTranslator) const;
     892             : 
     893             :   template<class S> void Record(S &aStream) const;
     894             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     895             : 
     896           0 :   virtual std::string GetName() const { return "Font Data"; }
     897           0 :   virtual ReferencePtr GetObjectRef() const { return nullptr; };
     898             : 
     899             :   void SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex);
     900             : 
     901             :   bool GetFontDetails(RecordedFontDetails& fontDetails);
     902             : 
     903             : private:
     904             :   friend class RecordedEvent;
     905             : 
     906             :   FontType mType;
     907             :   uint8_t* mData;
     908             :   RecordedFontDetails mFontDetails;
     909             : 
     910             :   bool mGetFontFileDataSucceeded;
     911             : 
     912             :   template<class S>
     913             :   MOZ_IMPLICIT RecordedFontData(S &aStream);
     914             : };
     915             : 
     916             : class RecordedFontDescriptor : public RecordedEventDerived<RecordedFontDescriptor> {
     917             : public:
     918             : 
     919           0 :   static void FontDescCb(const uint8_t* aData, uint32_t aSize,
     920             :                          void* aBaton)
     921             :   {
     922           0 :     auto recordedFontDesc = static_cast<RecordedFontDescriptor*>(aBaton);
     923           0 :     recordedFontDesc->SetFontDescriptor(aData, aSize);
     924           0 :   }
     925             : 
     926           0 :   explicit RecordedFontDescriptor(UnscaledFont* aUnscaledFont)
     927           0 :     : RecordedEventDerived(FONTDESC)
     928           0 :     , mType(aUnscaledFont->GetType())
     929           0 :     , mRefPtr(aUnscaledFont)
     930             :   {
     931           0 :     mHasDesc = aUnscaledFont->GetFontDescriptor(FontDescCb, this);
     932           0 :   }
     933             : 
     934             :   ~RecordedFontDescriptor();
     935             : 
     936           0 :   bool IsValid() const { return mHasDesc; }
     937             : 
     938             :   virtual bool PlayEvent(Translator *aTranslator) const;
     939             : 
     940             :   template<class S> void Record(S &aStream) const;
     941             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     942             : 
     943           0 :   virtual std::string GetName() const { return "Font Desc"; }
     944           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     945             : 
     946             : private:
     947             :   friend class RecordedEvent;
     948             : 
     949             :   void SetFontDescriptor(const uint8_t* aData, uint32_t aSize);
     950             : 
     951             :   bool mHasDesc;
     952             : 
     953             :   FontType mType;
     954             :   std::vector<uint8_t> mData;
     955             :   ReferencePtr mRefPtr;
     956             : 
     957             :   template<class S>
     958             :   MOZ_IMPLICIT RecordedFontDescriptor(S &aStream);
     959             : };
     960             : 
     961           0 : class RecordedUnscaledFontCreation : public RecordedEventDerived<RecordedUnscaledFontCreation> {
     962             : public:
     963           0 :   static void FontInstanceDataProc(const uint8_t* aData, uint32_t aSize, void* aBaton)
     964             :   {
     965           0 :     auto recordedUnscaledFontCreation = static_cast<RecordedUnscaledFontCreation*>(aBaton);
     966           0 :     recordedUnscaledFontCreation->SetFontInstanceData(aData, aSize);
     967           0 :   }
     968             : 
     969           0 :   RecordedUnscaledFontCreation(UnscaledFont* aUnscaledFont,
     970             :                                RecordedFontDetails aFontDetails)
     971           0 :     : RecordedEventDerived(UNSCALEDFONTCREATION)
     972             :     , mRefPtr(aUnscaledFont)
     973           0 :     , mFontDataKey(aFontDetails.fontDataKey)
     974           0 :     , mIndex(aFontDetails.index)
     975             :   {
     976           0 :     aUnscaledFont->GetFontInstanceData(FontInstanceDataProc, this);
     977           0 :   }
     978             : 
     979             :   virtual bool PlayEvent(Translator *aTranslator) const;
     980             : 
     981             :   template<class S> void Record(S &aStream) const;
     982             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
     983             : 
     984           0 :   virtual std::string GetName() const { return "UnscaledFont Creation"; }
     985           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
     986             : 
     987             :   void SetFontInstanceData(const uint8_t *aData, uint32_t aSize);
     988             : 
     989             : private:
     990             :   friend class RecordedEvent;
     991             : 
     992             :   ReferencePtr mRefPtr;
     993             :   uint64_t mFontDataKey;
     994             :   uint32_t mIndex;
     995             :   std::vector<uint8_t> mInstanceData;
     996             : 
     997             :   template<class S>
     998             :   MOZ_IMPLICIT RecordedUnscaledFontCreation(S &aStream);
     999             : };
    1000             : 
    1001           0 : class RecordedUnscaledFontDestruction : public RecordedEventDerived<RecordedUnscaledFontDestruction> {
    1002             : public:
    1003             :   MOZ_IMPLICIT RecordedUnscaledFontDestruction(ReferencePtr aRefPtr)
    1004             :     : RecordedEventDerived(UNSCALEDFONTDESTRUCTION), mRefPtr(aRefPtr)
    1005             :   {}
    1006             : 
    1007             :   virtual bool PlayEvent(Translator *aTranslator) const;
    1008             :   template<class S>
    1009             :   void Record(S &aStream) const;
    1010             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
    1011             : 
    1012           0 :   virtual std::string GetName() const { return "UnscaledFont Destruction"; }
    1013           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
    1014             : private:
    1015             :   friend class RecordedEvent;
    1016             : 
    1017             :   ReferencePtr mRefPtr;
    1018             : 
    1019             :   template<class S>
    1020             :   MOZ_IMPLICIT RecordedUnscaledFontDestruction(S &aStream);
    1021             : };
    1022             : 
    1023           0 : class RecordedScaledFontCreation : public RecordedEventDerived<RecordedScaledFontCreation> {
    1024             : public:
    1025             : 
    1026           0 :   static void FontInstanceDataProc(const uint8_t* aData, uint32_t aSize, void* aBaton)
    1027             :   {
    1028           0 :     auto recordedScaledFontCreation = static_cast<RecordedScaledFontCreation*>(aBaton);
    1029           0 :     recordedScaledFontCreation->SetFontInstanceData(aData, aSize);
    1030           0 :   }
    1031             : 
    1032           0 :   RecordedScaledFontCreation(ScaledFont* aScaledFont,
    1033             :                              UnscaledFont* aUnscaledFont)
    1034           0 :     : RecordedEventDerived(SCALEDFONTCREATION)
    1035             :     , mRefPtr(aScaledFont)
    1036             :     , mUnscaledFont(aUnscaledFont)
    1037           0 :     , mGlyphSize(aScaledFont->GetSize())
    1038             :   {
    1039           0 :     aScaledFont->GetFontInstanceData(FontInstanceDataProc, this);
    1040           0 :   }
    1041             : 
    1042             :   virtual bool PlayEvent(Translator *aTranslator) const;
    1043             : 
    1044             :   template<class S> void Record(S &aStream) const;
    1045             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
    1046             :   
    1047           0 :   virtual std::string GetName() const { return "ScaledFont Creation"; }
    1048           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
    1049             : 
    1050             :   void SetFontInstanceData(const uint8_t *aData, uint32_t aSize);
    1051             : 
    1052             : private:
    1053             :   friend class RecordedEvent;
    1054             : 
    1055             :   ReferencePtr mRefPtr;
    1056             :   ReferencePtr mUnscaledFont;
    1057             :   Float mGlyphSize;
    1058             :   std::vector<uint8_t> mInstanceData;
    1059             : 
    1060             :   template<class S>
    1061             :   MOZ_IMPLICIT RecordedScaledFontCreation(S &aStream);
    1062             : };
    1063             : 
    1064           0 : class RecordedScaledFontDestruction : public RecordedEventDerived<RecordedScaledFontDestruction> {
    1065             : public:
    1066           0 :   MOZ_IMPLICIT RecordedScaledFontDestruction(ReferencePtr aRefPtr)
    1067           0 :     : RecordedEventDerived(SCALEDFONTDESTRUCTION), mRefPtr(aRefPtr)
    1068             :   {
    1069           0 :   }
    1070             : 
    1071             :   virtual bool PlayEvent(Translator *aTranslator) const;
    1072             : 
    1073             :   template<class S>
    1074             :   void Record(S &aStream) const;
    1075             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
    1076             : 
    1077           0 :   virtual std::string GetName() const { return "ScaledFont Destruction"; }
    1078           0 :   virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
    1079             : private:
    1080             :   friend class RecordedEvent;
    1081             : 
    1082             :   ReferencePtr mRefPtr;
    1083             : 
    1084             :   template<class S>
    1085             :   MOZ_IMPLICIT RecordedScaledFontDestruction(S &aStream);
    1086             : };
    1087             : 
    1088           0 : class RecordedMaskSurface : public RecordedDrawingEvent<RecordedMaskSurface> {
    1089             : public:
    1090           0 :   RecordedMaskSurface(DrawTarget *aDT, const Pattern &aPattern, ReferencePtr aRefMask,
    1091             :                       const Point &aOffset, const DrawOptions &aOptions)
    1092           0 :     : RecordedDrawingEvent(MASKSURFACE, aDT), mRefMask(aRefMask), mOffset(aOffset)
    1093           0 :     , mOptions(aOptions)
    1094             :   {
    1095           0 :     StorePattern(mPattern, aPattern);
    1096           0 :   }
    1097             : 
    1098             :   virtual bool PlayEvent(Translator *aTranslator) const;
    1099             : 
    1100             :   template<class S> void Record(S &aStream) const;
    1101             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
    1102             :   
    1103           0 :   virtual std::string GetName() const { return "MaskSurface"; }
    1104             : private:
    1105             :   friend class RecordedEvent;
    1106             : 
    1107             :   template<class S>
    1108             :   MOZ_IMPLICIT RecordedMaskSurface(S &aStream);
    1109             : 
    1110             :   PatternStorage mPattern;
    1111             :   ReferencePtr mRefMask;
    1112             :   Point mOffset;
    1113             :   DrawOptions mOptions;
    1114             : };
    1115             : 
    1116           0 : class RecordedFilterNodeSetAttribute : public RecordedEventDerived<RecordedFilterNodeSetAttribute>
    1117             : {
    1118             : public:
    1119             :   enum ArgType {
    1120             :     ARGTYPE_UINT32,
    1121             :     ARGTYPE_BOOL,
    1122             :     ARGTYPE_FLOAT,
    1123             :     ARGTYPE_SIZE,
    1124             :     ARGTYPE_INTSIZE,
    1125             :     ARGTYPE_INTPOINT,
    1126             :     ARGTYPE_RECT,
    1127             :     ARGTYPE_INTRECT,
    1128             :     ARGTYPE_POINT,
    1129             :     ARGTYPE_MATRIX,
    1130             :     ARGTYPE_MATRIX5X4,
    1131             :     ARGTYPE_POINT3D,
    1132             :     ARGTYPE_COLOR,
    1133             :     ARGTYPE_FLOAT_ARRAY
    1134             :   };
    1135             : 
    1136             :   template<typename T>
    1137           0 :   RecordedFilterNodeSetAttribute(FilterNode *aNode, uint32_t aIndex, T aArgument, ArgType aArgType)
    1138           0 :     : RecordedEventDerived(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(aArgType)
    1139             :   {
    1140           0 :     mPayload.resize(sizeof(T));
    1141           0 :     memcpy(&mPayload.front(), &aArgument, sizeof(T));
    1142           0 :   }
    1143             : 
    1144           0 :   RecordedFilterNodeSetAttribute(FilterNode *aNode, uint32_t aIndex, const Float *aFloat, uint32_t aSize)
    1145           0 :     : RecordedEventDerived(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(ARGTYPE_FLOAT_ARRAY)
    1146             :   {
    1147           0 :     mPayload.resize(sizeof(Float) * aSize);
    1148           0 :     memcpy(&mPayload.front(), aFloat, sizeof(Float) * aSize);
    1149           0 :   }
    1150             : 
    1151             :   virtual bool PlayEvent(Translator *aTranslator) const;
    1152             :   template<class S> void Record(S &aStream) const;
    1153             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
    1154             : 
    1155           0 :   virtual std::string GetName() const { return "SetAttribute"; }
    1156             : 
    1157           0 :   virtual ReferencePtr GetObjectRef() const { return mNode; }
    1158             : 
    1159             : private:
    1160             :   friend class RecordedEvent;
    1161             : 
    1162             :   ReferencePtr mNode;
    1163             : 
    1164             :   uint32_t mIndex;
    1165             :   ArgType mArgType;
    1166             :   std::vector<uint8_t> mPayload;
    1167             : 
    1168             :   template<class S>
    1169             :   MOZ_IMPLICIT RecordedFilterNodeSetAttribute(S &aStream);
    1170             : };
    1171             : 
    1172           0 : class RecordedFilterNodeSetInput : public RecordedEventDerived<RecordedFilterNodeSetInput>
    1173             : {
    1174             : public:
    1175           0 :   RecordedFilterNodeSetInput(FilterNode* aNode, uint32_t aIndex, FilterNode* aInputNode)
    1176           0 :     : RecordedEventDerived(FILTERNODESETINPUT), mNode(aNode), mIndex(aIndex)
    1177           0 :     , mInputFilter(aInputNode), mInputSurface(nullptr)
    1178             :   {
    1179           0 :   }
    1180             : 
    1181           0 :   RecordedFilterNodeSetInput(FilterNode *aNode, uint32_t aIndex, SourceSurface *aInputSurface)
    1182           0 :     : RecordedEventDerived(FILTERNODESETINPUT), mNode(aNode), mIndex(aIndex)
    1183           0 :     , mInputFilter(nullptr), mInputSurface(aInputSurface)
    1184             :   {
    1185           0 :   }
    1186             : 
    1187             :   virtual bool PlayEvent(Translator *aTranslator) const;
    1188             :   template<class S> void Record(S &aStream) const;
    1189             :   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
    1190             : 
    1191           0 :   virtual std::string GetName() const { return "SetInput"; }
    1192             : 
    1193           0 :   virtual ReferencePtr GetObjectRef() const { return mNode; }
    1194             : 
    1195             : private:
    1196             :   friend class RecordedEvent;
    1197             : 
    1198             :   ReferencePtr mNode;
    1199             :   uint32_t mIndex;
    1200             :   ReferencePtr mInputFilter;
    1201             :   ReferencePtr mInputSurface;
    1202             : 
    1203             :   template<class S>
    1204             :   MOZ_IMPLICIT RecordedFilterNodeSetInput(S &aStream);
    1205             : };
    1206             : 
    1207             : 
    1208             : using namespace std;
    1209             : 
    1210           0 : static std::string NameFromBackend(BackendType aType)
    1211             : {
    1212           0 :   switch (aType) {
    1213             :   case BackendType::NONE:
    1214           0 :     return "None";
    1215             :   case BackendType::DIRECT2D:
    1216           0 :     return "Direct2D";
    1217             :   default:
    1218           0 :     return "Unknown";
    1219             :   }
    1220             : }
    1221             : 
    1222             : template<class S>
    1223             : void
    1224           0 : RecordedEvent::RecordPatternData(S &aStream, const PatternStorage &aPattern) const
    1225             : {
    1226           0 :   WriteElement(aStream, aPattern.mType);
    1227             : 
    1228           0 :   switch (aPattern.mType) {
    1229             :   case PatternType::COLOR:
    1230             :     {
    1231           0 :       WriteElement(aStream, *reinterpret_cast<const ColorPatternStorage*>(&aPattern.mStorage));
    1232           0 :       return;
    1233             :     }
    1234             :   case PatternType::LINEAR_GRADIENT:
    1235             :     {
    1236           0 :       WriteElement(aStream, *reinterpret_cast<const LinearGradientPatternStorage*>(&aPattern.mStorage));
    1237           0 :       return;
    1238             :     }
    1239             :   case PatternType::RADIAL_GRADIENT:
    1240             :     {
    1241           0 :       WriteElement(aStream, *reinterpret_cast<const RadialGradientPatternStorage*>(&aPattern.mStorage));
    1242           0 :       return;
    1243             :     }
    1244             :   case PatternType::SURFACE:
    1245             :     {
    1246           0 :       WriteElement(aStream, *reinterpret_cast<const SurfacePatternStorage*>(&aPattern.mStorage));
    1247           0 :       return;
    1248             :     }
    1249             :   default:
    1250           0 :     return;
    1251             :   }
    1252             : }
    1253             : 
    1254             : template<class S>
    1255             : void
    1256           0 : RecordedEvent::ReadPatternData(S &aStream, PatternStorage &aPattern) const
    1257             : {
    1258           0 :   ReadElement(aStream, aPattern.mType);
    1259             : 
    1260           0 :   switch (aPattern.mType) {
    1261             :   case PatternType::COLOR:
    1262             :     {
    1263           0 :       ReadElement(aStream, *reinterpret_cast<ColorPatternStorage*>(&aPattern.mStorage));
    1264           0 :       return;
    1265             :     }
    1266             :   case PatternType::LINEAR_GRADIENT:
    1267             :     {
    1268           0 :       ReadElement(aStream, *reinterpret_cast<LinearGradientPatternStorage*>(&aPattern.mStorage));
    1269           0 :       return;
    1270             :     }
    1271             :   case PatternType::RADIAL_GRADIENT:
    1272             :     {
    1273           0 :       ReadElement(aStream, *reinterpret_cast<RadialGradientPatternStorage*>(&aPattern.mStorage));
    1274           0 :       return;
    1275             :     }
    1276             :   case PatternType::SURFACE:
    1277             :     {
    1278           0 :       ReadElement(aStream, *reinterpret_cast<SurfacePatternStorage*>(&aPattern.mStorage));
    1279           0 :       return;
    1280             :     }
    1281             :   default:
    1282           0 :     return;
    1283             :   }
    1284             : }
    1285             : 
    1286             : inline void
    1287           0 : RecordedEvent::StorePattern(PatternStorage &aDestination, const Pattern &aSource) const
    1288             : {
    1289           0 :   aDestination.mType = aSource.GetType();
    1290             :   
    1291           0 :   switch (aSource.GetType()) {
    1292             :   case PatternType::COLOR:
    1293             :     {
    1294           0 :       reinterpret_cast<ColorPatternStorage*>(&aDestination.mStorage)->mColor =
    1295             :         static_cast<const ColorPattern*>(&aSource)->mColor;
    1296           0 :       return;
    1297             :     }
    1298             :   case PatternType::LINEAR_GRADIENT:
    1299             :     {
    1300             :       LinearGradientPatternStorage *store =
    1301           0 :         reinterpret_cast<LinearGradientPatternStorage*>(&aDestination.mStorage);
    1302             :       const LinearGradientPattern *pat =
    1303           0 :         static_cast<const LinearGradientPattern*>(&aSource);
    1304           0 :       store->mBegin = pat->mBegin;
    1305           0 :       store->mEnd = pat->mEnd;
    1306           0 :       store->mMatrix = pat->mMatrix;
    1307           0 :       store->mStops = pat->mStops.get();
    1308           0 :       return;
    1309             :     }
    1310             :   case PatternType::RADIAL_GRADIENT:
    1311             :     {
    1312             :       RadialGradientPatternStorage *store =
    1313           0 :         reinterpret_cast<RadialGradientPatternStorage*>(&aDestination.mStorage);
    1314             :       const RadialGradientPattern *pat =
    1315           0 :         static_cast<const RadialGradientPattern*>(&aSource);
    1316           0 :       store->mCenter1 = pat->mCenter1;
    1317           0 :       store->mCenter2 = pat->mCenter2;
    1318           0 :       store->mRadius1 = pat->mRadius1;
    1319           0 :       store->mRadius2 = pat->mRadius2;
    1320           0 :       store->mMatrix = pat->mMatrix;
    1321           0 :       store->mStops = pat->mStops.get();
    1322           0 :       return;
    1323             :     }
    1324             :   case PatternType::SURFACE:
    1325             :     {
    1326             :       SurfacePatternStorage *store =
    1327           0 :         reinterpret_cast<SurfacePatternStorage*>(&aDestination.mStorage);
    1328             :       const SurfacePattern *pat =
    1329           0 :         static_cast<const SurfacePattern*>(&aSource);
    1330           0 :       store->mExtend = pat->mExtendMode;
    1331           0 :       store->mSamplingFilter = pat->mSamplingFilter;
    1332           0 :       store->mMatrix = pat->mMatrix;
    1333           0 :       store->mSurface = pat->mSurface;
    1334           0 :       store->mSamplingRect = pat->mSamplingRect;
    1335           0 :       return;
    1336             :     }
    1337             :   }
    1338             : }
    1339             : 
    1340             : template<class S>
    1341             : void
    1342           0 : RecordedEvent::RecordStrokeOptions(S &aStream, const StrokeOptions &aStrokeOptions) const
    1343             : {
    1344           0 :   JoinStyle joinStyle = aStrokeOptions.mLineJoin;
    1345           0 :   CapStyle capStyle = aStrokeOptions.mLineCap;
    1346             : 
    1347           0 :   WriteElement(aStream, uint64_t(aStrokeOptions.mDashLength));
    1348           0 :   WriteElement(aStream, aStrokeOptions.mDashOffset);
    1349           0 :   WriteElement(aStream, aStrokeOptions.mLineWidth);
    1350           0 :   WriteElement(aStream, aStrokeOptions.mMiterLimit);
    1351           0 :   WriteElement(aStream, joinStyle);
    1352           0 :   WriteElement(aStream, capStyle);
    1353             : 
    1354           0 :   if (!aStrokeOptions.mDashPattern) {
    1355           0 :     return;
    1356             :   }
    1357             : 
    1358           0 :   aStream.write((char*)aStrokeOptions.mDashPattern, sizeof(Float) * aStrokeOptions.mDashLength);
    1359             : }
    1360             : 
    1361             : template<class S>
    1362             : void
    1363           0 : RecordedEvent::ReadStrokeOptions(S &aStream, StrokeOptions &aStrokeOptions)
    1364             : {
    1365             :   uint64_t dashLength;
    1366             :   JoinStyle joinStyle;
    1367             :   CapStyle capStyle;
    1368             : 
    1369           0 :   ReadElement(aStream, dashLength);
    1370           0 :   ReadElement(aStream, aStrokeOptions.mDashOffset);
    1371           0 :   ReadElement(aStream, aStrokeOptions.mLineWidth);
    1372           0 :   ReadElement(aStream, aStrokeOptions.mMiterLimit);
    1373           0 :   ReadElement(aStream, joinStyle);
    1374           0 :   ReadElement(aStream, capStyle);
    1375             :   // On 32 bit we truncate the value of dashLength.
    1376             :   // See also bug 811850 for history.
    1377           0 :   aStrokeOptions.mDashLength = size_t(dashLength);
    1378           0 :   aStrokeOptions.mLineJoin = joinStyle;
    1379           0 :   aStrokeOptions.mLineCap = capStyle;
    1380             : 
    1381           0 :   if (!aStrokeOptions.mDashLength) {
    1382           0 :     return;
    1383             :   }
    1384             : 
    1385           0 :   mDashPatternStorage.resize(aStrokeOptions.mDashLength);
    1386           0 :   aStrokeOptions.mDashPattern = &mDashPatternStorage.front();
    1387           0 :   aStream.read((char*)aStrokeOptions.mDashPattern, sizeof(Float) * aStrokeOptions.mDashLength);
    1388             : }
    1389             : 
    1390             : inline void
    1391           0 : RecordedEvent::OutputSimplePatternInfo(const PatternStorage &aStorage, std::stringstream &aOutput) const
    1392             : {
    1393           0 :   switch (aStorage.mType) {
    1394             :   case PatternType::COLOR:
    1395             :     {
    1396           0 :       const Color color = reinterpret_cast<const ColorPatternStorage*>(&aStorage.mStorage)->mColor;
    1397           0 :       aOutput << "Color: (" << color.r << ", " << color.g << ", " << color.b << ", " << color.a << ")";
    1398           0 :       return;
    1399             :     }
    1400             :   case PatternType::LINEAR_GRADIENT:
    1401             :     {
    1402             :       const LinearGradientPatternStorage *store =
    1403           0 :         reinterpret_cast<const LinearGradientPatternStorage*>(&aStorage.mStorage);
    1404             : 
    1405           0 :       aOutput << "LinearGradient (" << store->mBegin.x << ", " << store->mBegin.y <<
    1406           0 :         ") - (" << store->mEnd.x << ", " << store->mEnd.y << ") Stops: " << store->mStops;
    1407           0 :       return;
    1408             :     }
    1409             :   case PatternType::RADIAL_GRADIENT:
    1410             :     {
    1411             :       const RadialGradientPatternStorage *store =
    1412           0 :         reinterpret_cast<const RadialGradientPatternStorage*>(&aStorage.mStorage);
    1413           0 :       aOutput << "RadialGradient (Center 1: (" << store->mCenter1.x << ", " <<
    1414           0 :         store->mCenter2.y << ") Radius 2: " << store->mRadius2;
    1415           0 :       return;
    1416             :     }
    1417             :   case PatternType::SURFACE:
    1418             :     {
    1419             :       const SurfacePatternStorage *store =
    1420           0 :         reinterpret_cast<const SurfacePatternStorage*>(&aStorage.mStorage);
    1421           0 :       aOutput << "Surface (0x" << store->mSurface << ")";
    1422           0 :       return;
    1423             :     }
    1424             :   }
    1425             : }
    1426             : 
    1427             : template<class T>
    1428             : template<class S>
    1429           0 : RecordedDrawingEvent<T>::RecordedDrawingEvent(RecordedEvent::EventType aType, S &aStream)
    1430           0 :   : RecordedEventDerived<T>(aType)
    1431             : {
    1432           0 :   ReadElement(aStream, mDT);
    1433           0 : }
    1434             : 
    1435             : template<class T>
    1436             : template<class S>
    1437             : void
    1438           0 : RecordedDrawingEvent<T>::Record(S &aStream) const
    1439             : {
    1440           0 :   WriteElement(aStream, mDT);
    1441           0 : }
    1442             : 
    1443             : template<class T>
    1444             : ReferencePtr
    1445           0 : RecordedDrawingEvent<T>::GetObjectRef() const
    1446             : {
    1447           0 :   return mDT;
    1448             : }
    1449             : 
    1450             : inline bool
    1451           0 : RecordedDrawTargetCreation::PlayEvent(Translator *aTranslator) const
    1452             : {
    1453             :   RefPtr<DrawTarget> newDT =
    1454           0 :     aTranslator->CreateDrawTarget(mRefPtr, mSize, mFormat);
    1455             : 
    1456             :   // If we couldn't create a DrawTarget this will probably cause us to crash
    1457             :   // with nullptr later in the playback, so return false to abort.
    1458           0 :   if (!newDT) {
    1459           0 :     return false;
    1460             :   }
    1461             : 
    1462           0 :   if (mHasExistingData) {
    1463           0 :     Rect dataRect(0, 0, mExistingData->GetSize().width, mExistingData->GetSize().height);
    1464           0 :     newDT->DrawSurface(mExistingData, dataRect, dataRect);
    1465             :   }
    1466             : 
    1467           0 :   return true;
    1468             : }
    1469             : 
    1470             : template<class S>
    1471             : void
    1472           0 : RecordedDrawTargetCreation::Record(S &aStream) const
    1473             : {
    1474           0 :   WriteElement(aStream, mRefPtr);
    1475           0 :   WriteElement(aStream, mBackendType);
    1476           0 :   WriteElement(aStream, mSize);
    1477           0 :   WriteElement(aStream, mFormat);
    1478           0 :   WriteElement(aStream, mHasExistingData);
    1479             : 
    1480           0 :   if (mHasExistingData) {
    1481           0 :     MOZ_ASSERT(mExistingData);
    1482           0 :     MOZ_ASSERT(mExistingData->GetSize() == mSize);
    1483           0 :     RefPtr<DataSourceSurface> dataSurf = mExistingData->GetDataSurface();
    1484           0 :     for (int y = 0; y < mSize.height; y++) {
    1485           0 :       aStream.write((const char*)dataSurf->GetData() + y * dataSurf->Stride(),
    1486           0 :                     BytesPerPixel(mFormat) * mSize.width);
    1487             :     }
    1488             :   }
    1489           0 : }
    1490             : 
    1491             : template<class S>
    1492           0 : RecordedDrawTargetCreation::RecordedDrawTargetCreation(S &aStream)
    1493             :   : RecordedEventDerived(DRAWTARGETCREATION)
    1494           0 :   , mExistingData(nullptr)
    1495             : {
    1496           0 :   ReadElement(aStream, mRefPtr);
    1497           0 :   ReadElement(aStream, mBackendType);
    1498           0 :   ReadElement(aStream, mSize);
    1499           0 :   ReadElement(aStream, mFormat);
    1500           0 :   ReadElement(aStream, mHasExistingData);
    1501             : 
    1502           0 :   if (mHasExistingData) {
    1503           0 :     RefPtr<DataSourceSurface> dataSurf = Factory::CreateDataSourceSurface(mSize, mFormat);
    1504           0 :     if (!dataSurf) {
    1505           0 :       gfxWarning() << "RecordedDrawTargetCreation had to reset mHasExistingData";
    1506           0 :       mHasExistingData = false;
    1507           0 :       return;
    1508             :     }
    1509             : 
    1510           0 :     for (int y = 0; y < mSize.height; y++) {
    1511           0 :       aStream.read((char*)dataSurf->GetData() + y * dataSurf->Stride(),
    1512           0 :                     BytesPerPixel(mFormat) * mSize.width);
    1513             :     }
    1514           0 :     mExistingData = dataSurf;
    1515             :   }
    1516             : }
    1517             : 
    1518             : inline void
    1519           0 : RecordedDrawTargetCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    1520             : {
    1521           0 :   aStringStream << "[" << mRefPtr << "] DrawTarget Creation (Type: " << NameFromBackend(mBackendType) << ", Size: " << mSize.width << "x" << mSize.height << ")";
    1522           0 : }
    1523             : 
    1524             : 
    1525             : inline bool
    1526           0 : RecordedDrawTargetDestruction::PlayEvent(Translator *aTranslator) const
    1527             : {
    1528           0 :   aTranslator->RemoveDrawTarget(mRefPtr);
    1529           0 :   return true;
    1530             : }
    1531             : 
    1532             : template<class S>
    1533             : void
    1534           0 : RecordedDrawTargetDestruction::Record(S &aStream) const
    1535             : {
    1536           0 :   WriteElement(aStream, mRefPtr);
    1537           0 : }
    1538             : 
    1539             : template<class S>
    1540           0 : RecordedDrawTargetDestruction::RecordedDrawTargetDestruction(S &aStream)
    1541           0 :   : RecordedEventDerived(DRAWTARGETDESTRUCTION)
    1542             : {
    1543           0 :   ReadElement(aStream, mRefPtr);
    1544           0 : }
    1545             : 
    1546             : inline void
    1547           0 : RecordedDrawTargetDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    1548             : {
    1549           0 :   aStringStream << "[" << mRefPtr << "] DrawTarget Destruction";
    1550           0 : }
    1551             : 
    1552             : inline bool
    1553           0 : RecordedCreateSimilarDrawTarget::PlayEvent(Translator *aTranslator) const
    1554             : {
    1555             :   RefPtr<DrawTarget> newDT =
    1556           0 :     aTranslator->GetReferenceDrawTarget()->CreateSimilarDrawTarget(mSize, mFormat);
    1557             : 
    1558             :   // If we couldn't create a DrawTarget this will probably cause us to crash
    1559             :   // with nullptr later in the playback, so return false to abort.
    1560           0 :   if (!newDT) {
    1561           0 :     return false;
    1562             :   }
    1563             : 
    1564           0 :   aTranslator->AddDrawTarget(mRefPtr, newDT);
    1565           0 :   return true;
    1566             : }
    1567             : 
    1568             : template<class S>
    1569             : void
    1570           0 : RecordedCreateSimilarDrawTarget::Record(S &aStream) const
    1571             : {
    1572           0 :   WriteElement(aStream, mRefPtr);
    1573           0 :   WriteElement(aStream, mSize);
    1574           0 :   WriteElement(aStream, mFormat);
    1575           0 : }
    1576             : 
    1577             : template<class S>
    1578           0 : RecordedCreateSimilarDrawTarget::RecordedCreateSimilarDrawTarget(S &aStream)
    1579           0 :   : RecordedEventDerived(CREATESIMILARDRAWTARGET)
    1580             : {
    1581           0 :   ReadElement(aStream, mRefPtr);
    1582           0 :   ReadElement(aStream, mSize);
    1583           0 :   ReadElement(aStream, mFormat);
    1584           0 : }
    1585             : 
    1586             : inline void
    1587           0 : RecordedCreateSimilarDrawTarget::OutputSimpleEventInfo(stringstream &aStringStream) const
    1588             : {
    1589           0 :   aStringStream << "[" << mRefPtr << "] CreateSimilarDrawTarget (Size: " << mSize.width << "x" << mSize.height << ")";
    1590           0 : }
    1591             : 
    1592             : struct GenericPattern
    1593             : {
    1594           0 :   GenericPattern(const PatternStorage &aStorage, Translator *aTranslator)
    1595           0 :     : mPattern(nullptr), mTranslator(aTranslator)
    1596             :   {
    1597           0 :     mStorage = const_cast<PatternStorage*>(&aStorage);
    1598           0 :   }
    1599             : 
    1600           0 :   ~GenericPattern() {
    1601           0 :     if (mPattern) {
    1602           0 :       mPattern->~Pattern();
    1603             :     }
    1604           0 :   }
    1605             : 
    1606           0 :   operator Pattern*()
    1607             :   {
    1608           0 :     switch(mStorage->mType) {
    1609             :     case PatternType::COLOR:
    1610           0 :       return new (mColPat) ColorPattern(reinterpret_cast<ColorPatternStorage*>(&mStorage->mStorage)->mColor);
    1611             :     case PatternType::SURFACE:
    1612             :       {
    1613           0 :         SurfacePatternStorage *storage = reinterpret_cast<SurfacePatternStorage*>(&mStorage->mStorage);
    1614           0 :         mPattern =
    1615           0 :           new (mSurfPat) SurfacePattern(mTranslator->LookupSourceSurface(storage->mSurface),
    1616             :                                         storage->mExtend, storage->mMatrix,
    1617             :                                         storage->mSamplingFilter,
    1618           0 :                                         storage->mSamplingRect);
    1619           0 :         return mPattern;
    1620             :       }
    1621             :     case PatternType::LINEAR_GRADIENT:
    1622             :       {
    1623           0 :         LinearGradientPatternStorage *storage = reinterpret_cast<LinearGradientPatternStorage*>(&mStorage->mStorage);
    1624           0 :         mPattern =
    1625           0 :           new (mLinGradPat) LinearGradientPattern(storage->mBegin, storage->mEnd,
    1626           0 :                                                   mTranslator->LookupGradientStops(storage->mStops),
    1627           0 :                                                   storage->mMatrix);
    1628           0 :         return mPattern;
    1629             :       }
    1630             :     case PatternType::RADIAL_GRADIENT:
    1631             :       {
    1632           0 :         RadialGradientPatternStorage *storage = reinterpret_cast<RadialGradientPatternStorage*>(&mStorage->mStorage);
    1633           0 :         mPattern =
    1634           0 :           new (mRadGradPat) RadialGradientPattern(storage->mCenter1, storage->mCenter2,
    1635             :                                                   storage->mRadius1, storage->mRadius2,
    1636           0 :                                                   mTranslator->LookupGradientStops(storage->mStops),
    1637           0 :                                                   storage->mMatrix);
    1638           0 :         return mPattern;
    1639             :       }
    1640             :     default:
    1641           0 :       return new (mColPat) ColorPattern(Color());
    1642             :     }
    1643             : 
    1644             :     return mPattern;
    1645             :   }
    1646             : 
    1647             :   union {
    1648             :     char mColPat[sizeof(ColorPattern)];
    1649             :     char mLinGradPat[sizeof(LinearGradientPattern)];
    1650             :     char mRadGradPat[sizeof(RadialGradientPattern)];
    1651             :     char mSurfPat[sizeof(SurfacePattern)];
    1652             :   };
    1653             : 
    1654             :   PatternStorage *mStorage;
    1655             :   Pattern *mPattern;
    1656             :   Translator *mTranslator;
    1657             : };
    1658             : 
    1659             : inline bool
    1660           0 : RecordedFillRect::PlayEvent(Translator *aTranslator) const
    1661             : {
    1662           0 :   aTranslator->LookupDrawTarget(mDT)->FillRect(mRect, *GenericPattern(mPattern, aTranslator), mOptions);
    1663           0 :   return true;
    1664             : }
    1665             : 
    1666             : template<class S>
    1667             : void
    1668           0 : RecordedFillRect::Record(S &aStream) const
    1669             : {
    1670           0 :   RecordedDrawingEvent::Record(aStream);
    1671           0 :   WriteElement(aStream, mRect);
    1672           0 :   WriteElement(aStream, mOptions);
    1673           0 :   RecordPatternData(aStream, mPattern);
    1674           0 : }
    1675             : 
    1676             : template<class S>
    1677           0 : RecordedFillRect::RecordedFillRect(S &aStream)
    1678           0 :   : RecordedDrawingEvent(FILLRECT, aStream)
    1679             : {
    1680           0 :   ReadElement(aStream, mRect);
    1681           0 :   ReadElement(aStream, mOptions);
    1682           0 :   ReadPatternData(aStream, mPattern);
    1683           0 : }
    1684             : 
    1685             : inline void
    1686           0 : RecordedFillRect::OutputSimpleEventInfo(stringstream &aStringStream) const
    1687             : {
    1688           0 :   aStringStream << "[" << mDT << "] FillRect (" << mRect.x << ", " << mRect.y << " - " << mRect.width << " x " << mRect.height << ") ";
    1689           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    1690           0 : }
    1691             : 
    1692             : inline bool
    1693           0 : RecordedStrokeRect::PlayEvent(Translator *aTranslator) const
    1694             : {
    1695           0 :   aTranslator->LookupDrawTarget(mDT)->StrokeRect(mRect, *GenericPattern(mPattern, aTranslator), mStrokeOptions, mOptions);
    1696           0 :   return true;
    1697             : }
    1698             : 
    1699             : template<class S>
    1700             : void
    1701           0 : RecordedStrokeRect::Record(S &aStream) const
    1702             : {
    1703           0 :   RecordedDrawingEvent::Record(aStream);
    1704           0 :   WriteElement(aStream, mRect);
    1705           0 :   WriteElement(aStream, mOptions);
    1706           0 :   RecordPatternData(aStream, mPattern);
    1707           0 :   RecordStrokeOptions(aStream, mStrokeOptions);
    1708           0 : }
    1709             : 
    1710             : template<class S>
    1711           0 : RecordedStrokeRect::RecordedStrokeRect(S &aStream)
    1712           0 :   : RecordedDrawingEvent(STROKERECT, aStream)
    1713             : {
    1714           0 :   ReadElement(aStream, mRect);
    1715           0 :   ReadElement(aStream, mOptions);
    1716           0 :   ReadPatternData(aStream, mPattern);
    1717           0 :   ReadStrokeOptions(aStream, mStrokeOptions);
    1718           0 : }
    1719             : 
    1720             : inline void
    1721           0 : RecordedStrokeRect::OutputSimpleEventInfo(stringstream &aStringStream) const
    1722             : {
    1723           0 :   aStringStream << "[" << mDT << "] StrokeRect (" << mRect.x << ", " << mRect.y << " - " << mRect.width << " x " << mRect.height
    1724           0 :                 << ") LineWidth: " << mStrokeOptions.mLineWidth << "px ";
    1725           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    1726           0 : }
    1727             : 
    1728             : inline bool
    1729           0 : RecordedStrokeLine::PlayEvent(Translator *aTranslator) const
    1730             : {
    1731           0 :   aTranslator->LookupDrawTarget(mDT)->StrokeLine(mBegin, mEnd, *GenericPattern(mPattern, aTranslator), mStrokeOptions, mOptions);
    1732           0 :   return true;
    1733             : }
    1734             : 
    1735             : template<class S>
    1736             : void
    1737           0 : RecordedStrokeLine::Record(S &aStream) const
    1738             : {
    1739           0 :   RecordedDrawingEvent::Record(aStream);
    1740           0 :   WriteElement(aStream, mBegin);
    1741           0 :   WriteElement(aStream, mEnd);
    1742           0 :   WriteElement(aStream, mOptions);
    1743           0 :   RecordPatternData(aStream, mPattern);
    1744           0 :   RecordStrokeOptions(aStream, mStrokeOptions);
    1745           0 : }
    1746             : 
    1747             : template<class S>
    1748           0 : RecordedStrokeLine::RecordedStrokeLine(S &aStream)
    1749           0 :   : RecordedDrawingEvent(STROKELINE, aStream)
    1750             : {
    1751           0 :   ReadElement(aStream, mBegin);
    1752           0 :   ReadElement(aStream, mEnd);
    1753           0 :   ReadElement(aStream, mOptions);
    1754           0 :   ReadPatternData(aStream, mPattern);
    1755           0 :   ReadStrokeOptions(aStream, mStrokeOptions);
    1756           0 : }
    1757             : 
    1758             : inline void
    1759           0 : RecordedStrokeLine::OutputSimpleEventInfo(stringstream &aStringStream) const
    1760             : {
    1761           0 :   aStringStream << "[" << mDT << "] StrokeLine (" << mBegin.x << ", " << mBegin.y << " - " << mEnd.x << ", " << mEnd.y
    1762           0 :                 << ") LineWidth: " << mStrokeOptions.mLineWidth << "px ";
    1763           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    1764           0 : }
    1765             : 
    1766             : inline bool
    1767           0 : RecordedFill::PlayEvent(Translator *aTranslator) const
    1768             : {
    1769           0 :   aTranslator->LookupDrawTarget(mDT)->Fill(aTranslator->LookupPath(mPath), *GenericPattern(mPattern, aTranslator), mOptions);
    1770           0 :   return true;
    1771             : }
    1772             : 
    1773             : template<class S>
    1774           0 : RecordedFill::RecordedFill(S &aStream)
    1775           0 :   : RecordedDrawingEvent(FILL, aStream)
    1776             : {
    1777           0 :   ReadElement(aStream, mPath);
    1778           0 :   ReadElement(aStream, mOptions);
    1779           0 :   ReadPatternData(aStream, mPattern);
    1780           0 : }
    1781             : 
    1782             : template<class S>
    1783             : void
    1784           0 : RecordedFill::Record(S &aStream) const
    1785             : {
    1786           0 :   RecordedDrawingEvent::Record(aStream);
    1787           0 :   WriteElement(aStream, mPath);
    1788           0 :   WriteElement(aStream, mOptions);
    1789           0 :   RecordPatternData(aStream, mPattern);
    1790           0 : }
    1791             : 
    1792             : inline void
    1793           0 : RecordedFill::OutputSimpleEventInfo(stringstream &aStringStream) const
    1794             : {
    1795           0 :   aStringStream << "[" << mDT << "] Fill (" << mPath << ") ";
    1796           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    1797           0 : }
    1798             : 
    1799             : inline
    1800           0 : RecordedFillGlyphs::~RecordedFillGlyphs()
    1801             : {
    1802           0 :   delete [] mGlyphs;
    1803           0 : }
    1804             : 
    1805             : inline bool
    1806           0 : RecordedFillGlyphs::PlayEvent(Translator *aTranslator) const
    1807             : {
    1808             :   GlyphBuffer buffer;
    1809           0 :   buffer.mGlyphs = mGlyphs;
    1810           0 :   buffer.mNumGlyphs = mNumGlyphs;
    1811           0 :   aTranslator->LookupDrawTarget(mDT)->FillGlyphs(aTranslator->LookupScaledFont(mScaledFont), buffer, *GenericPattern(mPattern, aTranslator), mOptions);
    1812           0 :   return true;
    1813             : }
    1814             : 
    1815             : template<class S>
    1816           0 : RecordedFillGlyphs::RecordedFillGlyphs(S &aStream)
    1817           0 :   : RecordedDrawingEvent(FILLGLYPHS, aStream)
    1818             : {
    1819           0 :   ReadElement(aStream, mScaledFont);
    1820           0 :   ReadElement(aStream, mOptions);
    1821           0 :   ReadPatternData(aStream, mPattern);
    1822           0 :   ReadElement(aStream, mNumGlyphs);
    1823           0 :   mGlyphs = new Glyph[mNumGlyphs];
    1824           0 :   aStream.read((char*)mGlyphs, sizeof(Glyph) * mNumGlyphs);
    1825           0 : }
    1826             : 
    1827             : template<class S>
    1828             : void
    1829           0 : RecordedFillGlyphs::Record(S &aStream) const
    1830             : {
    1831           0 :   RecordedDrawingEvent::Record(aStream);
    1832           0 :   WriteElement(aStream, mScaledFont);
    1833           0 :   WriteElement(aStream, mOptions);
    1834           0 :   RecordPatternData(aStream, mPattern);
    1835           0 :   WriteElement(aStream, mNumGlyphs);
    1836           0 :   aStream.write((char*)mGlyphs, sizeof(Glyph) * mNumGlyphs);
    1837           0 : }
    1838             : 
    1839             : inline void
    1840           0 : RecordedFillGlyphs::OutputSimpleEventInfo(stringstream &aStringStream) const
    1841             : {
    1842           0 :   aStringStream << "[" << mDT << "] FillGlyphs (" << mScaledFont << ") ";
    1843           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    1844           0 : }
    1845             : 
    1846             : inline bool
    1847           0 : RecordedMask::PlayEvent(Translator *aTranslator) const
    1848             : {
    1849           0 :   aTranslator->LookupDrawTarget(mDT)->Mask(*GenericPattern(mSource, aTranslator), *GenericPattern(mMask, aTranslator), mOptions);
    1850           0 :   return true;
    1851             : }
    1852             : 
    1853             : template<class S>
    1854           0 : RecordedMask::RecordedMask(S &aStream)
    1855           0 :   : RecordedDrawingEvent(MASK, aStream)
    1856             : {
    1857           0 :   ReadElement(aStream, mOptions);
    1858           0 :   ReadPatternData(aStream, mSource);
    1859           0 :   ReadPatternData(aStream, mMask);
    1860           0 : }
    1861             : 
    1862             : template<class S>
    1863             : void
    1864           0 : RecordedMask::Record(S &aStream) const
    1865             : {
    1866           0 :   RecordedDrawingEvent::Record(aStream);
    1867           0 :   WriteElement(aStream, mOptions);
    1868           0 :   RecordPatternData(aStream, mSource);
    1869           0 :   RecordPatternData(aStream, mMask);
    1870           0 : }
    1871             : 
    1872             : inline void
    1873           0 : RecordedMask::OutputSimpleEventInfo(stringstream &aStringStream) const
    1874             : {
    1875           0 :   aStringStream << "[" << mDT << "] Mask (Source: ";
    1876           0 :   OutputSimplePatternInfo(mSource, aStringStream);
    1877           0 :   aStringStream << " Mask: ";
    1878           0 :   OutputSimplePatternInfo(mMask, aStringStream);
    1879           0 : }
    1880             : 
    1881             : inline bool
    1882           0 : RecordedStroke::PlayEvent(Translator *aTranslator) const
    1883             : {
    1884           0 :   aTranslator->LookupDrawTarget(mDT)->Stroke(aTranslator->LookupPath(mPath), *GenericPattern(mPattern, aTranslator), mStrokeOptions, mOptions);
    1885           0 :   return true;
    1886             : }
    1887             : 
    1888             : template<class S>
    1889             : void
    1890           0 : RecordedStroke::Record(S &aStream) const
    1891             : {
    1892           0 :   RecordedDrawingEvent::Record(aStream);
    1893           0 :   WriteElement(aStream, mPath);
    1894           0 :   WriteElement(aStream, mOptions);
    1895           0 :   RecordPatternData(aStream, mPattern);
    1896           0 :   RecordStrokeOptions(aStream, mStrokeOptions);
    1897           0 : }
    1898             : 
    1899             : template<class S>
    1900           0 : RecordedStroke::RecordedStroke(S &aStream)
    1901           0 :   : RecordedDrawingEvent(STROKE, aStream)
    1902             : {
    1903           0 :   ReadElement(aStream, mPath);
    1904           0 :   ReadElement(aStream, mOptions);
    1905           0 :   ReadPatternData(aStream, mPattern);
    1906           0 :   ReadStrokeOptions(aStream, mStrokeOptions);
    1907           0 : }
    1908             : 
    1909             : inline void
    1910           0 : RecordedStroke::OutputSimpleEventInfo(stringstream &aStringStream) const
    1911             : {
    1912           0 :   aStringStream << "[" << mDT << "] Stroke ("<< mPath << ") LineWidth: " << mStrokeOptions.mLineWidth << "px ";
    1913           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    1914           0 : }
    1915             : 
    1916             : inline bool
    1917           0 : RecordedClearRect::PlayEvent(Translator *aTranslator) const
    1918             : {
    1919           0 :   aTranslator->LookupDrawTarget(mDT)->ClearRect(mRect);
    1920           0 :   return true;
    1921             : }
    1922             : 
    1923             : template<class S>
    1924             : void
    1925           0 : RecordedClearRect::Record(S &aStream) const
    1926             : {
    1927           0 :   RecordedDrawingEvent::Record(aStream);
    1928           0 :   WriteElement(aStream, mRect);
    1929           0 : }
    1930             : 
    1931             : template<class S>
    1932           0 : RecordedClearRect::RecordedClearRect(S &aStream)
    1933           0 :   : RecordedDrawingEvent(CLEARRECT, aStream)
    1934             : {
    1935           0 :     ReadElement(aStream, mRect);
    1936           0 : }
    1937             : 
    1938             : inline void
    1939           0 : RecordedClearRect::OutputSimpleEventInfo(stringstream &aStringStream) const
    1940             : {
    1941           0 :   aStringStream << "[" << mDT<< "] ClearRect (" << mRect.x << ", " << mRect.y << " - " << mRect.width << " x " << mRect.height << ") ";
    1942           0 : }
    1943             : 
    1944             : inline bool
    1945           0 : RecordedCopySurface::PlayEvent(Translator *aTranslator) const
    1946             : {
    1947           0 :         aTranslator->LookupDrawTarget(mDT)->CopySurface(aTranslator->LookupSourceSurface(mSourceSurface),
    1948           0 :                                                   mSourceRect, mDest);
    1949           0 :   return true;
    1950             : }
    1951             : 
    1952             : template<class S>
    1953             : void
    1954           0 : RecordedCopySurface::Record(S &aStream) const
    1955             : {
    1956           0 :   RecordedDrawingEvent::Record(aStream);
    1957           0 :   WriteElement(aStream, mSourceSurface);
    1958           0 :   WriteElement(aStream, mSourceRect);
    1959           0 :   WriteElement(aStream, mDest);
    1960           0 : }
    1961             : 
    1962             : template<class S>
    1963           0 : RecordedCopySurface::RecordedCopySurface(S &aStream)
    1964           0 :   : RecordedDrawingEvent(COPYSURFACE, aStream)
    1965             : {
    1966           0 :   ReadElement(aStream, mSourceSurface);
    1967           0 :   ReadElement(aStream, mSourceRect);
    1968           0 :   ReadElement(aStream, mDest);
    1969           0 : }
    1970             : 
    1971             : inline void
    1972           0 : RecordedCopySurface::OutputSimpleEventInfo(stringstream &aStringStream) const
    1973             : {
    1974           0 :   aStringStream << "[" << mDT<< "] CopySurface (" << mSourceSurface << ")";
    1975           0 : }
    1976             : 
    1977             : inline bool
    1978           0 : RecordedPushClip::PlayEvent(Translator *aTranslator) const
    1979             : {
    1980           0 :   aTranslator->LookupDrawTarget(mDT)->PushClip(aTranslator->LookupPath(mPath));
    1981           0 :   return true;
    1982             : }
    1983             : 
    1984             : template<class S>
    1985             : void
    1986           0 : RecordedPushClip::Record(S &aStream) const
    1987             : {
    1988           0 :   RecordedDrawingEvent::Record(aStream);
    1989           0 :   WriteElement(aStream, mPath);
    1990           0 : }
    1991             : 
    1992             : template<class S>
    1993           0 : RecordedPushClip::RecordedPushClip(S &aStream)
    1994           0 :   : RecordedDrawingEvent(PUSHCLIP, aStream)
    1995             : {
    1996           0 :   ReadElement(aStream, mPath);
    1997           0 : }
    1998             : 
    1999             : inline void
    2000           0 : RecordedPushClip::OutputSimpleEventInfo(stringstream &aStringStream) const
    2001             : {
    2002           0 :   aStringStream << "[" << mDT << "] PushClip (" << mPath << ") ";
    2003           0 : }
    2004             : 
    2005             : inline bool
    2006           0 : RecordedPushClipRect::PlayEvent(Translator *aTranslator) const
    2007             : {
    2008           0 :   aTranslator->LookupDrawTarget(mDT)->PushClipRect(mRect);
    2009           0 :   return true;
    2010             : }
    2011             : 
    2012             : template<class S>
    2013             : void
    2014           0 : RecordedPushClipRect::Record(S &aStream) const
    2015             : {
    2016           0 :   RecordedDrawingEvent::Record(aStream);
    2017           0 :   WriteElement(aStream, mRect);
    2018           0 : }
    2019             : 
    2020             : template<class S>
    2021           0 : RecordedPushClipRect::RecordedPushClipRect(S &aStream)
    2022           0 :   : RecordedDrawingEvent(PUSHCLIPRECT, aStream)
    2023             : {
    2024           0 :   ReadElement(aStream, mRect);
    2025           0 : }
    2026             : 
    2027             : inline void
    2028           0 : RecordedPushClipRect::OutputSimpleEventInfo(stringstream &aStringStream) const
    2029             : {
    2030           0 :   aStringStream << "[" << mDT << "] PushClipRect (" << mRect.x << ", " << mRect.y << " - " << mRect.width << " x " << mRect.height << ") ";
    2031           0 : }
    2032             : 
    2033             : inline bool
    2034           0 : RecordedPopClip::PlayEvent(Translator *aTranslator) const
    2035             : {
    2036           0 :   aTranslator->LookupDrawTarget(mDT)->PopClip();
    2037           0 :   return true;
    2038             : }
    2039             : 
    2040             : template<class S>
    2041             : void
    2042           0 : RecordedPopClip::Record(S &aStream) const
    2043             : {
    2044           0 :   RecordedDrawingEvent::Record(aStream);
    2045           0 : }
    2046             : 
    2047             : template<class S>
    2048           0 : RecordedPopClip::RecordedPopClip(S &aStream)
    2049           0 :   : RecordedDrawingEvent(POPCLIP, aStream)
    2050             : {
    2051           0 : }
    2052             : 
    2053             : inline void
    2054           0 : RecordedPopClip::OutputSimpleEventInfo(stringstream &aStringStream) const
    2055             : {
    2056           0 :   aStringStream << "[" << mDT << "] PopClip";
    2057           0 : }
    2058             : 
    2059             : inline bool
    2060           0 : RecordedPushLayer::PlayEvent(Translator *aTranslator) const
    2061             : {
    2062           0 :   SourceSurface* mask = mMask ? aTranslator->LookupSourceSurface(mMask)
    2063           0 :                               : nullptr;
    2064           0 :   aTranslator->LookupDrawTarget(mDT)->
    2065           0 :     PushLayer(mOpaque, mOpacity, mask, mMaskTransform, mBounds, mCopyBackground);
    2066           0 :   return true;
    2067             : }
    2068             : 
    2069             : template<class S>
    2070             : void
    2071           0 : RecordedPushLayer::Record(S &aStream) const
    2072             : {
    2073           0 :   RecordedDrawingEvent::Record(aStream);
    2074           0 :   WriteElement(aStream, mOpaque);
    2075           0 :   WriteElement(aStream, mOpacity);
    2076           0 :   WriteElement(aStream, mMask);
    2077           0 :   WriteElement(aStream, mMaskTransform);
    2078           0 :   WriteElement(aStream, mBounds);
    2079           0 :   WriteElement(aStream, mCopyBackground);
    2080           0 : }
    2081             : 
    2082             : template<class S>
    2083           0 : RecordedPushLayer::RecordedPushLayer(S &aStream)
    2084           0 :   : RecordedDrawingEvent(PUSHLAYER, aStream)
    2085             : {
    2086           0 :   ReadElement(aStream, mOpaque);
    2087           0 :   ReadElement(aStream, mOpacity);
    2088           0 :   ReadElement(aStream, mMask);
    2089           0 :   ReadElement(aStream, mMaskTransform);
    2090           0 :   ReadElement(aStream, mBounds);
    2091           0 :   ReadElement(aStream, mCopyBackground);
    2092           0 : }
    2093             : 
    2094             : inline void
    2095           0 : RecordedPushLayer::OutputSimpleEventInfo(stringstream &aStringStream) const
    2096             : {
    2097           0 :   aStringStream << "[" << mDT << "] PushPLayer (Opaque=" << mOpaque <<
    2098           0 :     ", Opacity=" << mOpacity << ", Mask Ref=" << mMask << ") ";
    2099           0 : }
    2100             : 
    2101             : inline bool
    2102           0 : RecordedPopLayer::PlayEvent(Translator *aTranslator) const
    2103             : {
    2104           0 :   aTranslator->LookupDrawTarget(mDT)->PopLayer();
    2105           0 :   return true;
    2106             : }
    2107             : 
    2108             : template<class S>
    2109             : void
    2110           0 : RecordedPopLayer::Record(S &aStream) const
    2111             : {
    2112           0 :   RecordedDrawingEvent::Record(aStream);
    2113           0 : }
    2114             : 
    2115             : template<class S>
    2116           0 : RecordedPopLayer::RecordedPopLayer(S &aStream)
    2117           0 :   : RecordedDrawingEvent(POPLAYER, aStream)
    2118             : {
    2119           0 : }
    2120             : 
    2121             : inline void
    2122           0 : RecordedPopLayer::OutputSimpleEventInfo(stringstream &aStringStream) const
    2123             : {
    2124           0 :   aStringStream << "[" << mDT << "] PopLayer";
    2125           0 : }
    2126             : 
    2127             : inline bool
    2128           0 : RecordedSetTransform::PlayEvent(Translator *aTranslator) const
    2129             : {
    2130           0 :   aTranslator->LookupDrawTarget(mDT)->SetTransform(mTransform);
    2131           0 :   return true;
    2132             : }
    2133             : 
    2134             : template<class S>
    2135             : void
    2136           0 : RecordedSetTransform::Record(S &aStream) const
    2137             : {
    2138           0 :   RecordedDrawingEvent::Record(aStream);
    2139           0 :   WriteElement(aStream, mTransform);
    2140           0 : }
    2141             : 
    2142             : template<class S>
    2143           0 : RecordedSetTransform::RecordedSetTransform(S &aStream)
    2144           0 :   : RecordedDrawingEvent(SETTRANSFORM, aStream)
    2145             : {
    2146           0 :   ReadElement(aStream, mTransform);
    2147           0 : }
    2148             : 
    2149             : inline void
    2150           0 : RecordedSetTransform::OutputSimpleEventInfo(stringstream &aStringStream) const
    2151             : {
    2152           0 :   aStringStream << "[" << mDT << "] SetTransform [ " << mTransform._11 << " " << mTransform._12 << " ; " <<
    2153           0 :     mTransform._21 << " " << mTransform._22 << " ; " << mTransform._31 << " " << mTransform._32 << " ]";
    2154           0 : }
    2155             : 
    2156             : inline bool
    2157           0 : RecordedDrawSurface::PlayEvent(Translator *aTranslator) const
    2158             : {
    2159           0 :   aTranslator->LookupDrawTarget(mDT)->
    2160           0 :     DrawSurface(aTranslator->LookupSourceSurface(mRefSource), mDest, mSource,
    2161           0 :                 mDSOptions, mOptions);
    2162           0 :   return true;
    2163             : }
    2164             : 
    2165             : template<class S>
    2166             : void
    2167           0 : RecordedDrawSurface::Record(S &aStream) const
    2168             : {
    2169           0 :   RecordedDrawingEvent::Record(aStream);
    2170           0 :   WriteElement(aStream, mRefSource);
    2171           0 :   WriteElement(aStream, mDest);
    2172           0 :   WriteElement(aStream, mSource);
    2173           0 :   WriteElement(aStream, mDSOptions);
    2174           0 :   WriteElement(aStream, mOptions);
    2175           0 : }
    2176             : 
    2177             : template<class S>
    2178           0 : RecordedDrawSurface::RecordedDrawSurface(S &aStream)
    2179           0 :   : RecordedDrawingEvent(DRAWSURFACE, aStream)
    2180             : {
    2181           0 :   ReadElement(aStream, mRefSource);
    2182           0 :   ReadElement(aStream, mDest);
    2183           0 :   ReadElement(aStream, mSource);
    2184           0 :   ReadElement(aStream, mDSOptions);
    2185           0 :   ReadElement(aStream, mOptions);
    2186           0 : }
    2187             : 
    2188             : inline void
    2189           0 : RecordedDrawSurface::OutputSimpleEventInfo(stringstream &aStringStream) const
    2190             : {
    2191           0 :   aStringStream << "[" << mDT << "] DrawSurface (" << mRefSource << ")";
    2192           0 : }
    2193             : 
    2194             : inline bool
    2195           0 : RecordedDrawFilter::PlayEvent(Translator *aTranslator) const
    2196             : {
    2197           0 :   aTranslator->LookupDrawTarget(mDT)->
    2198           0 :     DrawFilter(aTranslator->LookupFilterNode(mNode), mSourceRect,
    2199           0 :                 mDestPoint, mOptions);
    2200           0 :   return true;
    2201             : }
    2202             : 
    2203             : template<class S>
    2204             : void
    2205           0 : RecordedDrawFilter::Record(S &aStream) const
    2206             : {
    2207           0 :   RecordedDrawingEvent::Record(aStream);
    2208           0 :   WriteElement(aStream, mNode);
    2209           0 :   WriteElement(aStream, mSourceRect);
    2210           0 :   WriteElement(aStream, mDestPoint);
    2211           0 :   WriteElement(aStream, mOptions);
    2212           0 : }
    2213             : 
    2214             : template<class S>
    2215           0 : RecordedDrawFilter::RecordedDrawFilter(S &aStream)
    2216           0 :   : RecordedDrawingEvent(DRAWFILTER, aStream)
    2217             : {
    2218           0 :   ReadElement(aStream, mNode);
    2219           0 :   ReadElement(aStream, mSourceRect);
    2220           0 :   ReadElement(aStream, mDestPoint);
    2221           0 :   ReadElement(aStream, mOptions);
    2222           0 : }
    2223             : 
    2224             : inline void
    2225           0 : RecordedDrawFilter::OutputSimpleEventInfo(stringstream &aStringStream) const
    2226             : {
    2227           0 :   aStringStream << "[" << mDT << "] DrawFilter (" << mNode << ")";
    2228           0 : }
    2229             : 
    2230             : inline bool
    2231           0 : RecordedDrawSurfaceWithShadow::PlayEvent(Translator *aTranslator) const
    2232             : {
    2233           0 :   aTranslator->LookupDrawTarget(mDT)->
    2234           0 :     DrawSurfaceWithShadow(aTranslator->LookupSourceSurface(mRefSource),
    2235           0 :                           mDest, mColor, mOffset, mSigma, mOp);
    2236           0 :   return true;
    2237             : }
    2238             : 
    2239             : template<class S>
    2240             : void
    2241           0 : RecordedDrawSurfaceWithShadow::Record(S &aStream) const
    2242             : {
    2243           0 :   RecordedDrawingEvent::Record(aStream);
    2244           0 :   WriteElement(aStream, mRefSource);
    2245           0 :   WriteElement(aStream, mDest);
    2246           0 :   WriteElement(aStream, mColor);
    2247           0 :   WriteElement(aStream, mOffset);
    2248           0 :   WriteElement(aStream, mSigma);
    2249           0 :   WriteElement(aStream, mOp);
    2250           0 : }
    2251             : 
    2252             : template<class S>
    2253           0 : RecordedDrawSurfaceWithShadow::RecordedDrawSurfaceWithShadow(S &aStream)
    2254           0 :   : RecordedDrawingEvent(DRAWSURFACEWITHSHADOW, aStream)
    2255             : {
    2256           0 :   ReadElement(aStream, mRefSource);
    2257           0 :   ReadElement(aStream, mDest);
    2258           0 :   ReadElement(aStream, mColor);
    2259           0 :   ReadElement(aStream, mOffset);
    2260           0 :   ReadElement(aStream, mSigma);
    2261           0 :   ReadElement(aStream, mOp);
    2262           0 : }
    2263             : 
    2264             : inline void
    2265           0 : RecordedDrawSurfaceWithShadow::OutputSimpleEventInfo(stringstream &aStringStream) const
    2266             : {
    2267           0 :   aStringStream << "[" << mDT << "] DrawSurfaceWithShadow (" << mRefSource << ") Color: (" <<
    2268           0 :     mColor.r << ", " << mColor.g << ", " << mColor.b << ", " << mColor.a << ")";
    2269           0 : }
    2270             : 
    2271             : inline
    2272           0 : RecordedPathCreation::RecordedPathCreation(PathRecording *aPath)
    2273           0 :   : RecordedEventDerived(PATHCREATION), mRefPtr(aPath), mFillRule(aPath->mFillRule), mPathOps(aPath->mPathOps)
    2274             : {
    2275           0 : }
    2276             : 
    2277             : inline
    2278           0 : RecordedPathCreation::~RecordedPathCreation()
    2279             : {
    2280           0 : }
    2281             : 
    2282             : inline bool
    2283           0 : RecordedPathCreation::PlayEvent(Translator *aTranslator) const
    2284             : {
    2285             :   RefPtr<PathBuilder> builder = 
    2286           0 :     aTranslator->GetReferenceDrawTarget()->CreatePathBuilder(mFillRule);
    2287             : 
    2288           0 :   for (size_t i = 0; i < mPathOps.size(); i++) {
    2289           0 :     const PathOp &op = mPathOps[i];
    2290           0 :     switch (op.mType) {
    2291             :     case PathOp::OP_MOVETO:
    2292           0 :       builder->MoveTo(op.mP1);
    2293           0 :       break;
    2294             :     case PathOp::OP_LINETO:
    2295           0 :       builder->LineTo(op.mP1);
    2296           0 :       break;
    2297             :     case PathOp::OP_BEZIERTO:
    2298           0 :       builder->BezierTo(op.mP1, op.mP2, op.mP3);
    2299           0 :       break;
    2300             :     case PathOp::OP_QUADRATICBEZIERTO:
    2301           0 :       builder->QuadraticBezierTo(op.mP1, op.mP2);
    2302           0 :       break;
    2303             :     case PathOp::OP_CLOSE:
    2304           0 :       builder->Close();
    2305           0 :       break;
    2306             :     }
    2307             :   }
    2308             : 
    2309           0 :   RefPtr<Path> path = builder->Finish();
    2310           0 :   aTranslator->AddPath(mRefPtr, path);
    2311           0 :   return true;
    2312             : }
    2313             : 
    2314             : template<class S>
    2315             : void
    2316           0 : RecordedPathCreation::Record(S &aStream) const
    2317             : {
    2318           0 :   WriteElement(aStream, mRefPtr);
    2319           0 :   WriteElement(aStream, uint64_t(mPathOps.size()));
    2320           0 :   WriteElement(aStream, mFillRule);
    2321             :   typedef std::vector<PathOp> pathOpVec;
    2322           0 :   for (pathOpVec::const_iterator iter = mPathOps.begin(); iter != mPathOps.end(); iter++) {
    2323           0 :     WriteElement(aStream, iter->mType);
    2324           0 :     if (sPointCount[iter->mType] >= 1) {
    2325           0 :       WriteElement(aStream, iter->mP1);
    2326             :     }
    2327           0 :     if (sPointCount[iter->mType] >= 2) {
    2328           0 :       WriteElement(aStream, iter->mP2);
    2329             :     }
    2330           0 :     if (sPointCount[iter->mType] >= 3) {
    2331           0 :       WriteElement(aStream, iter->mP3);
    2332             :     }
    2333             :   }
    2334             : 
    2335           0 : }
    2336             : 
    2337             : template<class S>
    2338           0 : RecordedPathCreation::RecordedPathCreation(S &aStream)
    2339           0 :   : RecordedEventDerived(PATHCREATION)
    2340             : {
    2341             :   uint64_t size;
    2342             : 
    2343           0 :   ReadElement(aStream, mRefPtr);
    2344           0 :   ReadElement(aStream, size);
    2345           0 :   ReadElement(aStream, mFillRule);
    2346             : 
    2347           0 :   for (uint64_t i = 0; i < size; i++) {
    2348           0 :     PathOp newPathOp;
    2349           0 :     ReadElement(aStream, newPathOp.mType);
    2350           0 :     if (sPointCount[newPathOp.mType] >= 1) {
    2351           0 :       ReadElement(aStream, newPathOp.mP1);
    2352             :     }
    2353           0 :     if (sPointCount[newPathOp.mType] >= 2) {
    2354           0 :       ReadElement(aStream, newPathOp.mP2);
    2355             :     }
    2356           0 :     if (sPointCount[newPathOp.mType] >= 3) {
    2357           0 :       ReadElement(aStream, newPathOp.mP3);
    2358             :     }
    2359             : 
    2360           0 :     mPathOps.push_back(newPathOp);
    2361             :   }
    2362             : 
    2363           0 : }
    2364             : 
    2365             : inline void
    2366           0 : RecordedPathCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    2367             : {
    2368           0 :   aStringStream << "[" << mRefPtr << "] Path created (OpCount: " << mPathOps.size() << ")";
    2369           0 : }
    2370             : inline bool
    2371           0 : RecordedPathDestruction::PlayEvent(Translator *aTranslator) const
    2372             : {
    2373           0 :   aTranslator->RemovePath(mRefPtr);
    2374           0 :   return true;
    2375             : }
    2376             : 
    2377             : template<class S>
    2378             : void
    2379           0 : RecordedPathDestruction::Record(S &aStream) const
    2380             : {
    2381           0 :   WriteElement(aStream, mRefPtr);
    2382           0 : }
    2383             : 
    2384             : template<class S>
    2385           0 : RecordedPathDestruction::RecordedPathDestruction(S &aStream)
    2386           0 :   : RecordedEventDerived(PATHDESTRUCTION)
    2387             : {
    2388           0 :   ReadElement(aStream, mRefPtr);
    2389           0 : }
    2390             : 
    2391             : inline void
    2392           0 : RecordedPathDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    2393             : {
    2394           0 :   aStringStream << "[" << mRefPtr << "] Path Destroyed";
    2395           0 : }
    2396             : 
    2397             : inline
    2398           0 : RecordedSourceSurfaceCreation::~RecordedSourceSurfaceCreation()
    2399             : {
    2400           0 :   if (mDataOwned) {
    2401           0 :     delete [] mData;
    2402             :   }
    2403           0 : }
    2404             : 
    2405             : inline bool
    2406           0 : RecordedSourceSurfaceCreation::PlayEvent(Translator *aTranslator) const
    2407             : {
    2408           0 :   if (!mData) {
    2409           0 :     return false;
    2410             :   }
    2411             : 
    2412           0 :   RefPtr<SourceSurface> src = aTranslator->GetReferenceDrawTarget()->
    2413           0 :     CreateSourceSurfaceFromData(mData, mSize, mSize.width * BytesPerPixel(mFormat), mFormat);
    2414           0 :   aTranslator->AddSourceSurface(mRefPtr, src);
    2415           0 :   return true;
    2416             : }
    2417             : 
    2418             : template<class S>
    2419             : void
    2420           0 : RecordedSourceSurfaceCreation::Record(S &aStream) const
    2421             : {
    2422           0 :   WriteElement(aStream, mRefPtr);
    2423           0 :   WriteElement(aStream, mSize);
    2424           0 :   WriteElement(aStream, mFormat);
    2425           0 :   MOZ_ASSERT(mData);
    2426           0 :   for (int y = 0; y < mSize.height; y++) {
    2427           0 :     aStream.write((const char*)mData + y * mStride, BytesPerPixel(mFormat) * mSize.width);
    2428             :   }
    2429           0 : }
    2430             : 
    2431             : template<class S>
    2432           0 : RecordedSourceSurfaceCreation::RecordedSourceSurfaceCreation(S &aStream)
    2433           0 :   : RecordedEventDerived(SOURCESURFACECREATION), mDataOwned(true)
    2434             : {
    2435           0 :   ReadElement(aStream, mRefPtr);
    2436           0 :   ReadElement(aStream, mSize);
    2437           0 :   ReadElement(aStream, mFormat);
    2438           0 :   mData = (uint8_t*)new (fallible) char[mSize.width * mSize.height * BytesPerPixel(mFormat)];
    2439           0 :   if (!mData) {
    2440           0 :     gfxWarning() << "RecordedSourceSurfaceCreation failed to allocate data";
    2441             :   } else {
    2442           0 :     aStream.read((char*)mData, mSize.width * mSize.height * BytesPerPixel(mFormat));
    2443             :   }
    2444           0 : }
    2445             : 
    2446             : inline void
    2447           0 : RecordedSourceSurfaceCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    2448             : {
    2449           0 :   aStringStream << "[" << mRefPtr << "] SourceSurface created (Size: " << mSize.width << "x" << mSize.height << ")";
    2450           0 : }
    2451             : 
    2452             : inline bool
    2453           0 : RecordedSourceSurfaceDestruction::PlayEvent(Translator *aTranslator) const
    2454             : {
    2455           0 :   aTranslator->RemoveSourceSurface(mRefPtr);
    2456           0 :   return true;
    2457             : }
    2458             : 
    2459             : template<class S>
    2460             : void
    2461           0 : RecordedSourceSurfaceDestruction::Record(S &aStream) const
    2462             : {
    2463           0 :   WriteElement(aStream, mRefPtr);
    2464           0 : }
    2465             : 
    2466             : template<class S>
    2467           0 : RecordedSourceSurfaceDestruction::RecordedSourceSurfaceDestruction(S &aStream)
    2468           0 :   : RecordedEventDerived(SOURCESURFACEDESTRUCTION)
    2469             : {
    2470           0 :   ReadElement(aStream, mRefPtr);
    2471           0 : }
    2472             : 
    2473             : inline void
    2474           0 : RecordedSourceSurfaceDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    2475             : {
    2476           0 :   aStringStream << "[" << mRefPtr << "] SourceSurface Destroyed";
    2477           0 : }
    2478             : 
    2479             : inline
    2480           0 : RecordedFilterNodeCreation::~RecordedFilterNodeCreation()
    2481             : {
    2482           0 : }
    2483             : 
    2484             : inline bool
    2485           0 : RecordedFilterNodeCreation::PlayEvent(Translator *aTranslator) const
    2486             : {
    2487           0 :   RefPtr<FilterNode> node = aTranslator->GetReferenceDrawTarget()->
    2488           0 :     CreateFilter(mType);
    2489           0 :   aTranslator->AddFilterNode(mRefPtr, node);
    2490           0 :   return true;
    2491             : }
    2492             : 
    2493             : template<class S>
    2494             : void
    2495           0 : RecordedFilterNodeCreation::Record(S &aStream) const
    2496             : {
    2497           0 :   WriteElement(aStream, mRefPtr);
    2498           0 :   WriteElement(aStream, mType);
    2499           0 : }
    2500             : 
    2501             : template<class S>
    2502           0 : RecordedFilterNodeCreation::RecordedFilterNodeCreation(S &aStream)
    2503           0 :   : RecordedEventDerived(FILTERNODECREATION)
    2504             : {
    2505           0 :   ReadElement(aStream, mRefPtr);
    2506           0 :   ReadElement(aStream, mType);
    2507           0 : }
    2508             : 
    2509             : inline void
    2510           0 : RecordedFilterNodeCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    2511             : {
    2512           0 :   aStringStream << "[" << mRefPtr << "] FilterNode created (Type: " << int(mType) << ")";
    2513           0 : }
    2514             : 
    2515             : inline bool
    2516           0 : RecordedFilterNodeDestruction::PlayEvent(Translator *aTranslator) const
    2517             : {
    2518           0 :   aTranslator->RemoveFilterNode(mRefPtr);
    2519           0 :   return true;
    2520             : }
    2521             : 
    2522             : template<class S>
    2523             : void
    2524           0 : RecordedFilterNodeDestruction::Record(S &aStream) const
    2525             : {
    2526           0 :   WriteElement(aStream, mRefPtr);
    2527           0 : }
    2528             : 
    2529             : template<class S>
    2530           0 : RecordedFilterNodeDestruction::RecordedFilterNodeDestruction(S &aStream)
    2531           0 :   : RecordedEventDerived(FILTERNODEDESTRUCTION)
    2532             : {
    2533           0 :   ReadElement(aStream, mRefPtr);
    2534           0 : }
    2535             : 
    2536             : inline void
    2537           0 : RecordedFilterNodeDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    2538             : {
    2539           0 :   aStringStream << "[" << mRefPtr << "] FilterNode Destroyed";
    2540           0 : }
    2541             : 
    2542             : inline
    2543           0 : RecordedGradientStopsCreation::~RecordedGradientStopsCreation()
    2544             : {
    2545           0 :   if (mDataOwned) {
    2546           0 :     delete [] mStops;
    2547             :   }
    2548           0 : }
    2549             : 
    2550             : inline bool
    2551           0 : RecordedGradientStopsCreation::PlayEvent(Translator *aTranslator) const
    2552             : {
    2553           0 :   RefPtr<GradientStops> src = aTranslator->GetReferenceDrawTarget()->
    2554           0 :     CreateGradientStops(mStops, mNumStops, mExtendMode);
    2555           0 :   aTranslator->AddGradientStops(mRefPtr, src);
    2556           0 :   return true;
    2557             : }
    2558             : 
    2559             : template<class S>
    2560             : void
    2561           0 : RecordedGradientStopsCreation::Record(S &aStream) const
    2562             : {
    2563           0 :   WriteElement(aStream, mRefPtr);
    2564           0 :   WriteElement(aStream, mExtendMode);
    2565           0 :   WriteElement(aStream, mNumStops);
    2566           0 :   aStream.write((const char*)mStops, mNumStops * sizeof(GradientStop));
    2567           0 : }
    2568             : 
    2569             : template<class S>
    2570           0 : RecordedGradientStopsCreation::RecordedGradientStopsCreation(S &aStream)
    2571           0 :   : RecordedEventDerived(GRADIENTSTOPSCREATION), mDataOwned(true)
    2572             : {
    2573           0 :   ReadElement(aStream, mRefPtr);
    2574           0 :   ReadElement(aStream, mExtendMode);
    2575           0 :   ReadElement(aStream, mNumStops);
    2576           0 :   mStops = new GradientStop[mNumStops];
    2577             : 
    2578           0 :   aStream.read((char*)mStops, mNumStops * sizeof(GradientStop));
    2579           0 : }
    2580             : 
    2581             : inline void
    2582           0 : RecordedGradientStopsCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    2583             : {
    2584           0 :   aStringStream << "[" << mRefPtr << "] GradientStops created (Stops: " << mNumStops << ")";
    2585           0 : }
    2586             : 
    2587             : inline bool
    2588           0 : RecordedGradientStopsDestruction::PlayEvent(Translator *aTranslator) const
    2589             : {
    2590           0 :   aTranslator->RemoveGradientStops(mRefPtr);
    2591           0 :   return true;
    2592             : }
    2593             : 
    2594             : template<class S>
    2595             : void
    2596           0 : RecordedGradientStopsDestruction::Record(S &aStream) const
    2597             : {
    2598           0 :   WriteElement(aStream, mRefPtr);
    2599           0 : }
    2600             : 
    2601             : template<class S>
    2602           0 : RecordedGradientStopsDestruction::RecordedGradientStopsDestruction(S &aStream)
    2603           0 :   : RecordedEventDerived(GRADIENTSTOPSDESTRUCTION)
    2604             : {
    2605           0 :   ReadElement(aStream, mRefPtr);
    2606           0 : }
    2607             : 
    2608             : inline void
    2609           0 : RecordedGradientStopsDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    2610             : {
    2611           0 :   aStringStream << "[" << mRefPtr << "] GradientStops Destroyed";
    2612           0 : }
    2613             : 
    2614             : inline bool
    2615           0 : RecordedIntoLuminanceSource::PlayEvent(Translator *aTranslator) const
    2616             : {
    2617           0 :   RefPtr<SourceSurface> src = aTranslator->LookupDrawTarget(mDT)->IntoLuminanceSource(mLuminanceType, mOpacity);
    2618           0 :   aTranslator->AddSourceSurface(mRefPtr, src);
    2619           0 :   return true;
    2620             : }
    2621             : 
    2622             : template<class S>
    2623             : void
    2624           0 : RecordedIntoLuminanceSource::Record(S &aStream) const
    2625             : {
    2626           0 :   WriteElement(aStream, mRefPtr);
    2627           0 :   WriteElement(aStream, mDT);
    2628           0 :   WriteElement(aStream, mLuminanceType);
    2629           0 :   WriteElement(aStream, mOpacity);
    2630           0 : }
    2631             : 
    2632             : template<class S>
    2633             : RecordedIntoLuminanceSource::RecordedIntoLuminanceSource(S &aStream)
    2634             :   : RecordedEventDerived(SNAPSHOT)
    2635             : {
    2636             :   ReadElement(aStream, mRefPtr);
    2637             :   ReadElement(aStream, mDT);
    2638             :   ReadElement(aStream, mLuminanceType);
    2639             :   ReadElement(aStream, mOpacity);
    2640             : }
    2641             : 
    2642             : inline void
    2643           0 : RecordedIntoLuminanceSource::OutputSimpleEventInfo(stringstream &aStringStream) const
    2644             : {
    2645           0 :   aStringStream << "[" << mRefPtr << "] Into Luminance Source (DT: " << mDT << ")";
    2646           0 : }
    2647             : 
    2648             : inline bool
    2649           0 : RecordedSnapshot::PlayEvent(Translator *aTranslator) const
    2650             : {
    2651           0 :   RefPtr<SourceSurface> src = aTranslator->LookupDrawTarget(mDT)->Snapshot();
    2652           0 :   aTranslator->AddSourceSurface(mRefPtr, src);
    2653           0 :   return true;
    2654             : }
    2655             : 
    2656             : template<class S>
    2657             : void
    2658           0 : RecordedSnapshot::Record(S &aStream) const
    2659             : {
    2660           0 :   WriteElement(aStream, mRefPtr);
    2661           0 :   WriteElement(aStream, mDT);
    2662           0 : }
    2663             : 
    2664             : template<class S>
    2665           0 : RecordedSnapshot::RecordedSnapshot(S &aStream)
    2666           0 :   : RecordedEventDerived(SNAPSHOT)
    2667             : {
    2668           0 :   ReadElement(aStream, mRefPtr);
    2669           0 :   ReadElement(aStream, mDT);
    2670           0 : }
    2671             : 
    2672             : inline void
    2673           0 : RecordedSnapshot::OutputSimpleEventInfo(stringstream &aStringStream) const
    2674             : {
    2675           0 :   aStringStream << "[" << mRefPtr << "] Snapshot Created (DT: " << mDT << ")";
    2676           0 : }
    2677             : 
    2678             : inline
    2679           0 : RecordedFontData::~RecordedFontData()
    2680             : {
    2681           0 :   delete[] mData;
    2682           0 : }
    2683             : 
    2684             : inline bool
    2685           0 : RecordedFontData::PlayEvent(Translator *aTranslator) const
    2686             : {
    2687             :   RefPtr<NativeFontResource> fontResource =
    2688           0 :     Factory::CreateNativeFontResource(mData, mFontDetails.size,
    2689           0 :                                       aTranslator->GetReferenceDrawTarget()->GetBackendType(),
    2690           0 :                                       mType, aTranslator->GetFontContext());
    2691           0 :   if (!fontResource) {
    2692           0 :     return false;
    2693             :   }
    2694             : 
    2695           0 :   aTranslator->AddNativeFontResource(mFontDetails.fontDataKey, fontResource);
    2696           0 :   return true;
    2697             : }
    2698             : 
    2699             : template<class S>
    2700             : void
    2701           0 : RecordedFontData::Record(S &aStream) const
    2702             : {
    2703           0 :   MOZ_ASSERT(mGetFontFileDataSucceeded);
    2704             : 
    2705           0 :   WriteElement(aStream, mType);
    2706           0 :   WriteElement(aStream, mFontDetails.fontDataKey);
    2707           0 :   WriteElement(aStream, mFontDetails.size);
    2708           0 :   aStream.write((const char*)mData, mFontDetails.size);
    2709           0 : }
    2710             : 
    2711             : inline void
    2712           0 : RecordedFontData::OutputSimpleEventInfo(stringstream &aStringStream) const
    2713             : {
    2714           0 :   aStringStream << "Font Data of size " << mFontDetails.size;
    2715           0 : }
    2716             : 
    2717             : inline void
    2718           0 : RecordedFontData::SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex)
    2719             : {
    2720           0 :   mData = new uint8_t[aSize];
    2721           0 :   memcpy(mData, aData, aSize);
    2722           0 :   mFontDetails.fontDataKey =
    2723           0 :     SFNTData::GetUniqueKey(aData, aSize, 0, nullptr);
    2724           0 :   mFontDetails.size = aSize;
    2725           0 :   mFontDetails.index = aIndex;
    2726           0 : }
    2727             : 
    2728             : inline bool
    2729           0 : RecordedFontData::GetFontDetails(RecordedFontDetails& fontDetails)
    2730             : {
    2731           0 :   if (!mGetFontFileDataSucceeded) {
    2732           0 :     return false;
    2733             :   }
    2734             : 
    2735           0 :   fontDetails.fontDataKey = mFontDetails.fontDataKey;
    2736           0 :   fontDetails.size = mFontDetails.size;
    2737           0 :   fontDetails.index = mFontDetails.index;
    2738           0 :   return true;
    2739             : }
    2740             : 
    2741             : template<class S>
    2742           0 : RecordedFontData::RecordedFontData(S &aStream)
    2743             :   : RecordedEventDerived(FONTDATA)
    2744             :   , mType(FontType::SKIA)
    2745           0 :   , mData(nullptr)
    2746             : {
    2747           0 :   ReadElement(aStream, mType);
    2748           0 :   ReadElement(aStream, mFontDetails.fontDataKey);
    2749           0 :   ReadElement(aStream, mFontDetails.size);
    2750           0 :   mData = new uint8_t[mFontDetails.size];
    2751           0 :   aStream.read((char*)mData, mFontDetails.size);
    2752           0 : }
    2753             : 
    2754             : inline
    2755           0 : RecordedFontDescriptor::~RecordedFontDescriptor()
    2756             : {
    2757           0 : }
    2758             : 
    2759             : inline bool
    2760           0 : RecordedFontDescriptor::PlayEvent(Translator *aTranslator) const
    2761             : {
    2762             :   RefPtr<UnscaledFont> font =
    2763           0 :     Factory::CreateUnscaledFontFromFontDescriptor(mType, mData.data(), mData.size());
    2764           0 :   if (!font) {
    2765           0 :     gfxDevCrash(LogReason::InvalidFont) <<
    2766           0 :       "Failed creating UnscaledFont of type " << int(mType) << " from font descriptor";
    2767           0 :     return false;
    2768             :   }
    2769             : 
    2770           0 :   aTranslator->AddUnscaledFont(mRefPtr, font);
    2771           0 :   return true;
    2772             : }
    2773             : 
    2774             : template<class S>
    2775             : void
    2776           0 : RecordedFontDescriptor::Record(S &aStream) const
    2777             : {
    2778           0 :   MOZ_ASSERT(mHasDesc);
    2779           0 :   WriteElement(aStream, mType);
    2780           0 :   WriteElement(aStream, mRefPtr);
    2781           0 :   WriteElement(aStream, (size_t)mData.size());
    2782           0 :   aStream.write((char*)mData.data(), mData.size());
    2783           0 : }
    2784             : 
    2785             : inline void
    2786           0 : RecordedFontDescriptor::OutputSimpleEventInfo(stringstream &aStringStream) const
    2787             : {
    2788           0 :   aStringStream << "[" << mRefPtr << "] Font Descriptor";
    2789           0 : }
    2790             : 
    2791             : inline void
    2792           0 : RecordedFontDescriptor::SetFontDescriptor(const uint8_t* aData, uint32_t aSize)
    2793             : {
    2794           0 :   mData.assign(aData, aData + aSize);
    2795           0 : }
    2796             : 
    2797             : template<class S>
    2798           0 : RecordedFontDescriptor::RecordedFontDescriptor(S &aStream)
    2799           0 :   : RecordedEventDerived(FONTDESC)
    2800             : {
    2801           0 :   ReadElement(aStream, mType);
    2802           0 :   ReadElement(aStream, mRefPtr);
    2803             : 
    2804             :   size_t size;
    2805           0 :   ReadElement(aStream, size);
    2806           0 :   mData.resize(size);
    2807           0 :   aStream.read((char*)mData.data(), size);
    2808           0 : }
    2809             : 
    2810             : inline bool
    2811           0 : RecordedUnscaledFontCreation::PlayEvent(Translator *aTranslator) const
    2812             : {
    2813           0 :   NativeFontResource *fontResource = aTranslator->LookupNativeFontResource(mFontDataKey);
    2814           0 :   if (!fontResource) {
    2815           0 :     gfxDevCrash(LogReason::NativeFontResourceNotFound) <<
    2816           0 :       "NativeFontResource lookup failed for key |" << hexa(mFontDataKey) << "|.";
    2817           0 :     return false;
    2818             :   }
    2819             : 
    2820             :   RefPtr<UnscaledFont> unscaledFont =
    2821           0 :     fontResource->CreateUnscaledFont(mIndex, mInstanceData.data(), mInstanceData.size());
    2822           0 :   aTranslator->AddUnscaledFont(mRefPtr, unscaledFont);
    2823           0 :   return true;
    2824             : }
    2825             : 
    2826             : template<class S>
    2827             : void
    2828           0 : RecordedUnscaledFontCreation::Record(S &aStream) const
    2829             : {
    2830           0 :   WriteElement(aStream, mRefPtr);
    2831           0 :   WriteElement(aStream, mFontDataKey);
    2832           0 :   WriteElement(aStream, mIndex);
    2833           0 :   WriteElement(aStream, (size_t)mInstanceData.size());
    2834           0 :   aStream.write((char*)mInstanceData.data(), mInstanceData.size());
    2835           0 : }
    2836             : 
    2837             : inline void
    2838           0 : RecordedUnscaledFontCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    2839             : {
    2840           0 :   aStringStream << "[" << mRefPtr << "] UnscaledFont Created";
    2841           0 : }
    2842             : 
    2843             : inline void
    2844           0 : RecordedUnscaledFontCreation::SetFontInstanceData(const uint8_t *aData, uint32_t aSize)
    2845             : {
    2846           0 :   mInstanceData.assign(aData, aData + aSize);
    2847           0 : }
    2848             : 
    2849             : template<class S>
    2850           0 : RecordedUnscaledFontCreation::RecordedUnscaledFontCreation(S &aStream)
    2851           0 :   : RecordedEventDerived(UNSCALEDFONTCREATION)
    2852             : {
    2853           0 :   ReadElement(aStream, mRefPtr);
    2854           0 :   ReadElement(aStream, mFontDataKey);
    2855           0 :   ReadElement(aStream, mIndex);
    2856             : 
    2857             :   size_t size;
    2858           0 :   ReadElement(aStream, size);
    2859           0 :   mInstanceData.resize(size);
    2860           0 :   aStream.read((char*)mInstanceData.data(), size);
    2861           0 : }
    2862             : 
    2863             : inline bool
    2864           0 : RecordedUnscaledFontDestruction::PlayEvent(Translator *aTranslator) const
    2865             : {
    2866           0 :   aTranslator->RemoveUnscaledFont(mRefPtr);
    2867           0 :   return true;
    2868             : }
    2869             : 
    2870             : template<class S>
    2871             : void
    2872           0 : RecordedUnscaledFontDestruction::Record(S &aStream) const
    2873             : {
    2874           0 :   WriteElement(aStream, mRefPtr);
    2875           0 : }
    2876             : 
    2877             : template<class S>
    2878           0 : RecordedUnscaledFontDestruction::RecordedUnscaledFontDestruction(S &aStream)
    2879           0 :   : RecordedEventDerived(UNSCALEDFONTDESTRUCTION)
    2880             : {
    2881           0 :   ReadElement(aStream, mRefPtr);
    2882           0 : }
    2883             : 
    2884             : inline void
    2885           0 : RecordedUnscaledFontDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    2886             : {
    2887           0 :   aStringStream << "[" << mRefPtr << "] UnscaledFont Destroyed";
    2888           0 : }
    2889             : 
    2890             : inline bool
    2891           0 : RecordedScaledFontCreation::PlayEvent(Translator *aTranslator) const
    2892             : {
    2893           0 :   UnscaledFont* unscaledFont = aTranslator->LookupUnscaledFont(mUnscaledFont);
    2894           0 :   if (!unscaledFont) {
    2895           0 :     gfxDevCrash(LogReason::UnscaledFontNotFound) <<
    2896           0 :       "UnscaledFont lookup failed for key |" << hexa(mUnscaledFont) << "|.";
    2897           0 :     return false;
    2898             :   }
    2899             : 
    2900             :   RefPtr<ScaledFont> scaledFont =
    2901           0 :     unscaledFont->CreateScaledFont(mGlyphSize, mInstanceData.data(), mInstanceData.size());
    2902           0 :   aTranslator->AddScaledFont(mRefPtr, scaledFont);
    2903           0 :   return true;
    2904             : }
    2905             : 
    2906             : template<class S>
    2907             : void
    2908           0 : RecordedScaledFontCreation::Record(S &aStream) const
    2909             : {
    2910           0 :   WriteElement(aStream, mRefPtr);
    2911           0 :   WriteElement(aStream, mUnscaledFont);
    2912           0 :   WriteElement(aStream, mGlyphSize);
    2913           0 :   WriteElement(aStream, (size_t)mInstanceData.size());
    2914           0 :   aStream.write((char*)mInstanceData.data(), mInstanceData.size());
    2915           0 : }
    2916             : 
    2917             : inline void
    2918           0 : RecordedScaledFontCreation::OutputSimpleEventInfo(stringstream &aStringStream) const
    2919             : {
    2920           0 :   aStringStream << "[" << mRefPtr << "] ScaledFont Created";
    2921           0 : }
    2922             : 
    2923             : inline void
    2924           0 : RecordedScaledFontCreation::SetFontInstanceData(const uint8_t *aData, uint32_t aSize)
    2925             : {
    2926           0 :   mInstanceData.assign(aData, aData + aSize);
    2927           0 : }
    2928             : 
    2929             : template<class S>
    2930           0 : RecordedScaledFontCreation::RecordedScaledFontCreation(S &aStream)
    2931           0 :   : RecordedEventDerived(SCALEDFONTCREATION)
    2932             : {
    2933           0 :   ReadElement(aStream, mRefPtr);
    2934           0 :   ReadElement(aStream, mUnscaledFont);
    2935           0 :   ReadElement(aStream, mGlyphSize);
    2936             : 
    2937             :   size_t size;
    2938           0 :   ReadElement(aStream, size);
    2939           0 :   mInstanceData.resize(size);
    2940           0 :   aStream.read((char*)mInstanceData.data(), size);
    2941           0 : }
    2942             : 
    2943             : inline bool
    2944           0 : RecordedScaledFontDestruction::PlayEvent(Translator *aTranslator) const
    2945             : {
    2946           0 :   aTranslator->RemoveScaledFont(mRefPtr);
    2947           0 :   return true;
    2948             : }
    2949             : 
    2950             : template<class S>
    2951             : void
    2952           0 : RecordedScaledFontDestruction::Record(S &aStream) const
    2953             : {
    2954           0 :   WriteElement(aStream, mRefPtr);
    2955           0 : }
    2956             : 
    2957             : template<class S>
    2958           0 : RecordedScaledFontDestruction::RecordedScaledFontDestruction(S &aStream)
    2959           0 :   : RecordedEventDerived(SCALEDFONTDESTRUCTION)
    2960             : {
    2961           0 :   ReadElement(aStream, mRefPtr);
    2962           0 : }
    2963             : 
    2964             : inline void
    2965           0 : RecordedScaledFontDestruction::OutputSimpleEventInfo(stringstream &aStringStream) const
    2966             : {
    2967           0 :   aStringStream << "[" << mRefPtr << "] ScaledFont Destroyed";
    2968           0 : }
    2969             : 
    2970             : inline bool
    2971           0 : RecordedMaskSurface::PlayEvent(Translator *aTranslator) const
    2972             : {
    2973           0 :   aTranslator->LookupDrawTarget(mDT)->
    2974           0 :     MaskSurface(*GenericPattern(mPattern, aTranslator),
    2975           0 :                 aTranslator->LookupSourceSurface(mRefMask),
    2976           0 :                 mOffset, mOptions);
    2977           0 :   return true;
    2978             : }
    2979             : 
    2980             : template<class S>
    2981             : void
    2982           0 : RecordedMaskSurface::Record(S &aStream) const
    2983             : {
    2984           0 :   RecordedDrawingEvent::Record(aStream);
    2985           0 :   RecordPatternData(aStream, mPattern);
    2986           0 :   WriteElement(aStream, mRefMask);
    2987           0 :   WriteElement(aStream, mOffset);
    2988           0 :   WriteElement(aStream, mOptions);
    2989           0 : }
    2990             : 
    2991             : template<class S>
    2992           0 : RecordedMaskSurface::RecordedMaskSurface(S &aStream)
    2993           0 :   : RecordedDrawingEvent(MASKSURFACE, aStream)
    2994             : {
    2995           0 :   ReadPatternData(aStream, mPattern);
    2996           0 :   ReadElement(aStream, mRefMask);
    2997           0 :   ReadElement(aStream, mOffset);
    2998           0 :   ReadElement(aStream, mOptions);
    2999           0 : }
    3000             : 
    3001             : inline void
    3002           0 : RecordedMaskSurface::OutputSimpleEventInfo(stringstream &aStringStream) const
    3003             : {
    3004           0 :   aStringStream << "[" << mDT << "] MaskSurface (" << mRefMask << ")  Offset: (" << mOffset.x << "x" << mOffset.y << ") Pattern: ";
    3005           0 :   OutputSimplePatternInfo(mPattern, aStringStream);
    3006           0 : }
    3007             : 
    3008             : template<typename T>
    3009             : void
    3010           0 : ReplaySetAttribute(FilterNode *aNode, uint32_t aIndex, T aValue)
    3011             : {
    3012           0 :   aNode->SetAttribute(aIndex, aValue);
    3013           0 : }
    3014             : 
    3015             : inline bool
    3016           0 : RecordedFilterNodeSetAttribute::PlayEvent(Translator *aTranslator) const
    3017             : {
    3018             : #define REPLAY_SET_ATTRIBUTE(type, argtype) \
    3019             :   case ARGTYPE_##argtype: \
    3020             :   ReplaySetAttribute(aTranslator->LookupFilterNode(mNode), mIndex, *(type*)&mPayload.front()); \
    3021             :   break
    3022             : 
    3023           0 :   switch (mArgType) {
    3024           0 :     REPLAY_SET_ATTRIBUTE(bool, BOOL);
    3025           0 :     REPLAY_SET_ATTRIBUTE(uint32_t, UINT32);
    3026           0 :     REPLAY_SET_ATTRIBUTE(Float, FLOAT);
    3027           0 :     REPLAY_SET_ATTRIBUTE(Size, SIZE);
    3028           0 :     REPLAY_SET_ATTRIBUTE(IntSize, INTSIZE);
    3029           0 :     REPLAY_SET_ATTRIBUTE(IntPoint, INTPOINT);
    3030           0 :     REPLAY_SET_ATTRIBUTE(Rect, RECT);
    3031           0 :     REPLAY_SET_ATTRIBUTE(IntRect, INTRECT);
    3032           0 :     REPLAY_SET_ATTRIBUTE(Point, POINT);
    3033           0 :     REPLAY_SET_ATTRIBUTE(Matrix, MATRIX);
    3034           0 :     REPLAY_SET_ATTRIBUTE(Matrix5x4, MATRIX5X4);
    3035           0 :     REPLAY_SET_ATTRIBUTE(Point3D, POINT3D);
    3036           0 :     REPLAY_SET_ATTRIBUTE(Color, COLOR);
    3037             :   case ARGTYPE_FLOAT_ARRAY:
    3038           0 :     aTranslator->LookupFilterNode(mNode)->SetAttribute(
    3039           0 :       mIndex,
    3040           0 :       reinterpret_cast<const Float*>(&mPayload.front()),
    3041           0 :       mPayload.size() / sizeof(Float));
    3042           0 :     break;
    3043             :   }
    3044             : 
    3045           0 :   return true;
    3046             : }
    3047             : 
    3048             : template<class S>
    3049             : void
    3050           0 : RecordedFilterNodeSetAttribute::Record(S &aStream) const
    3051             : {
    3052           0 :   WriteElement(aStream, mNode);
    3053           0 :   WriteElement(aStream, mIndex);
    3054           0 :   WriteElement(aStream, mArgType);
    3055           0 :   WriteElement(aStream, uint64_t(mPayload.size()));
    3056           0 :   aStream.write((const char*)&mPayload.front(), mPayload.size());
    3057           0 : }
    3058             : 
    3059             : template<class S>
    3060           0 : RecordedFilterNodeSetAttribute::RecordedFilterNodeSetAttribute(S &aStream)
    3061           0 :   : RecordedEventDerived(FILTERNODESETATTRIBUTE)
    3062             : {
    3063           0 :   ReadElement(aStream, mNode);
    3064           0 :   ReadElement(aStream, mIndex);
    3065           0 :   ReadElement(aStream, mArgType);
    3066             :   uint64_t size;
    3067           0 :   ReadElement(aStream, size);
    3068           0 :   mPayload.resize(size_t(size));
    3069           0 :   aStream.read((char*)&mPayload.front(), size);
    3070           0 : }
    3071             : 
    3072             : inline void
    3073           0 : RecordedFilterNodeSetAttribute::OutputSimpleEventInfo(stringstream &aStringStream) const
    3074             : {
    3075           0 :   aStringStream << "[" << mNode << "] SetAttribute (" << mIndex << ")";
    3076           0 : }
    3077             : 
    3078             : inline bool
    3079           0 : RecordedFilterNodeSetInput::PlayEvent(Translator *aTranslator) const
    3080             : {
    3081           0 :   if (mInputFilter) {
    3082           0 :     aTranslator->LookupFilterNode(mNode)->SetInput(
    3083           0 :       mIndex, aTranslator->LookupFilterNode(mInputFilter));
    3084             :   } else {
    3085           0 :     aTranslator->LookupFilterNode(mNode)->SetInput(
    3086           0 :       mIndex, aTranslator->LookupSourceSurface(mInputSurface));
    3087             :   }
    3088             : 
    3089           0 :   return true;
    3090             : }
    3091             : 
    3092             : template<class S>
    3093             : void
    3094           0 : RecordedFilterNodeSetInput::Record(S &aStream) const
    3095             : {
    3096           0 :   WriteElement(aStream, mNode);
    3097           0 :   WriteElement(aStream, mIndex);
    3098           0 :   WriteElement(aStream, mInputFilter);
    3099           0 :   WriteElement(aStream, mInputSurface);
    3100           0 : }
    3101             : 
    3102             : template<class S>
    3103           0 : RecordedFilterNodeSetInput::RecordedFilterNodeSetInput(S &aStream)
    3104           0 :   : RecordedEventDerived(FILTERNODESETINPUT)
    3105             : {
    3106           0 :   ReadElement(aStream, mNode);
    3107           0 :   ReadElement(aStream, mIndex);
    3108           0 :   ReadElement(aStream, mInputFilter);
    3109           0 :   ReadElement(aStream, mInputSurface);
    3110           0 : }
    3111             : 
    3112             : inline void
    3113           0 : RecordedFilterNodeSetInput::OutputSimpleEventInfo(stringstream &aStringStream) const
    3114             : {
    3115           0 :   aStringStream << "[" << mNode << "] SetAttribute (" << mIndex << ", ";
    3116             : 
    3117           0 :   if (mInputFilter) {
    3118           0 :     aStringStream << "Filter: " << mInputFilter;
    3119             :   } else {
    3120           0 :     aStringStream << "Surface: " << mInputSurface;
    3121             :   }
    3122             : 
    3123           0 :   aStringStream << ")";
    3124           0 : }
    3125             : 
    3126             : #define LOAD_EVENT_TYPE(_typeenum, _class) \
    3127             :   case _typeenum: return new _class(aStream)
    3128             : 
    3129             : template<class S>
    3130             : RecordedEvent *
    3131           0 : RecordedEvent::LoadEvent(S &aStream, EventType aType)
    3132             : {
    3133           0 :   switch (aType) {
    3134           0 :     LOAD_EVENT_TYPE(DRAWTARGETCREATION, RecordedDrawTargetCreation);
    3135           0 :     LOAD_EVENT_TYPE(DRAWTARGETDESTRUCTION, RecordedDrawTargetDestruction);
    3136           0 :     LOAD_EVENT_TYPE(FILLRECT, RecordedFillRect);
    3137           0 :     LOAD_EVENT_TYPE(STROKERECT, RecordedStrokeRect);
    3138           0 :     LOAD_EVENT_TYPE(STROKELINE, RecordedStrokeLine);
    3139           0 :     LOAD_EVENT_TYPE(CLEARRECT, RecordedClearRect);
    3140           0 :     LOAD_EVENT_TYPE(COPYSURFACE, RecordedCopySurface);
    3141           0 :     LOAD_EVENT_TYPE(SETTRANSFORM, RecordedSetTransform);
    3142           0 :     LOAD_EVENT_TYPE(PUSHCLIPRECT, RecordedPushClipRect);
    3143           0 :     LOAD_EVENT_TYPE(PUSHCLIP, RecordedPushClip);
    3144           0 :     LOAD_EVENT_TYPE(POPCLIP, RecordedPopClip);
    3145           0 :     LOAD_EVENT_TYPE(FILL, RecordedFill);
    3146           0 :     LOAD_EVENT_TYPE(FILLGLYPHS, RecordedFillGlyphs);
    3147           0 :     LOAD_EVENT_TYPE(MASK, RecordedMask);
    3148           0 :     LOAD_EVENT_TYPE(STROKE, RecordedStroke);
    3149           0 :     LOAD_EVENT_TYPE(DRAWSURFACE, RecordedDrawSurface);
    3150           0 :     LOAD_EVENT_TYPE(DRAWSURFACEWITHSHADOW, RecordedDrawSurfaceWithShadow);
    3151           0 :     LOAD_EVENT_TYPE(DRAWFILTER, RecordedDrawFilter);
    3152           0 :     LOAD_EVENT_TYPE(PATHCREATION, RecordedPathCreation);
    3153           0 :     LOAD_EVENT_TYPE(PATHDESTRUCTION, RecordedPathDestruction);
    3154           0 :     LOAD_EVENT_TYPE(SOURCESURFACECREATION, RecordedSourceSurfaceCreation);
    3155           0 :     LOAD_EVENT_TYPE(SOURCESURFACEDESTRUCTION, RecordedSourceSurfaceDestruction);
    3156           0 :     LOAD_EVENT_TYPE(FILTERNODECREATION, RecordedFilterNodeCreation);
    3157           0 :     LOAD_EVENT_TYPE(FILTERNODEDESTRUCTION, RecordedFilterNodeDestruction);
    3158           0 :     LOAD_EVENT_TYPE(GRADIENTSTOPSCREATION, RecordedGradientStopsCreation);
    3159           0 :     LOAD_EVENT_TYPE(GRADIENTSTOPSDESTRUCTION, RecordedGradientStopsDestruction);
    3160           0 :     LOAD_EVENT_TYPE(SNAPSHOT, RecordedSnapshot);
    3161           0 :     LOAD_EVENT_TYPE(SCALEDFONTCREATION, RecordedScaledFontCreation);
    3162           0 :     LOAD_EVENT_TYPE(SCALEDFONTDESTRUCTION, RecordedScaledFontDestruction);
    3163           0 :     LOAD_EVENT_TYPE(MASKSURFACE, RecordedMaskSurface);
    3164           0 :     LOAD_EVENT_TYPE(FILTERNODESETATTRIBUTE, RecordedFilterNodeSetAttribute);
    3165           0 :     LOAD_EVENT_TYPE(FILTERNODESETINPUT, RecordedFilterNodeSetInput);
    3166           0 :     LOAD_EVENT_TYPE(CREATESIMILARDRAWTARGET, RecordedCreateSimilarDrawTarget);
    3167           0 :     LOAD_EVENT_TYPE(FONTDATA, RecordedFontData);
    3168           0 :     LOAD_EVENT_TYPE(FONTDESC, RecordedFontDescriptor);
    3169           0 :     LOAD_EVENT_TYPE(PUSHLAYER, RecordedPushLayer);
    3170           0 :     LOAD_EVENT_TYPE(POPLAYER, RecordedPopLayer);
    3171           0 :     LOAD_EVENT_TYPE(UNSCALEDFONTCREATION, RecordedUnscaledFontCreation);
    3172           0 :     LOAD_EVENT_TYPE(UNSCALEDFONTDESTRUCTION, RecordedUnscaledFontDestruction);
    3173             :   default:
    3174           0 :     return nullptr;
    3175             :   }
    3176             : }
    3177             : 
    3178             : 
    3179             : } // namespace gfx
    3180             : } // namespace mozilla
    3181             : 
    3182             : #endif

Generated by: LCOV version 1.13