gfx/2d/RecordedEvent.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef MOZILLA_GFX_RECORDEDEVENT_H_
michael@0 7 #define MOZILLA_GFX_RECORDEDEVENT_H_
michael@0 8
michael@0 9 #include "2D.h"
michael@0 10 #include <ostream>
michael@0 11 #include <sstream>
michael@0 12 #include <cstring>
michael@0 13 #include "RecordingTypes.h"
michael@0 14 #include "PathRecording.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace gfx {
michael@0 18
michael@0 19 // A change in major revision means a change in event binary format, causing
michael@0 20 // loss of backwards compatibility. Old streams will not work in a player
michael@0 21 // using a newer major revision. And new streams will not work in a player
michael@0 22 // using an older major revision.
michael@0 23 const uint16_t kMajorRevision = 3;
michael@0 24 // A change in minor revision means additions of new events. New streams will
michael@0 25 // not play in older players.
michael@0 26 const uint16_t kMinorRevision = 2;
michael@0 27
michael@0 28 struct ReferencePtr
michael@0 29 {
michael@0 30 ReferencePtr()
michael@0 31 : mLongPtr(0)
michael@0 32 {}
michael@0 33
michael@0 34 ReferencePtr(const void* aLongPtr)
michael@0 35 : mLongPtr(uint64_t(aLongPtr))
michael@0 36 {}
michael@0 37
michael@0 38 template <typename T>
michael@0 39 ReferencePtr(const RefPtr<T>& aPtr)
michael@0 40 : mLongPtr(uint64_t(aPtr.get()))
michael@0 41 {}
michael@0 42
michael@0 43 ReferencePtr &operator =(const void* aLongPtr) {
michael@0 44 mLongPtr = uint64_t(aLongPtr);
michael@0 45 return *this;
michael@0 46 }
michael@0 47
michael@0 48 template <typename T>
michael@0 49 ReferencePtr &operator =(const RefPtr<T>& aPtr) {
michael@0 50 mLongPtr = uint64_t(aPtr.get());
michael@0 51 return *this;
michael@0 52 }
michael@0 53
michael@0 54 operator void*() const {
michael@0 55 return (void*)mLongPtr;
michael@0 56 }
michael@0 57
michael@0 58 uint64_t mLongPtr;
michael@0 59 };
michael@0 60
michael@0 61 // Used by the Azure drawing debugger (player2d)
michael@0 62 inline std::string StringFromPtr(ReferencePtr aPtr)
michael@0 63 {
michael@0 64 std::stringstream stream;
michael@0 65 stream << aPtr;
michael@0 66 return stream.str();
michael@0 67 }
michael@0 68
michael@0 69 class Translator
michael@0 70 {
michael@0 71 public:
michael@0 72 virtual ~Translator() {}
michael@0 73
michael@0 74 virtual DrawTarget *LookupDrawTarget(ReferencePtr aRefPtr) = 0;
michael@0 75 virtual Path *LookupPath(ReferencePtr aRefPtr) = 0;
michael@0 76 virtual SourceSurface *LookupSourceSurface(ReferencePtr aRefPtr) = 0;
michael@0 77 virtual FilterNode *LookupFilterNode(ReferencePtr aRefPtr) = 0;
michael@0 78 virtual GradientStops *LookupGradientStops(ReferencePtr aRefPtr) = 0;
michael@0 79 virtual ScaledFont *LookupScaledFont(ReferencePtr aRefPtr) = 0;
michael@0 80 virtual void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget *aDT) = 0;
michael@0 81 virtual void RemoveDrawTarget(ReferencePtr aRefPtr) = 0;
michael@0 82 virtual void AddPath(ReferencePtr aRefPtr, Path *aPath) = 0;
michael@0 83 virtual void RemovePath(ReferencePtr aRefPtr) = 0;
michael@0 84 virtual void AddSourceSurface(ReferencePtr aRefPtr, SourceSurface *aPath) = 0;
michael@0 85 virtual void RemoveSourceSurface(ReferencePtr aRefPtr) = 0;
michael@0 86 virtual void AddFilterNode(mozilla::gfx::ReferencePtr aRefPtr, FilterNode *aSurface) = 0;
michael@0 87 virtual void RemoveFilterNode(mozilla::gfx::ReferencePtr aRefPtr) = 0;
michael@0 88 virtual void AddGradientStops(ReferencePtr aRefPtr, GradientStops *aPath) = 0;
michael@0 89 virtual void RemoveGradientStops(ReferencePtr aRefPtr) = 0;
michael@0 90 virtual void AddScaledFont(ReferencePtr aRefPtr, ScaledFont *aScaledFont) = 0;
michael@0 91 virtual void RemoveScaledFont(ReferencePtr aRefPtr) = 0;
michael@0 92
michael@0 93 virtual DrawTarget *GetReferenceDrawTarget() = 0;
michael@0 94 virtual FontType GetDesiredFontType() = 0;
michael@0 95 };
michael@0 96
michael@0 97 struct ColorPatternStorage
michael@0 98 {
michael@0 99 Color mColor;
michael@0 100 };
michael@0 101
michael@0 102 struct LinearGradientPatternStorage
michael@0 103 {
michael@0 104 Point mBegin;
michael@0 105 Point mEnd;
michael@0 106 ReferencePtr mStops;
michael@0 107 Matrix mMatrix;
michael@0 108 };
michael@0 109
michael@0 110 struct RadialGradientPatternStorage
michael@0 111 {
michael@0 112 Point mCenter1;
michael@0 113 Point mCenter2;
michael@0 114 Float mRadius1;
michael@0 115 Float mRadius2;
michael@0 116 ReferencePtr mStops;
michael@0 117 Matrix mMatrix;
michael@0 118 };
michael@0 119
michael@0 120 struct SurfacePatternStorage
michael@0 121 {
michael@0 122 ExtendMode mExtend;
michael@0 123 Filter mFilter;
michael@0 124 ReferencePtr mSurface;
michael@0 125 Matrix mMatrix;
michael@0 126 };
michael@0 127
michael@0 128 struct PatternStorage
michael@0 129 {
michael@0 130 PatternType mType;
michael@0 131 union {
michael@0 132 char *mStorage;
michael@0 133 char mColor[sizeof(ColorPatternStorage)];
michael@0 134 char mLinear[sizeof(LinearGradientPatternStorage)];
michael@0 135 char mRadial[sizeof(RadialGradientPatternStorage)];
michael@0 136 char mSurface[sizeof(SurfacePatternStorage)];
michael@0 137 };
michael@0 138 };
michael@0 139
michael@0 140 class RecordedEvent {
michael@0 141 public:
michael@0 142 enum EventType {
michael@0 143 DRAWTARGETCREATION = 0,
michael@0 144 DRAWTARGETDESTRUCTION,
michael@0 145 FILLRECT,
michael@0 146 STROKERECT,
michael@0 147 STROKELINE,
michael@0 148 CLEARRECT,
michael@0 149 COPYSURFACE,
michael@0 150 SETTRANSFORM,
michael@0 151 PUSHCLIP,
michael@0 152 PUSHCLIPRECT,
michael@0 153 POPCLIP,
michael@0 154 FILL,
michael@0 155 FILLGLYPHS,
michael@0 156 MASK,
michael@0 157 STROKE,
michael@0 158 DRAWSURFACE,
michael@0 159 DRAWSURFACEWITHSHADOW,
michael@0 160 PATHCREATION,
michael@0 161 PATHDESTRUCTION,
michael@0 162 SOURCESURFACECREATION,
michael@0 163 SOURCESURFACEDESTRUCTION,
michael@0 164 GRADIENTSTOPSCREATION,
michael@0 165 GRADIENTSTOPSDESTRUCTION,
michael@0 166 SNAPSHOT,
michael@0 167 SCALEDFONTCREATION,
michael@0 168 SCALEDFONTDESTRUCTION,
michael@0 169 MASKSURFACE,
michael@0 170 FILTERNODECREATION,
michael@0 171 FILTERNODEDESTRUCTION,
michael@0 172 DRAWFILTER,
michael@0 173 FILTERNODESETATTRIBUTE,
michael@0 174 FILTERNODESETINPUT
michael@0 175 };
michael@0 176 static const uint32_t kTotalEventTypes = RecordedEvent::FILTERNODESETINPUT + 1;
michael@0 177
michael@0 178 static std::string GetEventName(EventType aType);
michael@0 179
michael@0 180 virtual void PlayEvent(Translator *aTranslator) const {}
michael@0 181
michael@0 182 virtual void RecordToStream(std::ostream &aStream) const {}
michael@0 183
michael@0 184 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const { }
michael@0 185
michael@0 186 void RecordPatternData(std::ostream &aStream, const PatternStorage &aPatternStorage) const;
michael@0 187 void ReadPatternData(std::istream &aStream, PatternStorage &aPatternStorage) const;
michael@0 188 void StorePattern(PatternStorage &aDestination, const Pattern &aSource) const;
michael@0 189 void RecordStrokeOptions(std::ostream &aStream, const StrokeOptions &aStrokeOptions) const;
michael@0 190 void ReadStrokeOptions(std::istream &aStream, StrokeOptions &aStrokeOptions);
michael@0 191
michael@0 192 virtual std::string GetName() const = 0;
michael@0 193
michael@0 194 virtual ReferencePtr GetObjectRef() const = 0;
michael@0 195
michael@0 196 virtual ReferencePtr GetDestinedDT() { return nullptr; }
michael@0 197
michael@0 198 void OutputSimplePatternInfo(const PatternStorage &aStorage, std::stringstream &aOutput) const;
michael@0 199
michael@0 200 static RecordedEvent *LoadEventFromStream(std::istream &aStream, EventType aType);
michael@0 201
michael@0 202 EventType GetType() { return (EventType)mType; }
michael@0 203 protected:
michael@0 204 friend class DrawEventRecorderPrivate;
michael@0 205
michael@0 206 RecordedEvent(int32_t aType) : mType(aType)
michael@0 207 {}
michael@0 208
michael@0 209 int32_t mType;
michael@0 210 std::vector<Float> mDashPatternStorage;
michael@0 211 };
michael@0 212
michael@0 213 class RecordedDrawingEvent : public RecordedEvent
michael@0 214 {
michael@0 215 public:
michael@0 216 virtual ReferencePtr GetDestinedDT() { return mDT; }
michael@0 217
michael@0 218 protected:
michael@0 219 RecordedDrawingEvent(EventType aType, DrawTarget *aTarget)
michael@0 220 : RecordedEvent(aType), mDT(aTarget)
michael@0 221 {
michael@0 222 }
michael@0 223
michael@0 224 RecordedDrawingEvent(EventType aType, std::istream &aStream);
michael@0 225 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 226
michael@0 227 virtual ReferencePtr GetObjectRef() const;
michael@0 228
michael@0 229 ReferencePtr mDT;
michael@0 230 };
michael@0 231
michael@0 232 class RecordedDrawTargetCreation : public RecordedEvent {
michael@0 233 public:
michael@0 234 RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType, const IntSize &aSize, SurfaceFormat aFormat,
michael@0 235 bool aHasExistingData = false, SourceSurface *aExistingData = nullptr)
michael@0 236 : RecordedEvent(DRAWTARGETCREATION), mRefPtr(aRefPtr), mBackendType(aType), mSize(aSize), mFormat(aFormat)
michael@0 237 , mHasExistingData(aHasExistingData), mExistingData(aExistingData)
michael@0 238 {}
michael@0 239
michael@0 240 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 241
michael@0 242 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 243 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 244
michael@0 245 virtual std::string GetName() const { return "DrawTarget Creation"; }
michael@0 246 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 247
michael@0 248 ReferencePtr mRefPtr;
michael@0 249 BackendType mBackendType;
michael@0 250 IntSize mSize;
michael@0 251 SurfaceFormat mFormat;
michael@0 252 bool mHasExistingData;
michael@0 253 RefPtr<SourceSurface> mExistingData;
michael@0 254
michael@0 255 private:
michael@0 256 friend class RecordedEvent;
michael@0 257
michael@0 258 RecordedDrawTargetCreation(std::istream &aStream);
michael@0 259 };
michael@0 260
michael@0 261 class RecordedDrawTargetDestruction : public RecordedEvent {
michael@0 262 public:
michael@0 263 RecordedDrawTargetDestruction(ReferencePtr aRefPtr)
michael@0 264 : RecordedEvent(DRAWTARGETDESTRUCTION), mRefPtr(aRefPtr)
michael@0 265 {}
michael@0 266
michael@0 267 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 268
michael@0 269 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 270 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 271
michael@0 272 virtual std::string GetName() const { return "DrawTarget Destruction"; }
michael@0 273 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 274
michael@0 275 ReferencePtr mRefPtr;
michael@0 276
michael@0 277 BackendType mBackendType;
michael@0 278 private:
michael@0 279 friend class RecordedEvent;
michael@0 280
michael@0 281 RecordedDrawTargetDestruction(std::istream &aStream);
michael@0 282 };
michael@0 283
michael@0 284 class RecordedFillRect : public RecordedDrawingEvent {
michael@0 285 public:
michael@0 286 RecordedFillRect(DrawTarget *aDT, const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions)
michael@0 287 : RecordedDrawingEvent(FILLRECT, aDT), mRect(aRect), mOptions(aOptions)
michael@0 288 {
michael@0 289 StorePattern(mPattern, aPattern);
michael@0 290 }
michael@0 291
michael@0 292 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 293
michael@0 294 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 295 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 296
michael@0 297 virtual std::string GetName() const { return "FillRect"; }
michael@0 298 private:
michael@0 299 friend class RecordedEvent;
michael@0 300
michael@0 301 RecordedFillRect(std::istream &aStream);
michael@0 302
michael@0 303 Rect mRect;
michael@0 304 PatternStorage mPattern;
michael@0 305 DrawOptions mOptions;
michael@0 306 };
michael@0 307
michael@0 308 class RecordedStrokeRect : public RecordedDrawingEvent {
michael@0 309 public:
michael@0 310 RecordedStrokeRect(DrawTarget *aDT, const Rect &aRect, const Pattern &aPattern,
michael@0 311 const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
michael@0 312 : RecordedDrawingEvent(STROKERECT, aDT), mRect(aRect),
michael@0 313 mStrokeOptions(aStrokeOptions), mOptions(aOptions)
michael@0 314 {
michael@0 315 StorePattern(mPattern, aPattern);
michael@0 316 }
michael@0 317
michael@0 318 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 319
michael@0 320 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 321 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 322
michael@0 323 virtual std::string GetName() const { return "StrokeRect"; }
michael@0 324 private:
michael@0 325 friend class RecordedEvent;
michael@0 326
michael@0 327 RecordedStrokeRect(std::istream &aStream);
michael@0 328
michael@0 329 Rect mRect;
michael@0 330 PatternStorage mPattern;
michael@0 331 StrokeOptions mStrokeOptions;
michael@0 332 DrawOptions mOptions;
michael@0 333 };
michael@0 334
michael@0 335 class RecordedStrokeLine : public RecordedDrawingEvent {
michael@0 336 public:
michael@0 337 RecordedStrokeLine(DrawTarget *aDT, const Point &aBegin, const Point &aEnd,
michael@0 338 const Pattern &aPattern, const StrokeOptions &aStrokeOptions,
michael@0 339 const DrawOptions &aOptions)
michael@0 340 : RecordedDrawingEvent(STROKELINE, aDT), mBegin(aBegin), mEnd(aEnd),
michael@0 341 mStrokeOptions(aStrokeOptions), mOptions(aOptions)
michael@0 342 {
michael@0 343 StorePattern(mPattern, aPattern);
michael@0 344 }
michael@0 345
michael@0 346 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 347
michael@0 348 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 349 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 350
michael@0 351 virtual std::string GetName() const { return "StrokeLine"; }
michael@0 352 private:
michael@0 353 friend class RecordedEvent;
michael@0 354
michael@0 355 RecordedStrokeLine(std::istream &aStream);
michael@0 356
michael@0 357 Point mBegin;
michael@0 358 Point mEnd;
michael@0 359 PatternStorage mPattern;
michael@0 360 StrokeOptions mStrokeOptions;
michael@0 361 DrawOptions mOptions;
michael@0 362 };
michael@0 363
michael@0 364 class RecordedFill : public RecordedDrawingEvent {
michael@0 365 public:
michael@0 366 RecordedFill(DrawTarget *aDT, ReferencePtr aPath, const Pattern &aPattern, const DrawOptions &aOptions)
michael@0 367 : RecordedDrawingEvent(FILL, aDT), mPath(aPath), mOptions(aOptions)
michael@0 368 {
michael@0 369 StorePattern(mPattern, aPattern);
michael@0 370 }
michael@0 371
michael@0 372 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 373
michael@0 374 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 375 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 376
michael@0 377 virtual std::string GetName() const { return "Fill"; }
michael@0 378 private:
michael@0 379 friend class RecordedEvent;
michael@0 380
michael@0 381 RecordedFill(std::istream &aStream);
michael@0 382
michael@0 383 ReferencePtr mPath;
michael@0 384 PatternStorage mPattern;
michael@0 385 DrawOptions mOptions;
michael@0 386 };
michael@0 387
michael@0 388 class RecordedFillGlyphs : public RecordedDrawingEvent {
michael@0 389 public:
michael@0 390 RecordedFillGlyphs(DrawTarget *aDT, ReferencePtr aScaledFont, const Pattern &aPattern, const DrawOptions &aOptions,
michael@0 391 const Glyph *aGlyphs, uint32_t aNumGlyphs)
michael@0 392 : RecordedDrawingEvent(FILLGLYPHS, aDT), mScaledFont(aScaledFont), mOptions(aOptions)
michael@0 393 {
michael@0 394 StorePattern(mPattern, aPattern);
michael@0 395 mNumGlyphs = aNumGlyphs;
michael@0 396 mGlyphs = new Glyph[aNumGlyphs];
michael@0 397 memcpy(mGlyphs, aGlyphs, sizeof(Glyph) * aNumGlyphs);
michael@0 398 }
michael@0 399 virtual ~RecordedFillGlyphs();
michael@0 400
michael@0 401 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 402
michael@0 403 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 404 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 405
michael@0 406 virtual std::string GetName() const { return "FillGlyphs"; }
michael@0 407 private:
michael@0 408 friend class RecordedEvent;
michael@0 409
michael@0 410 RecordedFillGlyphs(std::istream &aStream);
michael@0 411
michael@0 412 ReferencePtr mScaledFont;
michael@0 413 PatternStorage mPattern;
michael@0 414 DrawOptions mOptions;
michael@0 415 Glyph *mGlyphs;
michael@0 416 uint32_t mNumGlyphs;
michael@0 417 };
michael@0 418
michael@0 419 class RecordedMask : public RecordedDrawingEvent {
michael@0 420 public:
michael@0 421 RecordedMask(DrawTarget *aDT, const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions)
michael@0 422 : RecordedDrawingEvent(MASK, aDT), mOptions(aOptions)
michael@0 423 {
michael@0 424 StorePattern(mSource, aSource);
michael@0 425 StorePattern(mMask, aMask);
michael@0 426 }
michael@0 427
michael@0 428 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 429
michael@0 430 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 431 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 432
michael@0 433 virtual std::string GetName() const { return "Mask"; }
michael@0 434 private:
michael@0 435 friend class RecordedEvent;
michael@0 436
michael@0 437 RecordedMask(std::istream &aStream);
michael@0 438
michael@0 439 PatternStorage mSource;
michael@0 440 PatternStorage mMask;
michael@0 441 DrawOptions mOptions;
michael@0 442 };
michael@0 443
michael@0 444 class RecordedStroke : public RecordedDrawingEvent {
michael@0 445 public:
michael@0 446 RecordedStroke(DrawTarget *aDT, ReferencePtr aPath, const Pattern &aPattern,
michael@0 447 const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions)
michael@0 448 : RecordedDrawingEvent(STROKE, aDT), mPath(aPath),
michael@0 449 mStrokeOptions(aStrokeOptions), mOptions(aOptions)
michael@0 450 {
michael@0 451 StorePattern(mPattern, aPattern);
michael@0 452 }
michael@0 453
michael@0 454 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 455
michael@0 456 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 457 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 458
michael@0 459 virtual std::string GetName() const { return "Stroke"; }
michael@0 460 private:
michael@0 461 friend class RecordedEvent;
michael@0 462
michael@0 463 RecordedStroke(std::istream &aStream);
michael@0 464
michael@0 465 ReferencePtr mPath;
michael@0 466 PatternStorage mPattern;
michael@0 467 StrokeOptions mStrokeOptions;
michael@0 468 DrawOptions mOptions;
michael@0 469 };
michael@0 470
michael@0 471 class RecordedClearRect : public RecordedDrawingEvent {
michael@0 472 public:
michael@0 473 RecordedClearRect(DrawTarget *aDT, const Rect &aRect)
michael@0 474 : RecordedDrawingEvent(CLEARRECT, aDT), mRect(aRect)
michael@0 475 {
michael@0 476 }
michael@0 477
michael@0 478 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 479
michael@0 480 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 481 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 482
michael@0 483 virtual std::string GetName() const { return "ClearRect"; }
michael@0 484 private:
michael@0 485 friend class RecordedEvent;
michael@0 486
michael@0 487 RecordedClearRect(std::istream &aStream);
michael@0 488
michael@0 489 Rect mRect;
michael@0 490 };
michael@0 491
michael@0 492 class RecordedCopySurface : public RecordedDrawingEvent {
michael@0 493 public:
michael@0 494 RecordedCopySurface(DrawTarget *aDT, ReferencePtr aSourceSurface,
michael@0 495 const IntRect &aSourceRect, const IntPoint &aDest)
michael@0 496 : RecordedDrawingEvent(COPYSURFACE, aDT), mSourceSurface(aSourceSurface),
michael@0 497 mSourceRect(aSourceRect), mDest(aDest)
michael@0 498 {
michael@0 499 }
michael@0 500
michael@0 501 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 502
michael@0 503 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 504 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 505
michael@0 506 virtual std::string GetName() const { return "CopySurface"; }
michael@0 507 private:
michael@0 508 friend class RecordedEvent;
michael@0 509
michael@0 510 RecordedCopySurface(std::istream &aStream);
michael@0 511
michael@0 512 ReferencePtr mSourceSurface;
michael@0 513 IntRect mSourceRect;
michael@0 514 IntPoint mDest;
michael@0 515 };
michael@0 516
michael@0 517 class RecordedPushClip : public RecordedDrawingEvent {
michael@0 518 public:
michael@0 519 RecordedPushClip(DrawTarget *aDT, ReferencePtr aPath)
michael@0 520 : RecordedDrawingEvent(PUSHCLIP, aDT), mPath(aPath)
michael@0 521 {
michael@0 522 }
michael@0 523
michael@0 524 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 525
michael@0 526 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 527 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 528
michael@0 529 virtual std::string GetName() const { return "PushClip"; }
michael@0 530 private:
michael@0 531 friend class RecordedEvent;
michael@0 532
michael@0 533 RecordedPushClip(std::istream &aStream);
michael@0 534
michael@0 535 ReferencePtr mPath;
michael@0 536 };
michael@0 537
michael@0 538 class RecordedPushClipRect : public RecordedDrawingEvent {
michael@0 539 public:
michael@0 540 RecordedPushClipRect(DrawTarget *aDT, const Rect &aRect)
michael@0 541 : RecordedDrawingEvent(PUSHCLIPRECT, aDT), mRect(aRect)
michael@0 542 {
michael@0 543 }
michael@0 544
michael@0 545 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 546
michael@0 547 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 548 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 549
michael@0 550 virtual std::string GetName() const { return "PushClipRect"; }
michael@0 551 private:
michael@0 552 friend class RecordedEvent;
michael@0 553
michael@0 554 RecordedPushClipRect(std::istream &aStream);
michael@0 555
michael@0 556 Rect mRect;
michael@0 557 };
michael@0 558
michael@0 559 class RecordedPopClip : public RecordedDrawingEvent {
michael@0 560 public:
michael@0 561 RecordedPopClip(DrawTarget *aDT)
michael@0 562 : RecordedDrawingEvent(POPCLIP, aDT)
michael@0 563 {}
michael@0 564
michael@0 565 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 566
michael@0 567 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 568 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 569
michael@0 570 virtual std::string GetName() const { return "PopClip"; }
michael@0 571 private:
michael@0 572 friend class RecordedEvent;
michael@0 573
michael@0 574 RecordedPopClip(std::istream &aStream);
michael@0 575 };
michael@0 576
michael@0 577 class RecordedSetTransform : public RecordedDrawingEvent {
michael@0 578 public:
michael@0 579 RecordedSetTransform(DrawTarget *aDT, const Matrix &aTransform)
michael@0 580 : RecordedDrawingEvent(SETTRANSFORM, aDT), mTransform(aTransform)
michael@0 581 {
michael@0 582 }
michael@0 583
michael@0 584 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 585
michael@0 586 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 587 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 588
michael@0 589 virtual std::string GetName() const { return "SetTransform"; }
michael@0 590 private:
michael@0 591 friend class RecordedEvent;
michael@0 592
michael@0 593 RecordedSetTransform(std::istream &aStream);
michael@0 594
michael@0 595 Matrix mTransform;
michael@0 596 };
michael@0 597
michael@0 598 class RecordedDrawSurface : public RecordedDrawingEvent {
michael@0 599 public:
michael@0 600 RecordedDrawSurface(DrawTarget *aDT, ReferencePtr aRefSource, const Rect &aDest,
michael@0 601 const Rect &aSource, const DrawSurfaceOptions &aDSOptions,
michael@0 602 const DrawOptions &aOptions)
michael@0 603 : RecordedDrawingEvent(DRAWSURFACE, aDT), mRefSource(aRefSource), mDest(aDest)
michael@0 604 , mSource(aSource), mDSOptions(aDSOptions), mOptions(aOptions)
michael@0 605 {
michael@0 606 }
michael@0 607
michael@0 608 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 609
michael@0 610 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 611 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 612
michael@0 613 virtual std::string GetName() const { return "DrawSurface"; }
michael@0 614 private:
michael@0 615 friend class RecordedEvent;
michael@0 616
michael@0 617 RecordedDrawSurface(std::istream &aStream);
michael@0 618
michael@0 619 ReferencePtr mRefSource;
michael@0 620 Rect mDest;
michael@0 621 Rect mSource;
michael@0 622 DrawSurfaceOptions mDSOptions;
michael@0 623 DrawOptions mOptions;
michael@0 624 };
michael@0 625
michael@0 626 class RecordedDrawSurfaceWithShadow : public RecordedDrawingEvent {
michael@0 627 public:
michael@0 628 RecordedDrawSurfaceWithShadow(DrawTarget *aDT, ReferencePtr aRefSource, const Point &aDest,
michael@0 629 const Color &aColor, const Point &aOffset,
michael@0 630 Float aSigma, CompositionOp aOp)
michael@0 631 : RecordedDrawingEvent(DRAWSURFACEWITHSHADOW, aDT), mRefSource(aRefSource), mDest(aDest)
michael@0 632 , mColor(aColor), mOffset(aOffset), mSigma(aSigma), mOp(aOp)
michael@0 633 {
michael@0 634 }
michael@0 635
michael@0 636 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 637
michael@0 638 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 639 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 640
michael@0 641 virtual std::string GetName() const { return "DrawSurfaceWithShadow"; }
michael@0 642 private:
michael@0 643 friend class RecordedEvent;
michael@0 644
michael@0 645 RecordedDrawSurfaceWithShadow(std::istream &aStream);
michael@0 646
michael@0 647 ReferencePtr mRefSource;
michael@0 648 Point mDest;
michael@0 649 Color mColor;
michael@0 650 Point mOffset;
michael@0 651 Float mSigma;
michael@0 652 CompositionOp mOp;
michael@0 653 };
michael@0 654
michael@0 655 class RecordedDrawFilter : public RecordedDrawingEvent {
michael@0 656 public:
michael@0 657 RecordedDrawFilter(DrawTarget *aDT, ReferencePtr aNode,
michael@0 658 const Rect &aSourceRect,
michael@0 659 const Point &aDestPoint,
michael@0 660 const DrawOptions &aOptions)
michael@0 661 : RecordedDrawingEvent(DRAWFILTER, aDT), mNode(aNode), mSourceRect(aSourceRect)
michael@0 662 , mDestPoint(aDestPoint), mOptions(aOptions)
michael@0 663 {
michael@0 664 }
michael@0 665
michael@0 666 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 667
michael@0 668 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 669 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 670
michael@0 671 virtual std::string GetName() const { return "DrawFilter"; }
michael@0 672 private:
michael@0 673 friend class RecordedEvent;
michael@0 674
michael@0 675 RecordedDrawFilter(std::istream &aStream);
michael@0 676
michael@0 677 ReferencePtr mNode;
michael@0 678 Rect mSourceRect;
michael@0 679 Point mDestPoint;
michael@0 680 DrawOptions mOptions;
michael@0 681 };
michael@0 682
michael@0 683 class RecordedPathCreation : public RecordedEvent {
michael@0 684 public:
michael@0 685 RecordedPathCreation(PathRecording *aPath);
michael@0 686 ~RecordedPathCreation();
michael@0 687
michael@0 688 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 689
michael@0 690 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 691 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 692
michael@0 693 virtual std::string GetName() const { return "Path Creation"; }
michael@0 694 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 695 private:
michael@0 696 friend class RecordedEvent;
michael@0 697
michael@0 698 ReferencePtr mRefPtr;
michael@0 699 FillRule mFillRule;
michael@0 700 std::vector<PathOp> mPathOps;
michael@0 701
michael@0 702 RecordedPathCreation(std::istream &aStream);
michael@0 703 };
michael@0 704
michael@0 705 class RecordedPathDestruction : public RecordedEvent {
michael@0 706 public:
michael@0 707 RecordedPathDestruction(PathRecording *aPath)
michael@0 708 : RecordedEvent(PATHDESTRUCTION), mRefPtr(aPath)
michael@0 709 {
michael@0 710 }
michael@0 711
michael@0 712 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 713
michael@0 714 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 715 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 716
michael@0 717 virtual std::string GetName() const { return "Path Destruction"; }
michael@0 718 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 719 private:
michael@0 720 friend class RecordedEvent;
michael@0 721
michael@0 722 ReferencePtr mRefPtr;
michael@0 723
michael@0 724 RecordedPathDestruction(std::istream &aStream);
michael@0 725 };
michael@0 726
michael@0 727 class RecordedSourceSurfaceCreation : public RecordedEvent {
michael@0 728 public:
michael@0 729 RecordedSourceSurfaceCreation(ReferencePtr aRefPtr, uint8_t *aData, int32_t aStride,
michael@0 730 const IntSize &aSize, SurfaceFormat aFormat)
michael@0 731 : RecordedEvent(SOURCESURFACECREATION), mRefPtr(aRefPtr), mData(aData)
michael@0 732 , mStride(aStride), mSize(aSize), mFormat(aFormat), mDataOwned(false)
michael@0 733 {
michael@0 734 }
michael@0 735
michael@0 736 ~RecordedSourceSurfaceCreation();
michael@0 737
michael@0 738 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 739
michael@0 740 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 741 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 742
michael@0 743 virtual std::string GetName() const { return "SourceSurface Creation"; }
michael@0 744 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 745 private:
michael@0 746 friend class RecordedEvent;
michael@0 747
michael@0 748 ReferencePtr mRefPtr;
michael@0 749 uint8_t *mData;
michael@0 750 int32_t mStride;
michael@0 751 IntSize mSize;
michael@0 752 SurfaceFormat mFormat;
michael@0 753 bool mDataOwned;
michael@0 754
michael@0 755 RecordedSourceSurfaceCreation(std::istream &aStream);
michael@0 756 };
michael@0 757
michael@0 758 class RecordedSourceSurfaceDestruction : public RecordedEvent {
michael@0 759 public:
michael@0 760 RecordedSourceSurfaceDestruction(ReferencePtr aRefPtr)
michael@0 761 : RecordedEvent(SOURCESURFACEDESTRUCTION), mRefPtr(aRefPtr)
michael@0 762 {
michael@0 763 }
michael@0 764
michael@0 765 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 766
michael@0 767 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 768 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 769
michael@0 770 virtual std::string GetName() const { return "SourceSurface Destruction"; }
michael@0 771 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 772 private:
michael@0 773 friend class RecordedEvent;
michael@0 774
michael@0 775 ReferencePtr mRefPtr;
michael@0 776
michael@0 777 RecordedSourceSurfaceDestruction(std::istream &aStream);
michael@0 778 };
michael@0 779
michael@0 780 class RecordedFilterNodeCreation : public RecordedEvent {
michael@0 781 public:
michael@0 782 RecordedFilterNodeCreation(ReferencePtr aRefPtr, FilterType aType)
michael@0 783 : RecordedEvent(FILTERNODECREATION), mRefPtr(aRefPtr), mType(aType)
michael@0 784 {
michael@0 785 }
michael@0 786
michael@0 787 ~RecordedFilterNodeCreation();
michael@0 788
michael@0 789 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 790
michael@0 791 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 792 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 793
michael@0 794 virtual std::string GetName() const { return "FilterNode Creation"; }
michael@0 795 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 796 private:
michael@0 797 friend class RecordedEvent;
michael@0 798
michael@0 799 ReferencePtr mRefPtr;
michael@0 800 FilterType mType;
michael@0 801
michael@0 802 RecordedFilterNodeCreation(std::istream &aStream);
michael@0 803 };
michael@0 804
michael@0 805 class RecordedFilterNodeDestruction : public RecordedEvent {
michael@0 806 public:
michael@0 807 RecordedFilterNodeDestruction(ReferencePtr aRefPtr)
michael@0 808 : RecordedEvent(FILTERNODEDESTRUCTION), mRefPtr(aRefPtr)
michael@0 809 {
michael@0 810 }
michael@0 811
michael@0 812 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 813
michael@0 814 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 815 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 816
michael@0 817 virtual std::string GetName() const { return "FilterNode Destruction"; }
michael@0 818 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 819 private:
michael@0 820 friend class RecordedEvent;
michael@0 821
michael@0 822 ReferencePtr mRefPtr;
michael@0 823
michael@0 824 RecordedFilterNodeDestruction(std::istream &aStream);
michael@0 825 };
michael@0 826
michael@0 827 class RecordedGradientStopsCreation : public RecordedEvent {
michael@0 828 public:
michael@0 829 RecordedGradientStopsCreation(ReferencePtr aRefPtr, GradientStop *aStops,
michael@0 830 uint32_t aNumStops, ExtendMode aExtendMode)
michael@0 831 : RecordedEvent(GRADIENTSTOPSCREATION), mRefPtr(aRefPtr), mStops(aStops)
michael@0 832 , mNumStops(aNumStops), mExtendMode(aExtendMode), mDataOwned(false)
michael@0 833 {
michael@0 834 }
michael@0 835
michael@0 836 ~RecordedGradientStopsCreation();
michael@0 837
michael@0 838 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 839
michael@0 840 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 841 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 842
michael@0 843 virtual std::string GetName() const { return "GradientStops Creation"; }
michael@0 844 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 845 private:
michael@0 846 friend class RecordedEvent;
michael@0 847
michael@0 848 ReferencePtr mRefPtr;
michael@0 849 GradientStop *mStops;
michael@0 850 uint32_t mNumStops;
michael@0 851 ExtendMode mExtendMode;
michael@0 852 bool mDataOwned;
michael@0 853
michael@0 854 RecordedGradientStopsCreation(std::istream &aStream);
michael@0 855 };
michael@0 856
michael@0 857 class RecordedGradientStopsDestruction : public RecordedEvent {
michael@0 858 public:
michael@0 859 RecordedGradientStopsDestruction(ReferencePtr aRefPtr)
michael@0 860 : RecordedEvent(GRADIENTSTOPSDESTRUCTION), mRefPtr(aRefPtr)
michael@0 861 {
michael@0 862 }
michael@0 863
michael@0 864 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 865
michael@0 866 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 867 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 868
michael@0 869 virtual std::string GetName() const { return "GradientStops Destruction"; }
michael@0 870 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 871 private:
michael@0 872 friend class RecordedEvent;
michael@0 873
michael@0 874 ReferencePtr mRefPtr;
michael@0 875
michael@0 876 RecordedGradientStopsDestruction(std::istream &aStream);
michael@0 877 };
michael@0 878
michael@0 879 class RecordedSnapshot : public RecordedEvent {
michael@0 880 public:
michael@0 881 RecordedSnapshot(ReferencePtr aRefPtr, DrawTarget *aDT)
michael@0 882 : RecordedEvent(SNAPSHOT), mRefPtr(aRefPtr), mDT(aDT)
michael@0 883 {
michael@0 884 }
michael@0 885
michael@0 886 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 887
michael@0 888 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 889 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 890
michael@0 891 virtual std::string GetName() const { return "Snapshot"; }
michael@0 892 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 893 private:
michael@0 894 friend class RecordedEvent;
michael@0 895
michael@0 896 ReferencePtr mRefPtr;
michael@0 897 ReferencePtr mDT;
michael@0 898
michael@0 899 RecordedSnapshot(std::istream &aStream);
michael@0 900 };
michael@0 901
michael@0 902 class RecordedScaledFontCreation : public RecordedEvent {
michael@0 903 public:
michael@0 904 static void FontDataProc(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize, void* aBaton)
michael@0 905 {
michael@0 906 static_cast<RecordedScaledFontCreation*>(aBaton)->SetFontData(aData, aSize, aIndex, aGlyphSize);
michael@0 907 }
michael@0 908
michael@0 909 RecordedScaledFontCreation(ReferencePtr aRefPtr, ScaledFont *aScaledFont)
michael@0 910 : RecordedEvent(SCALEDFONTCREATION), mRefPtr(aRefPtr), mData(nullptr)
michael@0 911 {
michael@0 912 aScaledFont->GetFontFileData(&FontDataProc, this);
michael@0 913 }
michael@0 914
michael@0 915 ~RecordedScaledFontCreation();
michael@0 916
michael@0 917 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 918
michael@0 919 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 920 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 921
michael@0 922 virtual std::string GetName() const { return "ScaledFont Creation"; }
michael@0 923 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 924
michael@0 925 void SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize);
michael@0 926
michael@0 927 private:
michael@0 928 friend class RecordedEvent;
michael@0 929
michael@0 930 ReferencePtr mRefPtr;
michael@0 931 uint8_t *mData;
michael@0 932 uint32_t mSize;
michael@0 933 Float mGlyphSize;
michael@0 934 uint32_t mIndex;
michael@0 935
michael@0 936 RecordedScaledFontCreation(std::istream &aStream);
michael@0 937 };
michael@0 938
michael@0 939 class RecordedScaledFontDestruction : public RecordedEvent {
michael@0 940 public:
michael@0 941 RecordedScaledFontDestruction(ReferencePtr aRefPtr)
michael@0 942 : RecordedEvent(SCALEDFONTDESTRUCTION), mRefPtr(aRefPtr)
michael@0 943 {
michael@0 944 }
michael@0 945
michael@0 946 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 947
michael@0 948 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 949 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 950
michael@0 951 virtual std::string GetName() const { return "ScaledFont Destruction"; }
michael@0 952 virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
michael@0 953 private:
michael@0 954 friend class RecordedEvent;
michael@0 955
michael@0 956 ReferencePtr mRefPtr;
michael@0 957
michael@0 958 RecordedScaledFontDestruction(std::istream &aStream);
michael@0 959 };
michael@0 960
michael@0 961 class RecordedMaskSurface : public RecordedDrawingEvent {
michael@0 962 public:
michael@0 963 RecordedMaskSurface(DrawTarget *aDT, const Pattern &aPattern, ReferencePtr aRefMask,
michael@0 964 const Point &aOffset, const DrawOptions &aOptions)
michael@0 965 : RecordedDrawingEvent(MASKSURFACE, aDT), mRefMask(aRefMask), mOffset(aOffset)
michael@0 966 , mOptions(aOptions)
michael@0 967 {
michael@0 968 StorePattern(mPattern, aPattern);
michael@0 969 }
michael@0 970
michael@0 971 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 972
michael@0 973 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 974 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 975
michael@0 976 virtual std::string GetName() const { return "MaskSurface"; }
michael@0 977 private:
michael@0 978 friend class RecordedEvent;
michael@0 979
michael@0 980 RecordedMaskSurface(std::istream &aStream);
michael@0 981
michael@0 982 PatternStorage mPattern;
michael@0 983 ReferencePtr mRefMask;
michael@0 984 Point mOffset;
michael@0 985 DrawOptions mOptions;
michael@0 986 };
michael@0 987
michael@0 988 class RecordedFilterNodeSetAttribute : public RecordedEvent
michael@0 989 {
michael@0 990 public:
michael@0 991 enum ArgType {
michael@0 992 ARGTYPE_UINT32,
michael@0 993 ARGTYPE_BOOL,
michael@0 994 ARGTYPE_FLOAT,
michael@0 995 ARGTYPE_SIZE,
michael@0 996 ARGTYPE_INTSIZE,
michael@0 997 ARGTYPE_INTPOINT,
michael@0 998 ARGTYPE_RECT,
michael@0 999 ARGTYPE_INTRECT,
michael@0 1000 ARGTYPE_POINT,
michael@0 1001 ARGTYPE_MATRIX5X4,
michael@0 1002 ARGTYPE_POINT3D,
michael@0 1003 ARGTYPE_COLOR,
michael@0 1004 ARGTYPE_FLOAT_ARRAY
michael@0 1005 };
michael@0 1006
michael@0 1007 template<typename T>
michael@0 1008 RecordedFilterNodeSetAttribute(FilterNode *aNode, uint32_t aIndex, T aArgument, ArgType aArgType)
michael@0 1009 : RecordedEvent(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(aArgType)
michael@0 1010 {
michael@0 1011 mPayload.resize(sizeof(T));
michael@0 1012 memcpy(&mPayload.front(), &aArgument, sizeof(T));
michael@0 1013 }
michael@0 1014
michael@0 1015 RecordedFilterNodeSetAttribute(FilterNode *aNode, uint32_t aIndex, const Float *aFloat, uint32_t aSize)
michael@0 1016 : RecordedEvent(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(ARGTYPE_FLOAT_ARRAY)
michael@0 1017 {
michael@0 1018 mPayload.resize(sizeof(Float) * aSize);
michael@0 1019 memcpy(&mPayload.front(), aFloat, sizeof(Float) * aSize);
michael@0 1020 }
michael@0 1021
michael@0 1022 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 1023 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 1024 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 1025
michael@0 1026 virtual std::string GetName() const { return "SetAttribute"; }
michael@0 1027
michael@0 1028 virtual ReferencePtr GetObjectRef() const { return mNode; }
michael@0 1029
michael@0 1030 private:
michael@0 1031 friend class RecordedEvent;
michael@0 1032
michael@0 1033 ReferencePtr mNode;
michael@0 1034
michael@0 1035 uint32_t mIndex;
michael@0 1036 ArgType mArgType;
michael@0 1037 std::vector<uint8_t> mPayload;
michael@0 1038
michael@0 1039 RecordedFilterNodeSetAttribute(std::istream &aStream);
michael@0 1040 };
michael@0 1041
michael@0 1042 class RecordedFilterNodeSetInput : public RecordedEvent
michael@0 1043 {
michael@0 1044 public:
michael@0 1045 RecordedFilterNodeSetInput(FilterNode* aNode, uint32_t aIndex, FilterNode* aInputNode)
michael@0 1046 : RecordedEvent(FILTERNODESETINPUT), mNode(aNode), mIndex(aIndex)
michael@0 1047 , mInputFilter(aInputNode), mInputSurface(nullptr)
michael@0 1048 {
michael@0 1049 }
michael@0 1050
michael@0 1051 RecordedFilterNodeSetInput(FilterNode *aNode, uint32_t aIndex, SourceSurface *aInputSurface)
michael@0 1052 : RecordedEvent(FILTERNODESETINPUT), mNode(aNode), mIndex(aIndex)
michael@0 1053 , mInputFilter(nullptr), mInputSurface(aInputSurface)
michael@0 1054 {
michael@0 1055 }
michael@0 1056
michael@0 1057 virtual void PlayEvent(Translator *aTranslator) const;
michael@0 1058 virtual void RecordToStream(std::ostream &aStream) const;
michael@0 1059 virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
michael@0 1060
michael@0 1061 virtual std::string GetName() const { return "SetInput"; }
michael@0 1062
michael@0 1063 virtual ReferencePtr GetObjectRef() const { return mNode; }
michael@0 1064
michael@0 1065 private:
michael@0 1066 friend class RecordedEvent;
michael@0 1067
michael@0 1068 ReferencePtr mNode;
michael@0 1069 uint32_t mIndex;
michael@0 1070 ReferencePtr mInputFilter;
michael@0 1071 ReferencePtr mInputSurface;
michael@0 1072
michael@0 1073 RecordedFilterNodeSetInput(std::istream &aStream);
michael@0 1074 };
michael@0 1075
michael@0 1076 }
michael@0 1077 }
michael@0 1078
michael@0 1079 #endif

mercurial