gfx/2d/RecordedEvent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/RecordedEvent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1079 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_GFX_RECORDEDEVENT_H_
    1.10 +#define MOZILLA_GFX_RECORDEDEVENT_H_
    1.11 +
    1.12 +#include "2D.h"
    1.13 +#include <ostream>
    1.14 +#include <sstream>
    1.15 +#include <cstring>
    1.16 +#include "RecordingTypes.h"
    1.17 +#include "PathRecording.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace gfx {
    1.21 +
    1.22 +// A change in major revision means a change in event binary format, causing
    1.23 +// loss of backwards compatibility. Old streams will not work in a player
    1.24 +// using a newer major revision. And new streams will not work in a player
    1.25 +// using an older major revision.
    1.26 +const uint16_t kMajorRevision = 3;
    1.27 +// A change in minor revision means additions of new events. New streams will
    1.28 +// not play in older players.
    1.29 +const uint16_t kMinorRevision = 2;
    1.30 +
    1.31 +struct ReferencePtr
    1.32 +{
    1.33 +  ReferencePtr()
    1.34 +    : mLongPtr(0)
    1.35 +  {}
    1.36 +
    1.37 +  ReferencePtr(const void* aLongPtr)
    1.38 +    : mLongPtr(uint64_t(aLongPtr))
    1.39 +  {}
    1.40 +
    1.41 +  template <typename T>
    1.42 +  ReferencePtr(const RefPtr<T>& aPtr)
    1.43 +    : mLongPtr(uint64_t(aPtr.get()))
    1.44 +  {}
    1.45 +
    1.46 +  ReferencePtr &operator =(const void* aLongPtr) {
    1.47 +    mLongPtr = uint64_t(aLongPtr);
    1.48 +    return *this;
    1.49 +  }
    1.50 +
    1.51 +  template <typename T>
    1.52 +  ReferencePtr &operator =(const RefPtr<T>& aPtr) {
    1.53 +    mLongPtr = uint64_t(aPtr.get());
    1.54 +    return *this;
    1.55 +  }
    1.56 +
    1.57 +  operator void*() const {
    1.58 +    return (void*)mLongPtr;
    1.59 +  }
    1.60 +
    1.61 +  uint64_t mLongPtr;
    1.62 +};
    1.63 +
    1.64 +// Used by the Azure drawing debugger (player2d)
    1.65 +inline std::string StringFromPtr(ReferencePtr aPtr)
    1.66 +{
    1.67 +  std::stringstream stream;
    1.68 +  stream << aPtr;
    1.69 +  return stream.str();
    1.70 +}
    1.71 +
    1.72 +class Translator
    1.73 +{
    1.74 +public:
    1.75 +  virtual ~Translator() {}
    1.76 +
    1.77 +  virtual DrawTarget *LookupDrawTarget(ReferencePtr aRefPtr) = 0;
    1.78 +  virtual Path *LookupPath(ReferencePtr aRefPtr) = 0;
    1.79 +  virtual SourceSurface *LookupSourceSurface(ReferencePtr aRefPtr) = 0;
    1.80 +  virtual FilterNode *LookupFilterNode(ReferencePtr aRefPtr) = 0;
    1.81 +  virtual GradientStops *LookupGradientStops(ReferencePtr aRefPtr) = 0;
    1.82 +  virtual ScaledFont *LookupScaledFont(ReferencePtr aRefPtr) = 0;
    1.83 +  virtual void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget *aDT) = 0;
    1.84 +  virtual void RemoveDrawTarget(ReferencePtr aRefPtr) = 0;
    1.85 +  virtual void AddPath(ReferencePtr aRefPtr, Path *aPath) = 0;
    1.86 +  virtual void RemovePath(ReferencePtr aRefPtr) = 0;
    1.87 +  virtual void AddSourceSurface(ReferencePtr aRefPtr, SourceSurface *aPath) = 0;
    1.88 +  virtual void RemoveSourceSurface(ReferencePtr aRefPtr) = 0;
    1.89 +  virtual void AddFilterNode(mozilla::gfx::ReferencePtr aRefPtr, FilterNode *aSurface) = 0;
    1.90 +  virtual void RemoveFilterNode(mozilla::gfx::ReferencePtr aRefPtr) = 0;
    1.91 +  virtual void AddGradientStops(ReferencePtr aRefPtr, GradientStops *aPath) = 0;
    1.92 +  virtual void RemoveGradientStops(ReferencePtr aRefPtr) = 0;
    1.93 +  virtual void AddScaledFont(ReferencePtr aRefPtr, ScaledFont *aScaledFont) = 0;
    1.94 +  virtual void RemoveScaledFont(ReferencePtr aRefPtr) = 0;
    1.95 +
    1.96 +  virtual DrawTarget *GetReferenceDrawTarget() = 0;
    1.97 +  virtual FontType GetDesiredFontType() = 0;
    1.98 +};
    1.99 +
   1.100 +struct ColorPatternStorage
   1.101 +{
   1.102 +  Color mColor;
   1.103 +};
   1.104 +
   1.105 +struct LinearGradientPatternStorage
   1.106 +{
   1.107 +  Point mBegin;
   1.108 +  Point mEnd;
   1.109 +  ReferencePtr mStops;
   1.110 +  Matrix mMatrix;
   1.111 +};
   1.112 +
   1.113 +struct RadialGradientPatternStorage
   1.114 +{
   1.115 +  Point mCenter1;
   1.116 +  Point mCenter2;
   1.117 +  Float mRadius1;
   1.118 +  Float mRadius2;
   1.119 +  ReferencePtr mStops;
   1.120 +  Matrix mMatrix;
   1.121 +};
   1.122 +
   1.123 +struct SurfacePatternStorage
   1.124 +{
   1.125 +  ExtendMode mExtend;
   1.126 +  Filter mFilter;
   1.127 +  ReferencePtr mSurface;
   1.128 +  Matrix mMatrix;
   1.129 +};
   1.130 +
   1.131 +struct PatternStorage
   1.132 +{
   1.133 +  PatternType mType;
   1.134 +  union {
   1.135 +    char *mStorage;
   1.136 +    char mColor[sizeof(ColorPatternStorage)];
   1.137 +    char mLinear[sizeof(LinearGradientPatternStorage)];
   1.138 +    char mRadial[sizeof(RadialGradientPatternStorage)];
   1.139 +    char mSurface[sizeof(SurfacePatternStorage)];
   1.140 +  };
   1.141 +};
   1.142 +
   1.143 +class RecordedEvent {
   1.144 +public:
   1.145 +  enum EventType {
   1.146 +    DRAWTARGETCREATION = 0,
   1.147 +    DRAWTARGETDESTRUCTION,
   1.148 +    FILLRECT,
   1.149 +    STROKERECT,
   1.150 +    STROKELINE,
   1.151 +    CLEARRECT,
   1.152 +    COPYSURFACE,
   1.153 +    SETTRANSFORM,
   1.154 +    PUSHCLIP,
   1.155 +    PUSHCLIPRECT,
   1.156 +    POPCLIP,
   1.157 +    FILL,
   1.158 +    FILLGLYPHS,
   1.159 +    MASK,
   1.160 +    STROKE,
   1.161 +    DRAWSURFACE,
   1.162 +    DRAWSURFACEWITHSHADOW,
   1.163 +    PATHCREATION,
   1.164 +    PATHDESTRUCTION,
   1.165 +    SOURCESURFACECREATION,
   1.166 +    SOURCESURFACEDESTRUCTION,
   1.167 +    GRADIENTSTOPSCREATION,
   1.168 +    GRADIENTSTOPSDESTRUCTION,
   1.169 +    SNAPSHOT,
   1.170 +    SCALEDFONTCREATION,
   1.171 +    SCALEDFONTDESTRUCTION,
   1.172 +    MASKSURFACE,
   1.173 +    FILTERNODECREATION,
   1.174 +    FILTERNODEDESTRUCTION,
   1.175 +    DRAWFILTER,
   1.176 +    FILTERNODESETATTRIBUTE,
   1.177 +    FILTERNODESETINPUT
   1.178 +  };
   1.179 +  static const uint32_t kTotalEventTypes = RecordedEvent::FILTERNODESETINPUT + 1;
   1.180 +
   1.181 +  static std::string GetEventName(EventType aType);
   1.182 +
   1.183 +  virtual void PlayEvent(Translator *aTranslator) const {}
   1.184 +
   1.185 +  virtual void RecordToStream(std::ostream &aStream) const {}
   1.186 +
   1.187 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const { }
   1.188 +
   1.189 +  void RecordPatternData(std::ostream &aStream, const PatternStorage &aPatternStorage) const;
   1.190 +  void ReadPatternData(std::istream &aStream, PatternStorage &aPatternStorage) const;
   1.191 +  void StorePattern(PatternStorage &aDestination, const Pattern &aSource) const;
   1.192 +  void RecordStrokeOptions(std::ostream &aStream, const StrokeOptions &aStrokeOptions) const;
   1.193 +  void ReadStrokeOptions(std::istream &aStream, StrokeOptions &aStrokeOptions);
   1.194 +
   1.195 +  virtual std::string GetName() const = 0;
   1.196 +
   1.197 +  virtual ReferencePtr GetObjectRef() const = 0;
   1.198 +
   1.199 +  virtual ReferencePtr GetDestinedDT() { return nullptr; }
   1.200 +
   1.201 +  void OutputSimplePatternInfo(const PatternStorage &aStorage, std::stringstream &aOutput) const;
   1.202 +
   1.203 +  static RecordedEvent *LoadEventFromStream(std::istream &aStream, EventType aType);
   1.204 +
   1.205 +  EventType GetType() { return (EventType)mType; }
   1.206 +protected:
   1.207 +  friend class DrawEventRecorderPrivate;
   1.208 +
   1.209 +  RecordedEvent(int32_t aType) : mType(aType)
   1.210 +  {}
   1.211 +
   1.212 +  int32_t mType;
   1.213 +  std::vector<Float> mDashPatternStorage;
   1.214 +};
   1.215 +
   1.216 +class RecordedDrawingEvent : public RecordedEvent
   1.217 +{
   1.218 +public:
   1.219 +   virtual ReferencePtr GetDestinedDT() { return mDT; }
   1.220 +
   1.221 +protected:
   1.222 +  RecordedDrawingEvent(EventType aType, DrawTarget *aTarget)
   1.223 +    : RecordedEvent(aType), mDT(aTarget)
   1.224 +  {
   1.225 +  }
   1.226 +
   1.227 +  RecordedDrawingEvent(EventType aType, std::istream &aStream);
   1.228 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.229 +
   1.230 +  virtual ReferencePtr GetObjectRef() const;
   1.231 +
   1.232 +  ReferencePtr mDT;
   1.233 +};
   1.234 +
   1.235 +class RecordedDrawTargetCreation : public RecordedEvent {
   1.236 +public:
   1.237 +  RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType, const IntSize &aSize, SurfaceFormat aFormat,
   1.238 +                             bool aHasExistingData = false, SourceSurface *aExistingData = nullptr)
   1.239 +    : RecordedEvent(DRAWTARGETCREATION), mRefPtr(aRefPtr), mBackendType(aType), mSize(aSize), mFormat(aFormat)
   1.240 +    , mHasExistingData(aHasExistingData), mExistingData(aExistingData)
   1.241 +  {}
   1.242 +
   1.243 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.244 +
   1.245 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.246 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.247 +
   1.248 +  virtual std::string GetName() const { return "DrawTarget Creation"; }
   1.249 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.250 +
   1.251 +  ReferencePtr mRefPtr;
   1.252 +  BackendType mBackendType;
   1.253 +  IntSize mSize;
   1.254 +  SurfaceFormat mFormat;
   1.255 +  bool mHasExistingData;
   1.256 +  RefPtr<SourceSurface> mExistingData;
   1.257 +  
   1.258 +private:
   1.259 +  friend class RecordedEvent;
   1.260 +
   1.261 +  RecordedDrawTargetCreation(std::istream &aStream);
   1.262 +};
   1.263 +
   1.264 +class RecordedDrawTargetDestruction : public RecordedEvent {
   1.265 +public:
   1.266 +  RecordedDrawTargetDestruction(ReferencePtr aRefPtr)
   1.267 +    : RecordedEvent(DRAWTARGETDESTRUCTION), mRefPtr(aRefPtr)
   1.268 +  {}
   1.269 +
   1.270 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.271 +
   1.272 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.273 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.274 +
   1.275 +  virtual std::string GetName() const { return "DrawTarget Destruction"; }
   1.276 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.277 +
   1.278 +  ReferencePtr mRefPtr;
   1.279 +
   1.280 +  BackendType mBackendType;
   1.281 +private:
   1.282 +  friend class RecordedEvent;
   1.283 +
   1.284 +  RecordedDrawTargetDestruction(std::istream &aStream);
   1.285 +};
   1.286 +
   1.287 +class RecordedFillRect : public RecordedDrawingEvent {
   1.288 +public:
   1.289 +  RecordedFillRect(DrawTarget *aDT, const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions)
   1.290 +    : RecordedDrawingEvent(FILLRECT, aDT), mRect(aRect), mOptions(aOptions)
   1.291 +  {
   1.292 +    StorePattern(mPattern, aPattern);
   1.293 +  }
   1.294 +
   1.295 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.296 +
   1.297 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.298 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.299 +
   1.300 +  virtual std::string GetName() const { return "FillRect"; }
   1.301 +private:
   1.302 +  friend class RecordedEvent;
   1.303 +
   1.304 +  RecordedFillRect(std::istream &aStream);
   1.305 +
   1.306 +  Rect mRect;
   1.307 +  PatternStorage mPattern;
   1.308 +  DrawOptions mOptions;
   1.309 +};
   1.310 +
   1.311 +class RecordedStrokeRect : public RecordedDrawingEvent {
   1.312 +public:
   1.313 +  RecordedStrokeRect(DrawTarget *aDT, const Rect &aRect, const Pattern &aPattern,
   1.314 +                     const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
   1.315 +    : RecordedDrawingEvent(STROKERECT, aDT), mRect(aRect),
   1.316 +      mStrokeOptions(aStrokeOptions), mOptions(aOptions)
   1.317 +  {
   1.318 +    StorePattern(mPattern, aPattern);
   1.319 +  }
   1.320 +
   1.321 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.322 +
   1.323 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.324 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.325 +
   1.326 +  virtual std::string GetName() const { return "StrokeRect"; }
   1.327 +private:
   1.328 +  friend class RecordedEvent;
   1.329 +
   1.330 +  RecordedStrokeRect(std::istream &aStream);
   1.331 +
   1.332 +  Rect mRect;
   1.333 +  PatternStorage mPattern;
   1.334 +  StrokeOptions mStrokeOptions;
   1.335 +  DrawOptions mOptions;
   1.336 +};
   1.337 +
   1.338 +class RecordedStrokeLine : public RecordedDrawingEvent {
   1.339 +public:
   1.340 +  RecordedStrokeLine(DrawTarget *aDT, const Point &aBegin, const Point &aEnd,
   1.341 +                     const Pattern &aPattern, const StrokeOptions &aStrokeOptions,
   1.342 +                     const DrawOptions &aOptions)
   1.343 +    : RecordedDrawingEvent(STROKELINE, aDT), mBegin(aBegin), mEnd(aEnd),
   1.344 +      mStrokeOptions(aStrokeOptions), mOptions(aOptions)
   1.345 +  {
   1.346 +    StorePattern(mPattern, aPattern);
   1.347 +  }
   1.348 +
   1.349 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.350 +
   1.351 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.352 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.353 +
   1.354 +  virtual std::string GetName() const { return "StrokeLine"; }
   1.355 +private:
   1.356 +  friend class RecordedEvent;
   1.357 +
   1.358 +  RecordedStrokeLine(std::istream &aStream);
   1.359 +
   1.360 +  Point mBegin;
   1.361 +  Point mEnd;
   1.362 +  PatternStorage mPattern;
   1.363 +  StrokeOptions mStrokeOptions;
   1.364 +  DrawOptions mOptions;
   1.365 +};
   1.366 +
   1.367 +class RecordedFill : public RecordedDrawingEvent {
   1.368 +public:
   1.369 +  RecordedFill(DrawTarget *aDT, ReferencePtr aPath, const Pattern &aPattern, const DrawOptions &aOptions)
   1.370 +    : RecordedDrawingEvent(FILL, aDT), mPath(aPath), mOptions(aOptions)
   1.371 +  {
   1.372 +    StorePattern(mPattern, aPattern);
   1.373 +  }
   1.374 +
   1.375 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.376 +
   1.377 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.378 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.379 +
   1.380 +  virtual std::string GetName() const { return "Fill"; }
   1.381 +private:
   1.382 +  friend class RecordedEvent;
   1.383 +
   1.384 +  RecordedFill(std::istream &aStream);
   1.385 +
   1.386 +  ReferencePtr mPath;
   1.387 +  PatternStorage mPattern;
   1.388 +  DrawOptions mOptions;
   1.389 +};
   1.390 +
   1.391 +class RecordedFillGlyphs : public RecordedDrawingEvent {
   1.392 +public:
   1.393 +  RecordedFillGlyphs(DrawTarget *aDT, ReferencePtr aScaledFont, const Pattern &aPattern, const DrawOptions &aOptions,
   1.394 +                     const Glyph *aGlyphs, uint32_t aNumGlyphs)
   1.395 +    : RecordedDrawingEvent(FILLGLYPHS, aDT), mScaledFont(aScaledFont), mOptions(aOptions)
   1.396 +  {
   1.397 +    StorePattern(mPattern, aPattern);
   1.398 +    mNumGlyphs = aNumGlyphs;
   1.399 +    mGlyphs = new Glyph[aNumGlyphs];
   1.400 +    memcpy(mGlyphs, aGlyphs, sizeof(Glyph) * aNumGlyphs);
   1.401 +  }
   1.402 +  virtual ~RecordedFillGlyphs();
   1.403 +
   1.404 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.405 +
   1.406 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.407 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.408 +
   1.409 +  virtual std::string GetName() const { return "FillGlyphs"; }
   1.410 +private:
   1.411 +  friend class RecordedEvent;
   1.412 +
   1.413 +  RecordedFillGlyphs(std::istream &aStream);
   1.414 +
   1.415 +  ReferencePtr mScaledFont;
   1.416 +  PatternStorage mPattern;
   1.417 +  DrawOptions mOptions;
   1.418 +  Glyph *mGlyphs;
   1.419 +  uint32_t mNumGlyphs;
   1.420 +};
   1.421 +
   1.422 +class RecordedMask : public RecordedDrawingEvent {
   1.423 +public:
   1.424 +  RecordedMask(DrawTarget *aDT, const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions)
   1.425 +    : RecordedDrawingEvent(MASK, aDT), mOptions(aOptions)
   1.426 +  {
   1.427 +    StorePattern(mSource, aSource);
   1.428 +    StorePattern(mMask, aMask);
   1.429 +  }
   1.430 +
   1.431 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.432 +
   1.433 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.434 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.435 +
   1.436 +  virtual std::string GetName() const { return "Mask"; }
   1.437 +private:
   1.438 +  friend class RecordedEvent;
   1.439 +
   1.440 +  RecordedMask(std::istream &aStream);
   1.441 +
   1.442 +  PatternStorage mSource;
   1.443 +  PatternStorage mMask;
   1.444 +  DrawOptions mOptions;
   1.445 +};
   1.446 +
   1.447 +class RecordedStroke : public RecordedDrawingEvent {
   1.448 +public:
   1.449 +  RecordedStroke(DrawTarget *aDT, ReferencePtr aPath, const Pattern &aPattern,
   1.450 +                     const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
   1.451 +    : RecordedDrawingEvent(STROKE, aDT), mPath(aPath),
   1.452 +      mStrokeOptions(aStrokeOptions), mOptions(aOptions)
   1.453 +  {
   1.454 +    StorePattern(mPattern, aPattern);
   1.455 +  }
   1.456 +
   1.457 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.458 +
   1.459 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.460 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.461 +
   1.462 +  virtual std::string GetName() const { return "Stroke"; }
   1.463 +private:
   1.464 +  friend class RecordedEvent;
   1.465 +
   1.466 +  RecordedStroke(std::istream &aStream);
   1.467 +
   1.468 +  ReferencePtr mPath;
   1.469 +  PatternStorage mPattern;
   1.470 +  StrokeOptions mStrokeOptions;
   1.471 +  DrawOptions mOptions;
   1.472 +};
   1.473 +
   1.474 +class RecordedClearRect : public RecordedDrawingEvent {
   1.475 +public:
   1.476 +  RecordedClearRect(DrawTarget *aDT, const Rect &aRect)
   1.477 +    : RecordedDrawingEvent(CLEARRECT, aDT), mRect(aRect)
   1.478 +  {
   1.479 +  }
   1.480 +
   1.481 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.482 +
   1.483 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.484 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.485 +
   1.486 +  virtual std::string GetName() const { return "ClearRect"; }
   1.487 +private:
   1.488 +  friend class RecordedEvent;
   1.489 +
   1.490 +  RecordedClearRect(std::istream &aStream);
   1.491 +
   1.492 +  Rect mRect;
   1.493 +};
   1.494 +
   1.495 +class RecordedCopySurface : public RecordedDrawingEvent {
   1.496 +public:
   1.497 +  RecordedCopySurface(DrawTarget *aDT, ReferencePtr aSourceSurface,
   1.498 +                      const IntRect &aSourceRect, const IntPoint &aDest)
   1.499 +    : RecordedDrawingEvent(COPYSURFACE, aDT), mSourceSurface(aSourceSurface),
   1.500 +	  mSourceRect(aSourceRect), mDest(aDest)
   1.501 +  {
   1.502 +  }
   1.503 +
   1.504 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.505 +
   1.506 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.507 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.508 +
   1.509 +  virtual std::string GetName() const { return "CopySurface"; }
   1.510 +private:
   1.511 +  friend class RecordedEvent;
   1.512 +
   1.513 +  RecordedCopySurface(std::istream &aStream);
   1.514 +
   1.515 +  ReferencePtr mSourceSurface;
   1.516 +  IntRect mSourceRect;
   1.517 +  IntPoint mDest;
   1.518 +};
   1.519 +
   1.520 +class RecordedPushClip : public RecordedDrawingEvent {
   1.521 +public:
   1.522 +  RecordedPushClip(DrawTarget *aDT, ReferencePtr aPath)
   1.523 +    : RecordedDrawingEvent(PUSHCLIP, aDT), mPath(aPath)
   1.524 +  {
   1.525 +  }
   1.526 +
   1.527 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.528 +
   1.529 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.530 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.531 +
   1.532 +  virtual std::string GetName() const { return "PushClip"; }
   1.533 +private:
   1.534 +  friend class RecordedEvent;
   1.535 +
   1.536 +  RecordedPushClip(std::istream &aStream);
   1.537 +
   1.538 +  ReferencePtr mPath;
   1.539 +};
   1.540 +
   1.541 +class RecordedPushClipRect : public RecordedDrawingEvent {
   1.542 +public:
   1.543 +  RecordedPushClipRect(DrawTarget *aDT, const Rect &aRect)
   1.544 +    : RecordedDrawingEvent(PUSHCLIPRECT, aDT), mRect(aRect)
   1.545 +  {
   1.546 +  }
   1.547 +
   1.548 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.549 +
   1.550 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.551 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.552 +
   1.553 +  virtual std::string GetName() const { return "PushClipRect"; }
   1.554 +private:
   1.555 +  friend class RecordedEvent;
   1.556 +
   1.557 +  RecordedPushClipRect(std::istream &aStream);
   1.558 +
   1.559 +  Rect mRect;
   1.560 +};
   1.561 +
   1.562 +class RecordedPopClip : public RecordedDrawingEvent {
   1.563 +public:
   1.564 +  RecordedPopClip(DrawTarget *aDT)
   1.565 +    : RecordedDrawingEvent(POPCLIP, aDT)
   1.566 +  {}
   1.567 +
   1.568 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.569 +
   1.570 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.571 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.572 +
   1.573 +  virtual std::string GetName() const { return "PopClip"; }
   1.574 +private:
   1.575 +  friend class RecordedEvent;
   1.576 +
   1.577 +  RecordedPopClip(std::istream &aStream);
   1.578 +};
   1.579 +
   1.580 +class RecordedSetTransform : public RecordedDrawingEvent {
   1.581 +public:
   1.582 +  RecordedSetTransform(DrawTarget *aDT, const Matrix &aTransform)
   1.583 +    : RecordedDrawingEvent(SETTRANSFORM, aDT), mTransform(aTransform)
   1.584 +  {
   1.585 +  }
   1.586 +
   1.587 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.588 +
   1.589 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.590 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.591 +  
   1.592 +  virtual std::string GetName() const { return "SetTransform"; }
   1.593 +private:
   1.594 +  friend class RecordedEvent;
   1.595 +
   1.596 +  RecordedSetTransform(std::istream &aStream);
   1.597 +
   1.598 +  Matrix mTransform;
   1.599 +};
   1.600 +
   1.601 +class RecordedDrawSurface : public RecordedDrawingEvent {
   1.602 +public:
   1.603 +  RecordedDrawSurface(DrawTarget *aDT, ReferencePtr aRefSource, const Rect &aDest,
   1.604 +                      const Rect &aSource, const DrawSurfaceOptions &aDSOptions,
   1.605 +                      const DrawOptions &aOptions)
   1.606 +    : RecordedDrawingEvent(DRAWSURFACE, aDT), mRefSource(aRefSource), mDest(aDest)
   1.607 +    , mSource(aSource), mDSOptions(aDSOptions), mOptions(aOptions)
   1.608 +  {
   1.609 +  }
   1.610 +
   1.611 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.612 +
   1.613 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.614 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.615 +  
   1.616 +  virtual std::string GetName() const { return "DrawSurface"; }
   1.617 +private:
   1.618 +  friend class RecordedEvent;
   1.619 +
   1.620 +  RecordedDrawSurface(std::istream &aStream);
   1.621 +
   1.622 +  ReferencePtr mRefSource;
   1.623 +  Rect mDest;
   1.624 +  Rect mSource;
   1.625 +  DrawSurfaceOptions mDSOptions;
   1.626 +  DrawOptions mOptions;
   1.627 +};
   1.628 +
   1.629 +class RecordedDrawSurfaceWithShadow : public RecordedDrawingEvent {
   1.630 +public:
   1.631 +  RecordedDrawSurfaceWithShadow(DrawTarget *aDT, ReferencePtr aRefSource, const Point &aDest,
   1.632 +                                const Color &aColor, const Point &aOffset,
   1.633 +                                Float aSigma, CompositionOp aOp)
   1.634 +    : RecordedDrawingEvent(DRAWSURFACEWITHSHADOW, aDT), mRefSource(aRefSource), mDest(aDest)
   1.635 +    , mColor(aColor), mOffset(aOffset), mSigma(aSigma), mOp(aOp)
   1.636 +  {
   1.637 +  }
   1.638 +
   1.639 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.640 +
   1.641 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.642 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.643 +  
   1.644 +  virtual std::string GetName() const { return "DrawSurfaceWithShadow"; }
   1.645 +private:
   1.646 +  friend class RecordedEvent;
   1.647 +
   1.648 +  RecordedDrawSurfaceWithShadow(std::istream &aStream);
   1.649 +
   1.650 +  ReferencePtr mRefSource;
   1.651 +  Point mDest;
   1.652 +  Color mColor;
   1.653 +  Point mOffset;
   1.654 +  Float mSigma;
   1.655 +  CompositionOp mOp;
   1.656 +};
   1.657 +
   1.658 +class RecordedDrawFilter : public RecordedDrawingEvent {
   1.659 +public:
   1.660 +  RecordedDrawFilter(DrawTarget *aDT, ReferencePtr aNode,
   1.661 +                     const Rect &aSourceRect,
   1.662 +                     const Point &aDestPoint,
   1.663 +                     const DrawOptions &aOptions)
   1.664 +    : RecordedDrawingEvent(DRAWFILTER, aDT), mNode(aNode), mSourceRect(aSourceRect)
   1.665 +    , mDestPoint(aDestPoint), mOptions(aOptions)
   1.666 +  {
   1.667 +  }
   1.668 +
   1.669 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.670 +
   1.671 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.672 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.673 +
   1.674 +  virtual std::string GetName() const { return "DrawFilter"; }
   1.675 +private:
   1.676 +  friend class RecordedEvent;
   1.677 +
   1.678 +  RecordedDrawFilter(std::istream &aStream);
   1.679 +
   1.680 +  ReferencePtr mNode;
   1.681 +  Rect mSourceRect;
   1.682 +  Point mDestPoint;
   1.683 +  DrawOptions mOptions;
   1.684 +};
   1.685 +
   1.686 +class RecordedPathCreation : public RecordedEvent {
   1.687 +public:
   1.688 +  RecordedPathCreation(PathRecording *aPath);
   1.689 +  ~RecordedPathCreation();
   1.690 +  
   1.691 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.692 +
   1.693 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.694 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.695 +  
   1.696 +  virtual std::string GetName() const { return "Path Creation"; }
   1.697 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.698 +private:
   1.699 +  friend class RecordedEvent;
   1.700 +
   1.701 +  ReferencePtr mRefPtr;
   1.702 +  FillRule mFillRule;
   1.703 +  std::vector<PathOp> mPathOps;
   1.704 +
   1.705 +  RecordedPathCreation(std::istream &aStream);
   1.706 +};
   1.707 +
   1.708 +class RecordedPathDestruction : public RecordedEvent {
   1.709 +public:
   1.710 +  RecordedPathDestruction(PathRecording *aPath)
   1.711 +    : RecordedEvent(PATHDESTRUCTION), mRefPtr(aPath)
   1.712 +  {
   1.713 +  }
   1.714 +  
   1.715 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.716 +
   1.717 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.718 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.719 +  
   1.720 +  virtual std::string GetName() const { return "Path Destruction"; }
   1.721 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.722 +private:
   1.723 +  friend class RecordedEvent;
   1.724 +
   1.725 +  ReferencePtr mRefPtr;
   1.726 +
   1.727 +  RecordedPathDestruction(std::istream &aStream);
   1.728 +};
   1.729 +
   1.730 +class RecordedSourceSurfaceCreation : public RecordedEvent {
   1.731 +public:
   1.732 +  RecordedSourceSurfaceCreation(ReferencePtr aRefPtr, uint8_t *aData, int32_t aStride,
   1.733 +                                const IntSize &aSize, SurfaceFormat aFormat)
   1.734 +    : RecordedEvent(SOURCESURFACECREATION), mRefPtr(aRefPtr), mData(aData)
   1.735 +    , mStride(aStride), mSize(aSize), mFormat(aFormat), mDataOwned(false)
   1.736 +  {
   1.737 +  }
   1.738 +
   1.739 +  ~RecordedSourceSurfaceCreation();
   1.740 +
   1.741 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.742 +
   1.743 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.744 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.745 +  
   1.746 +  virtual std::string GetName() const { return "SourceSurface Creation"; }
   1.747 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.748 +private:
   1.749 +  friend class RecordedEvent;
   1.750 +
   1.751 +  ReferencePtr mRefPtr;
   1.752 +  uint8_t *mData;
   1.753 +  int32_t mStride;
   1.754 +  IntSize mSize;
   1.755 +  SurfaceFormat mFormat;
   1.756 +  bool mDataOwned;
   1.757 +
   1.758 +  RecordedSourceSurfaceCreation(std::istream &aStream);
   1.759 +};
   1.760 +
   1.761 +class RecordedSourceSurfaceDestruction : public RecordedEvent {
   1.762 +public:
   1.763 +  RecordedSourceSurfaceDestruction(ReferencePtr aRefPtr)
   1.764 +    : RecordedEvent(SOURCESURFACEDESTRUCTION), mRefPtr(aRefPtr)
   1.765 +  {
   1.766 +  }
   1.767 +
   1.768 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.769 +
   1.770 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.771 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.772 +  
   1.773 +  virtual std::string GetName() const { return "SourceSurface Destruction"; }
   1.774 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.775 +private:
   1.776 +  friend class RecordedEvent;
   1.777 +
   1.778 +  ReferencePtr mRefPtr;
   1.779 +
   1.780 +  RecordedSourceSurfaceDestruction(std::istream &aStream);
   1.781 +};
   1.782 +
   1.783 +class RecordedFilterNodeCreation : public RecordedEvent {
   1.784 +public:
   1.785 +  RecordedFilterNodeCreation(ReferencePtr aRefPtr, FilterType aType)
   1.786 +    : RecordedEvent(FILTERNODECREATION), mRefPtr(aRefPtr), mType(aType)
   1.787 +  {
   1.788 +  }
   1.789 +
   1.790 +  ~RecordedFilterNodeCreation();
   1.791 +
   1.792 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.793 +
   1.794 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.795 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.796 +
   1.797 +  virtual std::string GetName() const { return "FilterNode Creation"; }
   1.798 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.799 +private:
   1.800 +  friend class RecordedEvent;
   1.801 +
   1.802 +  ReferencePtr mRefPtr;
   1.803 +  FilterType mType;
   1.804 +
   1.805 +  RecordedFilterNodeCreation(std::istream &aStream);
   1.806 +};
   1.807 +
   1.808 +class RecordedFilterNodeDestruction : public RecordedEvent {
   1.809 +public:
   1.810 +  RecordedFilterNodeDestruction(ReferencePtr aRefPtr)
   1.811 +    : RecordedEvent(FILTERNODEDESTRUCTION), mRefPtr(aRefPtr)
   1.812 +  {
   1.813 +  }
   1.814 +
   1.815 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.816 +
   1.817 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.818 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.819 +
   1.820 +  virtual std::string GetName() const { return "FilterNode Destruction"; }
   1.821 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.822 +private:
   1.823 +  friend class RecordedEvent;
   1.824 +
   1.825 +  ReferencePtr mRefPtr;
   1.826 +
   1.827 +  RecordedFilterNodeDestruction(std::istream &aStream);
   1.828 +};
   1.829 +
   1.830 +class RecordedGradientStopsCreation : public RecordedEvent {
   1.831 +public:
   1.832 +  RecordedGradientStopsCreation(ReferencePtr aRefPtr, GradientStop *aStops,
   1.833 +                                uint32_t aNumStops, ExtendMode aExtendMode)
   1.834 +    : RecordedEvent(GRADIENTSTOPSCREATION), mRefPtr(aRefPtr), mStops(aStops)
   1.835 +    , mNumStops(aNumStops), mExtendMode(aExtendMode), mDataOwned(false)
   1.836 +  {
   1.837 +  }
   1.838 +
   1.839 +  ~RecordedGradientStopsCreation();
   1.840 +
   1.841 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.842 +
   1.843 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.844 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.845 +  
   1.846 +  virtual std::string GetName() const { return "GradientStops Creation"; }
   1.847 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.848 +private:
   1.849 +  friend class RecordedEvent;
   1.850 +
   1.851 +  ReferencePtr mRefPtr;
   1.852 +  GradientStop *mStops;
   1.853 +  uint32_t mNumStops;
   1.854 +  ExtendMode mExtendMode;
   1.855 +  bool mDataOwned;
   1.856 +
   1.857 +  RecordedGradientStopsCreation(std::istream &aStream);
   1.858 +};
   1.859 +
   1.860 +class RecordedGradientStopsDestruction : public RecordedEvent {
   1.861 +public:
   1.862 +  RecordedGradientStopsDestruction(ReferencePtr aRefPtr)
   1.863 +    : RecordedEvent(GRADIENTSTOPSDESTRUCTION), mRefPtr(aRefPtr)
   1.864 +  {
   1.865 +  }
   1.866 +
   1.867 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.868 +
   1.869 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.870 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.871 +  
   1.872 +  virtual std::string GetName() const { return "GradientStops Destruction"; }
   1.873 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.874 +private:
   1.875 +  friend class RecordedEvent;
   1.876 +
   1.877 +  ReferencePtr mRefPtr;
   1.878 +
   1.879 +  RecordedGradientStopsDestruction(std::istream &aStream);
   1.880 +};
   1.881 +
   1.882 +class RecordedSnapshot : public RecordedEvent {
   1.883 +public:
   1.884 +  RecordedSnapshot(ReferencePtr aRefPtr, DrawTarget *aDT)
   1.885 +    : RecordedEvent(SNAPSHOT), mRefPtr(aRefPtr), mDT(aDT)
   1.886 +  {
   1.887 +  }
   1.888 +
   1.889 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.890 +
   1.891 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.892 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.893 +  
   1.894 +  virtual std::string GetName() const { return "Snapshot"; }
   1.895 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.896 +private:
   1.897 +  friend class RecordedEvent;
   1.898 +
   1.899 +  ReferencePtr mRefPtr;
   1.900 +  ReferencePtr mDT;
   1.901 +
   1.902 +  RecordedSnapshot(std::istream &aStream);
   1.903 +};
   1.904 +
   1.905 +class RecordedScaledFontCreation : public RecordedEvent {
   1.906 +public:
   1.907 +  static void FontDataProc(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize, void* aBaton)
   1.908 +  {
   1.909 +    static_cast<RecordedScaledFontCreation*>(aBaton)->SetFontData(aData, aSize, aIndex, aGlyphSize);
   1.910 +  }
   1.911 +
   1.912 +  RecordedScaledFontCreation(ReferencePtr aRefPtr, ScaledFont *aScaledFont)
   1.913 +    : RecordedEvent(SCALEDFONTCREATION), mRefPtr(aRefPtr), mData(nullptr)
   1.914 +  {
   1.915 +    aScaledFont->GetFontFileData(&FontDataProc, this);
   1.916 +  }
   1.917 +
   1.918 +  ~RecordedScaledFontCreation();
   1.919 +
   1.920 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.921 +
   1.922 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.923 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.924 +  
   1.925 +  virtual std::string GetName() const { return "ScaledFont Creation"; }
   1.926 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.927 +
   1.928 +  void SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize);
   1.929 +
   1.930 +private:
   1.931 +  friend class RecordedEvent;
   1.932 +
   1.933 +  ReferencePtr mRefPtr;
   1.934 +  uint8_t *mData;
   1.935 +  uint32_t mSize;
   1.936 +  Float mGlyphSize;
   1.937 +  uint32_t mIndex;
   1.938 +
   1.939 +  RecordedScaledFontCreation(std::istream &aStream);
   1.940 +};
   1.941 +
   1.942 +class RecordedScaledFontDestruction : public RecordedEvent {
   1.943 +public:
   1.944 +  RecordedScaledFontDestruction(ReferencePtr aRefPtr)
   1.945 +    : RecordedEvent(SCALEDFONTDESTRUCTION), mRefPtr(aRefPtr)
   1.946 +  {
   1.947 +  }
   1.948 +
   1.949 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.950 +
   1.951 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.952 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.953 +  
   1.954 +  virtual std::string GetName() const { return "ScaledFont Destruction"; }
   1.955 +  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
   1.956 +private:
   1.957 +  friend class RecordedEvent;
   1.958 +
   1.959 +  ReferencePtr mRefPtr;
   1.960 +
   1.961 +  RecordedScaledFontDestruction(std::istream &aStream);
   1.962 +};
   1.963 +
   1.964 +class RecordedMaskSurface : public RecordedDrawingEvent {
   1.965 +public:
   1.966 +  RecordedMaskSurface(DrawTarget *aDT, const Pattern &aPattern, ReferencePtr aRefMask,
   1.967 +                      const Point &aOffset, const DrawOptions &aOptions)
   1.968 +    : RecordedDrawingEvent(MASKSURFACE, aDT), mRefMask(aRefMask), mOffset(aOffset)
   1.969 +    , mOptions(aOptions)
   1.970 +  {
   1.971 +    StorePattern(mPattern, aPattern);
   1.972 +  }
   1.973 +
   1.974 +  virtual void PlayEvent(Translator *aTranslator) const;
   1.975 +
   1.976 +  virtual void RecordToStream(std::ostream &aStream) const;
   1.977 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   1.978 +  
   1.979 +  virtual std::string GetName() const { return "MaskSurface"; }
   1.980 +private:
   1.981 +  friend class RecordedEvent;
   1.982 +
   1.983 +  RecordedMaskSurface(std::istream &aStream);
   1.984 +
   1.985 +  PatternStorage mPattern;
   1.986 +  ReferencePtr mRefMask;
   1.987 +  Point mOffset;
   1.988 +  DrawOptions mOptions;
   1.989 +};
   1.990 +
   1.991 +class RecordedFilterNodeSetAttribute : public RecordedEvent
   1.992 +{
   1.993 +public:
   1.994 +  enum ArgType {
   1.995 +    ARGTYPE_UINT32,
   1.996 +    ARGTYPE_BOOL,
   1.997 +    ARGTYPE_FLOAT,
   1.998 +    ARGTYPE_SIZE,
   1.999 +    ARGTYPE_INTSIZE,
  1.1000 +    ARGTYPE_INTPOINT,
  1.1001 +    ARGTYPE_RECT,
  1.1002 +    ARGTYPE_INTRECT,
  1.1003 +    ARGTYPE_POINT,
  1.1004 +    ARGTYPE_MATRIX5X4,
  1.1005 +    ARGTYPE_POINT3D,
  1.1006 +    ARGTYPE_COLOR,
  1.1007 +    ARGTYPE_FLOAT_ARRAY
  1.1008 +  };
  1.1009 +
  1.1010 +  template<typename T>
  1.1011 +  RecordedFilterNodeSetAttribute(FilterNode *aNode, uint32_t aIndex, T aArgument, ArgType aArgType)
  1.1012 +    : RecordedEvent(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(aArgType)
  1.1013 +  {
  1.1014 +    mPayload.resize(sizeof(T));
  1.1015 +    memcpy(&mPayload.front(), &aArgument, sizeof(T));
  1.1016 +  }
  1.1017 +
  1.1018 +  RecordedFilterNodeSetAttribute(FilterNode *aNode, uint32_t aIndex, const Float *aFloat, uint32_t aSize)
  1.1019 +    : RecordedEvent(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(ARGTYPE_FLOAT_ARRAY)
  1.1020 +  {
  1.1021 +    mPayload.resize(sizeof(Float) * aSize);
  1.1022 +    memcpy(&mPayload.front(), aFloat, sizeof(Float) * aSize);
  1.1023 +  }
  1.1024 +
  1.1025 +  virtual void PlayEvent(Translator *aTranslator) const;
  1.1026 +  virtual void RecordToStream(std::ostream &aStream) const;
  1.1027 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
  1.1028 +
  1.1029 +  virtual std::string GetName() const { return "SetAttribute"; }
  1.1030 +
  1.1031 +  virtual ReferencePtr GetObjectRef() const { return mNode; }
  1.1032 +
  1.1033 +private:
  1.1034 +  friend class RecordedEvent;
  1.1035 +
  1.1036 +  ReferencePtr mNode;
  1.1037 +
  1.1038 +  uint32_t mIndex;
  1.1039 +  ArgType mArgType;
  1.1040 +  std::vector<uint8_t> mPayload;
  1.1041 +
  1.1042 +  RecordedFilterNodeSetAttribute(std::istream &aStream);
  1.1043 +};
  1.1044 +
  1.1045 +class RecordedFilterNodeSetInput : public RecordedEvent
  1.1046 +{
  1.1047 +public:
  1.1048 +  RecordedFilterNodeSetInput(FilterNode* aNode, uint32_t aIndex, FilterNode* aInputNode)
  1.1049 +    : RecordedEvent(FILTERNODESETINPUT), mNode(aNode), mIndex(aIndex)
  1.1050 +    , mInputFilter(aInputNode), mInputSurface(nullptr)
  1.1051 +  {
  1.1052 +  }
  1.1053 +
  1.1054 +  RecordedFilterNodeSetInput(FilterNode *aNode, uint32_t aIndex, SourceSurface *aInputSurface)
  1.1055 +    : RecordedEvent(FILTERNODESETINPUT), mNode(aNode), mIndex(aIndex)
  1.1056 +    , mInputFilter(nullptr), mInputSurface(aInputSurface)
  1.1057 +  {
  1.1058 +  }
  1.1059 +
  1.1060 +  virtual void PlayEvent(Translator *aTranslator) const;
  1.1061 +  virtual void RecordToStream(std::ostream &aStream) const;
  1.1062 +  virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
  1.1063 +
  1.1064 +  virtual std::string GetName() const { return "SetInput"; }
  1.1065 +
  1.1066 +  virtual ReferencePtr GetObjectRef() const { return mNode; }
  1.1067 +
  1.1068 +private:
  1.1069 +  friend class RecordedEvent;
  1.1070 +
  1.1071 +  ReferencePtr mNode;
  1.1072 +  uint32_t mIndex;
  1.1073 +  ReferencePtr mInputFilter;
  1.1074 +  ReferencePtr mInputSurface;
  1.1075 +
  1.1076 +  RecordedFilterNodeSetInput(std::istream &aStream);
  1.1077 +};
  1.1078 +
  1.1079 +}
  1.1080 +}
  1.1081 +
  1.1082 +#endif

mercurial