Source code

Revision control

Copy as Markdown

Other Tools

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_GFX_RECORDEDEVENTIMPL_H_
#define MOZILLA_GFX_RECORDEDEVENTIMPL_H_
#include "RecordedEvent.h"
#include "PathRecording.h"
#include "RecordingTypes.h"
#include "Tools.h"
#include "Filters.h"
#include "Logging.h"
#include "ScaledFontBase.h"
#include "SFNTData.h"
namespace mozilla {
namespace gfx {
template <class Derived>
class RecordedDrawingEvent : public RecordedEventDerived<Derived> {
public:
ReferencePtr GetDestinedDT() override { return mDT; }
protected:
RecordedDrawingEvent(RecordedEvent::EventType aType, DrawTarget* aTarget)
: RecordedEventDerived<Derived>(aType), mDT(aTarget) {}
template <class S>
RecordedDrawingEvent(RecordedEvent::EventType aType, S& aStream);
template <class S>
void Record(S& aStream) const;
ReferencePtr mDT;
};
class RecordedDrawTargetCreation
: public RecordedEventDerived<RecordedDrawTargetCreation> {
public:
RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType,
const IntRect& aRect, SurfaceFormat aFormat,
bool aHasExistingData = false,
SourceSurface* aExistingData = nullptr)
: RecordedEventDerived(DRAWTARGETCREATION),
mRefPtr(aRefPtr),
mBackendType(aType),
mRect(aRect),
mFormat(aFormat),
mHasExistingData(aHasExistingData),
mExistingData(aExistingData) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
std::string GetName() const override { return "DrawTarget Creation"; }
ReferencePtr mRefPtr;
BackendType mBackendType;
IntRect mRect;
SurfaceFormat mFormat;
bool mHasExistingData;
RefPtr<SourceSurface> mExistingData;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawTargetCreation(S& aStream);
};
class RecordedDrawTargetDestruction
: public RecordedEventDerived<RecordedDrawTargetDestruction> {
public:
MOZ_IMPLICIT RecordedDrawTargetDestruction(ReferencePtr aRefPtr)
: RecordedEventDerived(DRAWTARGETDESTRUCTION),
mRefPtr(aRefPtr),
mBackendType(BackendType::NONE) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "DrawTarget Destruction"; }
ReferencePtr mRefPtr;
BackendType mBackendType;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawTargetDestruction(S& aStream);
};
class RecordedCreateSimilarDrawTarget
: public RecordedEventDerived<RecordedCreateSimilarDrawTarget> {
public:
RecordedCreateSimilarDrawTarget(ReferencePtr aRefPtr, const IntSize& aSize,
SurfaceFormat aFormat)
: RecordedEventDerived(CREATESIMILARDRAWTARGET),
mRefPtr(aRefPtr),
mSize(aSize),
mFormat(aFormat) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
std::string GetName() const override { return "CreateSimilarDrawTarget"; }
ReferencePtr mRefPtr;
IntSize mSize;
SurfaceFormat mFormat;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedCreateSimilarDrawTarget(S& aStream);
};
class RecordedCreateClippedDrawTarget
: public RecordedDrawingEvent<RecordedCreateClippedDrawTarget> {
public:
RecordedCreateClippedDrawTarget(DrawTarget* aDT, ReferencePtr aRefPtr,
const Rect& aBounds, SurfaceFormat aFormat)
: RecordedDrawingEvent(CREATECLIPPEDDRAWTARGET, aDT),
mRefPtr(aRefPtr),
mBounds(aBounds),
mFormat(aFormat) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
std::string GetName() const override { return "CreateClippedDrawTarget"; }
ReferencePtr mRefPtr;
Rect mBounds;
SurfaceFormat mFormat;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedCreateClippedDrawTarget(S& aStream);
};
class RecordedCreateDrawTargetForFilter
: public RecordedDrawingEvent<RecordedCreateDrawTargetForFilter> {
public:
RecordedCreateDrawTargetForFilter(DrawTarget* aDT, ReferencePtr aRefPtr,
const IntSize& aMaxSize,
SurfaceFormat aFormat, FilterNode* aFilter,
FilterNode* aSource,
const Rect& aSourceRect,
const Point& aDestPoint)
: RecordedDrawingEvent(CREATEDRAWTARGETFORFILTER, aDT),
mRefPtr(aRefPtr),
mMaxSize(aMaxSize),
mFormat(aFormat),
mFilter(aFilter),
mSource(aSource),
mSourceRect(aSourceRect),
mDestPoint(aDestPoint) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
std::string GetName() const override {
return "CreateSimilarDrawTargetForFilter";
}
ReferencePtr mRefPtr;
IntSize mMaxSize;
SurfaceFormat mFormat;
ReferencePtr mFilter;
ReferencePtr mSource;
Rect mSourceRect;
Point mDestPoint;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedCreateDrawTargetForFilter(S& aStream);
};
class RecordedFillRect : public RecordedDrawingEvent<RecordedFillRect> {
public:
RecordedFillRect(DrawTarget* aDT, const Rect& aRect, const Pattern& aPattern,
const DrawOptions& aOptions)
: RecordedDrawingEvent(FILLRECT, aDT),
mRect(aRect),
mPattern(),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "FillRect"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedFillRect(S& aStream);
Rect mRect;
PatternStorage mPattern;
DrawOptions mOptions;
};
class RecordedStrokeRect : public RecordedDrawingEvent<RecordedStrokeRect> {
public:
RecordedStrokeRect(DrawTarget* aDT, const Rect& aRect,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedDrawingEvent(STROKERECT, aDT),
mRect(aRect),
mPattern(),
mStrokeOptions(aStrokeOptions),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "StrokeRect"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedStrokeRect(S& aStream);
Rect mRect;
PatternStorage mPattern;
StrokeOptions mStrokeOptions;
DrawOptions mOptions;
};
class RecordedStrokeLine : public RecordedDrawingEvent<RecordedStrokeLine> {
public:
RecordedStrokeLine(DrawTarget* aDT, const Point& aBegin, const Point& aEnd,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedDrawingEvent(STROKELINE, aDT),
mBegin(aBegin),
mEnd(aEnd),
mPattern(),
mStrokeOptions(aStrokeOptions),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "StrokeLine"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedStrokeLine(S& aStream);
Point mBegin;
Point mEnd;
PatternStorage mPattern;
StrokeOptions mStrokeOptions;
DrawOptions mOptions;
};
class RecordedFill : public RecordedDrawingEvent<RecordedFill> {
public:
RecordedFill(DrawTarget* aDT, ReferencePtr aPath, const Pattern& aPattern,
const DrawOptions& aOptions)
: RecordedDrawingEvent(FILL, aDT),
mPath(aPath),
mPattern(),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Fill"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedFill(S& aStream);
ReferencePtr mPath;
PatternStorage mPattern;
DrawOptions mOptions;
};
class RecordedFillGlyphs : public RecordedDrawingEvent<RecordedFillGlyphs> {
public:
RecordedFillGlyphs(DrawTarget* aDT, ReferencePtr aScaledFont,
const Pattern& aPattern, const DrawOptions& aOptions,
const Glyph* aGlyphs, uint32_t aNumGlyphs)
: RecordedDrawingEvent(FILLGLYPHS, aDT),
mScaledFont(aScaledFont),
mPattern(),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
mNumGlyphs = aNumGlyphs;
mGlyphs = new Glyph[aNumGlyphs];
memcpy(mGlyphs, aGlyphs, sizeof(Glyph) * aNumGlyphs);
}
virtual ~RecordedFillGlyphs();
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "FillGlyphs"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedFillGlyphs(S& aStream);
ReferencePtr mScaledFont;
PatternStorage mPattern;
DrawOptions mOptions;
Glyph* mGlyphs = nullptr;
uint32_t mNumGlyphs = 0;
};
class RecordedMask : public RecordedDrawingEvent<RecordedMask> {
public:
RecordedMask(DrawTarget* aDT, const Pattern& aSource, const Pattern& aMask,
const DrawOptions& aOptions)
: RecordedDrawingEvent(MASK, aDT),
mSource(),
mMask(),
mOptions(aOptions) {
StorePattern(mSource, aSource);
StorePattern(mMask, aMask);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Mask"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedMask(S& aStream);
PatternStorage mSource;
PatternStorage mMask;
DrawOptions mOptions;
};
class RecordedStroke : public RecordedDrawingEvent<RecordedStroke> {
public:
RecordedStroke(DrawTarget* aDT, ReferencePtr aPath, const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedDrawingEvent(STROKE, aDT),
mPath(aPath),
mPattern(),
mStrokeOptions(aStrokeOptions),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Stroke"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedStroke(S& aStream);
ReferencePtr mPath;
PatternStorage mPattern;
StrokeOptions mStrokeOptions;
DrawOptions mOptions;
};
class RecordedClearRect : public RecordedDrawingEvent<RecordedClearRect> {
public:
RecordedClearRect(DrawTarget* aDT, const Rect& aRect)
: RecordedDrawingEvent(CLEARRECT, aDT), mRect(aRect) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "ClearRect"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedClearRect(S& aStream);
Rect mRect;
};
class RecordedCopySurface : public RecordedDrawingEvent<RecordedCopySurface> {
public:
RecordedCopySurface(DrawTarget* aDT, ReferencePtr aSourceSurface,
const IntRect& aSourceRect, const IntPoint& aDest)
: RecordedDrawingEvent(COPYSURFACE, aDT),
mSourceSurface(aSourceSurface),
mSourceRect(aSourceRect),
mDest(aDest) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "CopySurface"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedCopySurface(S& aStream);
ReferencePtr mSourceSurface;
IntRect mSourceRect;
IntPoint mDest;
};
class RecordedPushClip : public RecordedDrawingEvent<RecordedPushClip> {
public:
RecordedPushClip(DrawTarget* aDT, ReferencePtr aPath)
: RecordedDrawingEvent(PUSHCLIP, aDT), mPath(aPath) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "PushClip"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedPushClip(S& aStream);
ReferencePtr mPath;
};
class RecordedPushClipRect : public RecordedDrawingEvent<RecordedPushClipRect> {
public:
RecordedPushClipRect(DrawTarget* aDT, const Rect& aRect)
: RecordedDrawingEvent(PUSHCLIPRECT, aDT), mRect(aRect) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "PushClipRect"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedPushClipRect(S& aStream);
Rect mRect;
};
class RecordedPopClip : public RecordedDrawingEvent<RecordedPopClip> {
public:
MOZ_IMPLICIT RecordedPopClip(DrawTarget* aDT)
: RecordedDrawingEvent(POPCLIP, aDT) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "PopClip"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedPopClip(S& aStream);
};
class RecordedPushLayer : public RecordedDrawingEvent<RecordedPushLayer> {
public:
RecordedPushLayer(DrawTarget* aDT, bool aOpaque, Float aOpacity,
SourceSurface* aMask, const Matrix& aMaskTransform,
const IntRect& aBounds, bool aCopyBackground)
: RecordedDrawingEvent(PUSHLAYER, aDT),
mOpaque(aOpaque),
mOpacity(aOpacity),
mMask(aMask),
mMaskTransform(aMaskTransform),
mBounds(aBounds),
mCopyBackground(aCopyBackground) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "PushLayer"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedPushLayer(S& aStream);
bool mOpaque;
Float mOpacity;
ReferencePtr mMask;
Matrix mMaskTransform;
IntRect mBounds;
bool mCopyBackground;
};
class RecordedPushLayerWithBlend
: public RecordedDrawingEvent<RecordedPushLayerWithBlend> {
public:
RecordedPushLayerWithBlend(DrawTarget* aDT, bool aOpaque, Float aOpacity,
SourceSurface* aMask, const Matrix& aMaskTransform,
const IntRect& aBounds, bool aCopyBackground,
CompositionOp aCompositionOp)
: RecordedDrawingEvent(PUSHLAYERWITHBLEND, aDT),
mOpaque(aOpaque),
mOpacity(aOpacity),
mMask(aMask),
mMaskTransform(aMaskTransform),
mBounds(aBounds),
mCopyBackground(aCopyBackground),
mCompositionOp(aCompositionOp) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
std::string GetName() const override { return "PushLayerWithBlend"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedPushLayerWithBlend(S& aStream);
bool mOpaque;
Float mOpacity;
ReferencePtr mMask;
Matrix mMaskTransform;
IntRect mBounds;
bool mCopyBackground;
CompositionOp mCompositionOp;
};
class RecordedPopLayer : public RecordedDrawingEvent<RecordedPopLayer> {
public:
MOZ_IMPLICIT RecordedPopLayer(DrawTarget* aDT)
: RecordedDrawingEvent(POPLAYER, aDT) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "PopLayer"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedPopLayer(S& aStream);
};
class RecordedSetTransform : public RecordedDrawingEvent<RecordedSetTransform> {
public:
RecordedSetTransform(DrawTarget* aDT, const Matrix& aTransform)
: RecordedDrawingEvent(SETTRANSFORM, aDT), mTransform(aTransform) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "SetTransform"; }
Matrix mTransform;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedSetTransform(S& aStream);
};
class RecordedDrawSurface : public RecordedDrawingEvent<RecordedDrawSurface> {
public:
RecordedDrawSurface(DrawTarget* aDT, ReferencePtr aRefSource,
const Rect& aDest, const Rect& aSource,
const DrawSurfaceOptions& aDSOptions,
const DrawOptions& aOptions)
: RecordedDrawingEvent(DRAWSURFACE, aDT),
mRefSource(aRefSource),
mDest(aDest),
mSource(aSource),
mDSOptions(aDSOptions),
mOptions(aOptions) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "DrawSurface"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawSurface(S& aStream);
ReferencePtr mRefSource;
Rect mDest;
Rect mSource;
DrawSurfaceOptions mDSOptions;
DrawOptions mOptions;
};
class RecordedDrawDependentSurface
: public RecordedDrawingEvent<RecordedDrawDependentSurface> {
public:
RecordedDrawDependentSurface(DrawTarget* aDT, uint64_t aId, const Rect& aDest)
: RecordedDrawingEvent(DRAWDEPENDENTSURFACE, aDT),
mId(aId),
mDest(aDest) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "DrawDependentSurface"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawDependentSurface(S& aStream);
uint64_t mId;
Rect mDest;
};
class RecordedDrawSurfaceWithShadow
: public RecordedDrawingEvent<RecordedDrawSurfaceWithShadow> {
public:
RecordedDrawSurfaceWithShadow(DrawTarget* aDT, ReferencePtr aRefSource,
const Point& aDest,
const ShadowOptions& aShadow, CompositionOp aOp)
: RecordedDrawingEvent(DRAWSURFACEWITHSHADOW, aDT),
mRefSource(aRefSource),
mDest(aDest),
mShadow(aShadow),
mOp(aOp) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "DrawSurfaceWithShadow"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawSurfaceWithShadow(S& aStream);
ReferencePtr mRefSource;
Point mDest;
ShadowOptions mShadow;
CompositionOp mOp;
};
class RecordedDrawFilter : public RecordedDrawingEvent<RecordedDrawFilter> {
public:
RecordedDrawFilter(DrawTarget* aDT, ReferencePtr aNode,
const Rect& aSourceRect, const Point& aDestPoint,
const DrawOptions& aOptions)
: RecordedDrawingEvent(DRAWFILTER, aDT),
mNode(aNode),
mSourceRect(aSourceRect),
mDestPoint(aDestPoint),
mOptions(aOptions) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "DrawFilter"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawFilter(S& aStream);
ReferencePtr mNode;
Rect mSourceRect;
Point mDestPoint;
DrawOptions mOptions;
};
class RecordedPathCreation : public RecordedEventDerived<RecordedPathCreation> {
public:
MOZ_IMPLICIT RecordedPathCreation(PathRecording* aPath);
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Path Creation"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
FillRule mFillRule;
RefPtr<PathRecording> mPath;
UniquePtr<PathOps> mPathOps;
template <class S>
MOZ_IMPLICIT RecordedPathCreation(S& aStream);
};
class RecordedPathDestruction
: public RecordedEventDerived<RecordedPathDestruction> {
public:
MOZ_IMPLICIT RecordedPathDestruction(PathRecording* aPath)
: RecordedEventDerived(PATHDESTRUCTION), mRefPtr(aPath) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Path Destruction"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedPathDestruction(S& aStream);
};
class RecordedSourceSurfaceCreation
: public RecordedEventDerived<RecordedSourceSurfaceCreation> {
public:
RecordedSourceSurfaceCreation(ReferencePtr aRefPtr, uint8_t* aData,
int32_t aStride, const IntSize& aSize,
SurfaceFormat aFormat)
: RecordedEventDerived(SOURCESURFACECREATION),
mRefPtr(aRefPtr),
mData(aData),
mStride(aStride),
mSize(aSize),
mFormat(aFormat),
mDataOwned(false) {}
~RecordedSourceSurfaceCreation();
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "SourceSurface Creation"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
uint8_t* mData = nullptr;
int32_t mStride;
IntSize mSize;
SurfaceFormat mFormat;
mutable bool mDataOwned;
template <class S>
MOZ_IMPLICIT RecordedSourceSurfaceCreation(S& aStream);
};
class RecordedSourceSurfaceDestruction
: public RecordedEventDerived<RecordedSourceSurfaceDestruction> {
public:
MOZ_IMPLICIT RecordedSourceSurfaceDestruction(ReferencePtr aRefPtr)
: RecordedEventDerived(SOURCESURFACEDESTRUCTION), mRefPtr(aRefPtr) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "SourceSurface Destruction"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedSourceSurfaceDestruction(S& aStream);
};
class RecordedOptimizeSourceSurface
: public RecordedEventDerived<RecordedOptimizeSourceSurface> {
public:
RecordedOptimizeSourceSurface(ReferencePtr aSurface, ReferencePtr aDT,
ReferencePtr aOptimizedSurface)
: RecordedEventDerived(OPTIMIZESOURCESURFACE),
mSurface(aSurface),
mDT(aDT),
mOptimizedSurface(aOptimizedSurface) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "OptimizeSourceSurface"; }
private:
friend class RecordedEvent;
ReferencePtr mSurface;
ReferencePtr mDT;
ReferencePtr mOptimizedSurface;
template <class S>
MOZ_IMPLICIT RecordedOptimizeSourceSurface(S& aStream);
};
class RecordedExternalSurfaceCreation
: public RecordedEventDerived<RecordedExternalSurfaceCreation> {
public:
RecordedExternalSurfaceCreation(ReferencePtr aRefPtr, const uint64_t aKey)
: RecordedEventDerived(EXTERNALSURFACECREATION),
mRefPtr(aRefPtr),
mKey(aKey) {}
~RecordedExternalSurfaceCreation() = default;
virtual bool PlayEvent(Translator* aTranslator) const;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(std::stringstream& aStringStream) const;
virtual std::string GetName() const {
return "SourceSurfaceSharedData Creation";
}
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
uint64_t mKey;
template <class S>
MOZ_IMPLICIT RecordedExternalSurfaceCreation(S& aStream);
};
class RecordedFilterNodeCreation
: public RecordedEventDerived<RecordedFilterNodeCreation> {
public:
RecordedFilterNodeCreation(ReferencePtr aRefPtr, FilterType aType)
: RecordedEventDerived(FILTERNODECREATION),
mRefPtr(aRefPtr),
mType(aType) {}
~RecordedFilterNodeCreation();
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "FilterNode Creation"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
FilterType mType;
template <class S>
MOZ_IMPLICIT RecordedFilterNodeCreation(S& aStream);
};
class RecordedFilterNodeDestruction
: public RecordedEventDerived<RecordedFilterNodeDestruction> {
public:
MOZ_IMPLICIT RecordedFilterNodeDestruction(ReferencePtr aRefPtr)
: RecordedEventDerived(FILTERNODEDESTRUCTION), mRefPtr(aRefPtr) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "FilterNode Destruction"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedFilterNodeDestruction(S& aStream);
};
class RecordedGradientStopsCreation
: public RecordedEventDerived<RecordedGradientStopsCreation> {
public:
RecordedGradientStopsCreation(ReferencePtr aRefPtr, GradientStop* aStops,
uint32_t aNumStops, ExtendMode aExtendMode)
: RecordedEventDerived(GRADIENTSTOPSCREATION),
mRefPtr(aRefPtr),
mStops(aStops),
mNumStops(aNumStops),
mExtendMode(aExtendMode),
mDataOwned(false) {}
~RecordedGradientStopsCreation();
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "GradientStops Creation"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
GradientStop* mStops = nullptr;
uint32_t mNumStops = 0;
ExtendMode mExtendMode;
bool mDataOwned;
template <class S>
MOZ_IMPLICIT RecordedGradientStopsCreation(S& aStream);
};
class RecordedGradientStopsDestruction
: public RecordedEventDerived<RecordedGradientStopsDestruction> {
public:
MOZ_IMPLICIT RecordedGradientStopsDestruction(ReferencePtr aRefPtr)
: RecordedEventDerived(GRADIENTSTOPSDESTRUCTION), mRefPtr(aRefPtr) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "GradientStops Destruction"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedGradientStopsDestruction(S& aStream);
};
class RecordedFlush : public RecordedDrawingEvent<RecordedFlush> {
public:
explicit RecordedFlush(DrawTarget* aDT) : RecordedDrawingEvent(FLUSH, aDT) {}
bool PlayEvent(Translator* aTranslator) const final;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
virtual std::string GetName() const override { return "Flush"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedFlush(S& aStream);
};
class RecordedDetachAllSnapshots
: public RecordedDrawingEvent<RecordedDetachAllSnapshots> {
public:
explicit RecordedDetachAllSnapshots(DrawTarget* aDT)
: RecordedDrawingEvent(DETACHALLSNAPSHOTS, aDT) {}
bool PlayEvent(Translator* aTranslator) const final;
template <class S>
void Record(S& aStream) const;
virtual void OutputSimpleEventInfo(
std::stringstream& aStringStream) const override;
virtual std::string GetName() const override { return "DetachAllSnapshots"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDetachAllSnapshots(S& aStream);
};
class RecordedSnapshot : public RecordedEventDerived<RecordedSnapshot> {
public:
RecordedSnapshot(ReferencePtr aRefPtr, DrawTarget* aDT)
: RecordedEventDerived(SNAPSHOT), mRefPtr(aRefPtr), mDT(aDT) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Snapshot"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
ReferencePtr mDT;
template <class S>
MOZ_IMPLICIT RecordedSnapshot(S& aStream);
};
class RecordedIntoLuminanceSource
: public RecordedEventDerived<RecordedIntoLuminanceSource> {
public:
RecordedIntoLuminanceSource(ReferencePtr aRefPtr, DrawTarget* aDT,
LuminanceType aLuminanceType, float aOpacity)
: RecordedEventDerived(INTOLUMINANCE),
mRefPtr(aRefPtr),
mDT(aDT),
mLuminanceType(aLuminanceType),
mOpacity(aOpacity) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "IntoLuminanceSource"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
ReferencePtr mDT;
LuminanceType mLuminanceType;
float mOpacity;
template <class S>
MOZ_IMPLICIT RecordedIntoLuminanceSource(S& aStream);
};
class RecordedFontData : public RecordedEventDerived<RecordedFontData> {
public:
static void FontDataProc(const uint8_t* aData, uint32_t aSize,
uint32_t aIndex, void* aBaton) {
auto recordedFontData = static_cast<RecordedFontData*>(aBaton);
recordedFontData->SetFontData(aData, aSize, aIndex);
}
explicit RecordedFontData(UnscaledFont* aUnscaledFont)
: RecordedEventDerived(FONTDATA),
mType(aUnscaledFont->GetType()),
mFontDetails() {
mGetFontFileDataSucceeded =
aUnscaledFont->GetFontFileData(&FontDataProc, this) && mData;
}
virtual ~RecordedFontData();
bool IsValid() const { return mGetFontFileDataSucceeded; }
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Font Data"; }
void SetFontData(const uint8_t* aData, uint32_t aSize, uint32_t aIndex);
bool GetFontDetails(RecordedFontDetails& fontDetails);
private:
friend class RecordedEvent;
FontType mType;
uint8_t* mData = nullptr;
RecordedFontDetails mFontDetails;
bool mGetFontFileDataSucceeded;
template <class S>
MOZ_IMPLICIT RecordedFontData(S& aStream);
};
class RecordedFontDescriptor
: public RecordedEventDerived<RecordedFontDescriptor> {
public:
static void FontDescCb(const uint8_t* aData, uint32_t aSize, uint32_t aIndex,
void* aBaton) {
auto recordedFontDesc = static_cast<RecordedFontDescriptor*>(aBaton);
recordedFontDesc->SetFontDescriptor(aData, aSize, aIndex);
}
explicit RecordedFontDescriptor(UnscaledFont* aUnscaledFont)
: RecordedEventDerived(FONTDESC),
mType(aUnscaledFont->GetType()),
mIndex(0),
mRefPtr(aUnscaledFont) {
mHasDesc = aUnscaledFont->GetFontDescriptor(FontDescCb, this);
}
virtual ~RecordedFontDescriptor();
bool IsValid() const { return mHasDesc; }
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "Font Desc"; }
private:
friend class RecordedEvent;
void SetFontDescriptor(const uint8_t* aData, uint32_t aSize, uint32_t aIndex);
bool mHasDesc;
FontType mType;
std::vector<uint8_t> mData;
uint32_t mIndex;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedFontDescriptor(S& aStream);
};
class RecordedUnscaledFontCreation
: public RecordedEventDerived<RecordedUnscaledFontCreation> {
public:
static void FontInstanceDataProc(const uint8_t* aData, uint32_t aSize,
void* aBaton) {
auto recordedUnscaledFontCreation =
static_cast<RecordedUnscaledFontCreation*>(aBaton);
recordedUnscaledFontCreation->SetFontInstanceData(aData, aSize);
}
RecordedUnscaledFontCreation(UnscaledFont* aUnscaledFont,
RecordedFontDetails aFontDetails)
: RecordedEventDerived(UNSCALEDFONTCREATION),
mRefPtr(aUnscaledFont),
mFontDataKey(aFontDetails.fontDataKey),
mIndex(aFontDetails.index) {
aUnscaledFont->GetFontInstanceData(FontInstanceDataProc, this);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "UnscaledFont Creation"; }
void SetFontInstanceData(const uint8_t* aData, uint32_t aSize);
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
uint64_t mFontDataKey;
uint32_t mIndex;
std::vector<uint8_t> mInstanceData;
template <class S>
MOZ_IMPLICIT RecordedUnscaledFontCreation(S& aStream);
};
class RecordedUnscaledFontDestruction
: public RecordedEventDerived<RecordedUnscaledFontDestruction> {
public:
MOZ_IMPLICIT RecordedUnscaledFontDestruction(ReferencePtr aRefPtr)
: RecordedEventDerived(UNSCALEDFONTDESTRUCTION), mRefPtr(aRefPtr) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "UnscaledFont Destruction"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedUnscaledFontDestruction(S& aStream);
};
class RecordedScaledFontCreation
: public RecordedEventDerived<RecordedScaledFontCreation> {
public:
static void FontInstanceDataProc(const uint8_t* aData, uint32_t aSize,
const FontVariation* aVariations,
uint32_t aNumVariations, void* aBaton) {
auto recordedScaledFontCreation =
static_cast<RecordedScaledFontCreation*>(aBaton);
recordedScaledFontCreation->SetFontInstanceData(aData, aSize, aVariations,
aNumVariations);
}
RecordedScaledFontCreation(ScaledFont* aScaledFont,
UnscaledFont* aUnscaledFont)
: RecordedEventDerived(SCALEDFONTCREATION),
mRefPtr(aScaledFont),
mUnscaledFont(aUnscaledFont),
mGlyphSize(aScaledFont->GetSize()) {
aScaledFont->GetFontInstanceData(FontInstanceDataProc, this);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "ScaledFont Creation"; }
void SetFontInstanceData(const uint8_t* aData, uint32_t aSize,
const FontVariation* aVariations,
uint32_t aNumVariations);
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
ReferencePtr mUnscaledFont;
Float mGlyphSize;
std::vector<uint8_t> mInstanceData;
std::vector<FontVariation> mVariations;
template <class S>
MOZ_IMPLICIT RecordedScaledFontCreation(S& aStream);
};
class RecordedScaledFontDestruction
: public RecordedEventDerived<RecordedScaledFontDestruction> {
public:
MOZ_IMPLICIT RecordedScaledFontDestruction(ReferencePtr aRefPtr)
: RecordedEventDerived(SCALEDFONTDESTRUCTION), mRefPtr(aRefPtr) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "ScaledFont Destruction"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedScaledFontDestruction(S& aStream);
};
class RecordedMaskSurface : public RecordedDrawingEvent<RecordedMaskSurface> {
public:
RecordedMaskSurface(DrawTarget* aDT, const Pattern& aPattern,
ReferencePtr aRefMask, const Point& aOffset,
const DrawOptions& aOptions)
: RecordedDrawingEvent(MASKSURFACE, aDT),
mPattern(),
mRefMask(aRefMask),
mOffset(aOffset),
mOptions(aOptions) {
StorePattern(mPattern, aPattern);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "MaskSurface"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedMaskSurface(S& aStream);
PatternStorage mPattern;
ReferencePtr mRefMask;
Point mOffset;
DrawOptions mOptions;
};
class RecordedFilterNodeSetAttribute
: public RecordedEventDerived<RecordedFilterNodeSetAttribute> {
public:
enum ArgType {
ARGTYPE_UINT32,
ARGTYPE_BOOL,
ARGTYPE_FLOAT,
ARGTYPE_SIZE,
ARGTYPE_INTSIZE,
ARGTYPE_INTPOINT,
ARGTYPE_RECT,
ARGTYPE_INTRECT,
ARGTYPE_POINT,
ARGTYPE_MATRIX,
ARGTYPE_MATRIX5X4,
ARGTYPE_POINT3D,
ARGTYPE_COLOR,
ARGTYPE_FLOAT_ARRAY
};
template <typename T>
RecordedFilterNodeSetAttribute(FilterNode* aNode, uint32_t aIndex,
T aArgument, ArgType aArgType)
: RecordedEventDerived(FILTERNODESETATTRIBUTE),
mNode(aNode),
mIndex(aIndex),
mArgType(aArgType) {
mPayload.resize(sizeof(T));
memcpy(&mPayload.front(), &aArgument, sizeof(T));
}
RecordedFilterNodeSetAttribute(FilterNode* aNode, uint32_t aIndex,
const Float* aFloat, uint32_t aSize)
: RecordedEventDerived(FILTERNODESETATTRIBUTE),
mNode(aNode),
mIndex(aIndex),
mArgType(ARGTYPE_FLOAT_ARRAY) {
mPayload.resize(sizeof(Float) * aSize);
memcpy(&mPayload.front(), aFloat, sizeof(Float) * aSize);
}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "SetAttribute"; }
private:
friend class RecordedEvent;
ReferencePtr mNode;
uint32_t mIndex;
ArgType mArgType;
std::vector<uint8_t> mPayload;
template <class S>
MOZ_IMPLICIT RecordedFilterNodeSetAttribute(S& aStream);
};
class RecordedFilterNodeSetInput
: public RecordedEventDerived<RecordedFilterNodeSetInput> {
public:
RecordedFilterNodeSetInput(FilterNode* aNode, uint32_t aIndex,
FilterNode* aInputNode)
: RecordedEventDerived(FILTERNODESETINPUT),
mNode(aNode),
mIndex(aIndex),
mInputFilter(aInputNode),
mInputSurface(nullptr) {}
RecordedFilterNodeSetInput(FilterNode* aNode, uint32_t aIndex,
SourceSurface* aInputSurface)
: RecordedEventDerived(FILTERNODESETINPUT),
mNode(aNode),
mIndex(aIndex),
mInputFilter(nullptr),
mInputSurface(aInputSurface) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
std::string GetName() const override { return "SetInput"; }
private:
friend class RecordedEvent;
ReferencePtr mNode;
uint32_t mIndex;
ReferencePtr mInputFilter;
ReferencePtr mInputSurface;
template <class S>
MOZ_IMPLICIT RecordedFilterNodeSetInput(S& aStream);
};
class RecordedLink : public RecordedDrawingEvent<RecordedLink> {
public:
RecordedLink(DrawTarget* aDT, const char* aDestination, const Rect& aRect)
: RecordedDrawingEvent(LINK, aDT),
mDestination(aDestination),
mRect(aRect) {}
bool PlayEvent(Translator* aTranslator) const override;
template <class S>