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"
#include "mozilla/layers/LayersSurfaces.h"
namespace mozilla {
namespace gfx {
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 = false;
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 RecordedSetCurrentDrawTarget
: public RecordedEventDerived<RecordedSetCurrentDrawTarget> {
public:
MOZ_IMPLICIT RecordedSetCurrentDrawTarget(ReferencePtr aRefPtr)
: RecordedEventDerived(SETCURRENTDRAWTARGET), 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 "SetCurrentDrawTarget"; }
ReferencePtr mRefPtr;
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedSetCurrentDrawTarget(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 RecordedEventDerived<RecordedCreateClippedDrawTarget> {
public:
RecordedCreateClippedDrawTarget(ReferencePtr aRefPtr, const Rect& aBounds,
SurfaceFormat aFormat)
: RecordedEventDerived(CREATECLIPPEDDRAWTARGET),
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 RecordedEventDerived<RecordedCreateDrawTargetForFilter> {
public:
RecordedCreateDrawTargetForFilter(ReferencePtr aRefPtr,
const IntSize& aMaxSize,
SurfaceFormat aFormat, FilterNode* aFilter,
FilterNode* aSource,
const Rect& aSourceRect,
const Point& aDestPoint)
: RecordedEventDerived(CREATEDRAWTARGETFORFILTER),
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 RecordedEventDerived<RecordedFillRect> {
public:
RecordedFillRect(const Rect& aRect, const Pattern& aPattern,
const DrawOptions& aOptions)
: RecordedEventDerived(FILLRECT),
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 RecordedEventDerived<RecordedStrokeRect> {
public:
RecordedStrokeRect(const Rect& aRect, const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedEventDerived(STROKERECT),
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 RecordedEventDerived<RecordedStrokeLine> {
public:
RecordedStrokeLine(const Point& aBegin, const Point& aEnd,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedEventDerived(STROKELINE),
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 RecordedStrokeCircle : public RecordedEventDerived<RecordedStrokeCircle> {
public:
RecordedStrokeCircle(Circle aCircle, const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedEventDerived(STROKECIRCLE),
mCircle(aCircle),
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 "StrokeCircle"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedStrokeCircle(S& aStream);
Circle mCircle;
PatternStorage mPattern;
StrokeOptions mStrokeOptions;
DrawOptions mOptions;
};
class RecordedFill : public RecordedEventDerived<RecordedFill> {
public:
RecordedFill(ReferencePtr aPath, const Pattern& aPattern,
const DrawOptions& aOptions)
: RecordedEventDerived(FILL),
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 RecordedFillCircle : public RecordedEventDerived<RecordedFillCircle> {
public:
RecordedFillCircle(Circle aCircle, const Pattern& aPattern,
const DrawOptions& aOptions)
: RecordedEventDerived(FILLCIRCLE),
mCircle(aCircle),
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 "FillCircle"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedFillCircle(S& aStream);
Circle mCircle;
PatternStorage mPattern;
DrawOptions mOptions;
};
template <class Derived>
class RecordedDrawGlyphs : public RecordedEventDerived<Derived> {
public:
RecordedDrawGlyphs(RecordedEvent::EventType aType, ReferencePtr aScaledFont,
const Pattern& aPattern, const DrawOptions& aOptions,
const Glyph* aGlyphs, uint32_t aNumGlyphs)
: RecordedEventDerived<Derived>(aType),
mScaledFont(aScaledFont),
mPattern(),
mOptions(aOptions) {
this->StorePattern(mPattern, aPattern);
mNumGlyphs = aNumGlyphs;
mGlyphs = new Glyph[aNumGlyphs];
memcpy(mGlyphs, aGlyphs, sizeof(Glyph) * aNumGlyphs);
}
virtual ~RecordedDrawGlyphs();
bool PlayEvent(Translator* aTranslator) const override;
template <class S>
void Record(S& aStream) const;
void OutputSimpleEventInfo(std::stringstream& aStringStream) const override;
protected:
friend class RecordedEvent;
template <class S>
RecordedDrawGlyphs(RecordedEvent::EventType aType, S& aStream);
virtual void DrawGlyphs(DrawTarget* aDT, ScaledFont* aScaledFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern) const = 0;
ReferencePtr mScaledFont;
PatternStorage mPattern;
DrawOptions mOptions;
Glyph* mGlyphs = nullptr;
uint32_t mNumGlyphs = 0;
};
class RecordedFillGlyphs : public RecordedDrawGlyphs<RecordedFillGlyphs> {
public:
RecordedFillGlyphs(ReferencePtr aScaledFont, const Pattern& aPattern,
const DrawOptions& aOptions, const Glyph* aGlyphs,
uint32_t aNumGlyphs)
: RecordedDrawGlyphs(FILLGLYPHS, aScaledFont, aPattern, aOptions, aGlyphs,
aNumGlyphs) {}
std::string GetName() const override { return "FillGlyphs"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedFillGlyphs(S& aStream)
: RecordedDrawGlyphs(FILLGLYPHS, aStream) {}
void DrawGlyphs(DrawTarget* aDT, ScaledFont* aScaledFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern) const override {
aDT->FillGlyphs(aScaledFont, aBuffer, aPattern, mOptions);
}
};
class RecordedStrokeGlyphs : public RecordedDrawGlyphs<RecordedStrokeGlyphs> {
public:
RecordedStrokeGlyphs(ReferencePtr aScaledFont, const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions, const Glyph* aGlyphs,
uint32_t aNumGlyphs)
: RecordedDrawGlyphs(STROKEGLYPHS, aScaledFont, aPattern, aOptions,
aGlyphs, aNumGlyphs),
mStrokeOptions(aStrokeOptions) {}
std::string GetName() const override { return "StrokeGlyphs"; }
template <class S>
void Record(S& aStream) const {
RecordedDrawGlyphs::Record(aStream);
RecordStrokeOptions(aStream, mStrokeOptions);
}
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedStrokeGlyphs(S& aStream)
: RecordedDrawGlyphs(STROKEGLYPHS, aStream) {
ReadStrokeOptions(aStream, mStrokeOptions);
}
void DrawGlyphs(DrawTarget* aDT, ScaledFont* aScaledFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern) const override {
aDT->StrokeGlyphs(aScaledFont, aBuffer, aPattern, mStrokeOptions, mOptions);
}
StrokeOptions mStrokeOptions;
};
class RecordedMask : public RecordedEventDerived<RecordedMask> {
public:
RecordedMask(const Pattern& aSource, const Pattern& aMask,
const DrawOptions& aOptions)
: RecordedEventDerived(MASK), 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 RecordedEventDerived<RecordedStroke> {
public:
RecordedStroke(ReferencePtr aPath, const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: RecordedEventDerived(STROKE),
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 RecordedEventDerived<RecordedClearRect> {
public:
explicit RecordedClearRect(const Rect& aRect)
: RecordedEventDerived(CLEARRECT), 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 RecordedEventDerived<RecordedCopySurface> {
public:
RecordedCopySurface(ReferencePtr aSourceSurface, const IntRect& aSourceRect,
const IntPoint& aDest)
: RecordedEventDerived(COPYSURFACE),
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 RecordedEventDerived<RecordedPushClip> {
public:
explicit RecordedPushClip(ReferencePtr aPath)
: RecordedEventDerived(PUSHCLIP), 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 RecordedEventDerived<RecordedPushClipRect> {
public:
explicit RecordedPushClipRect(const Rect& aRect)
: RecordedEventDerived(PUSHCLIPRECT), 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 RecordedEventDerived<RecordedPopClip> {
public:
MOZ_IMPLICIT RecordedPopClip() : RecordedEventDerived(POPCLIP) {}
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 RecordedEventDerived<RecordedPushLayer> {
public:
RecordedPushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
const Matrix& aMaskTransform, const IntRect& aBounds,
bool aCopyBackground)
: RecordedEventDerived(PUSHLAYER),
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 RecordedEventDerived<RecordedPushLayerWithBlend> {
public:
RecordedPushLayerWithBlend(bool aOpaque, Float aOpacity, SourceSurface* aMask,
const Matrix& aMaskTransform,
const IntRect& aBounds, bool aCopyBackground,
CompositionOp aCompositionOp)
: RecordedEventDerived(PUSHLAYERWITHBLEND),
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 RecordedEventDerived<RecordedPopLayer> {
public:
RecordedPopLayer() : RecordedEventDerived(POPLAYER) {}
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 RecordedSetPermitSubpixelAA
: public RecordedEventDerived<RecordedSetPermitSubpixelAA> {
public:
explicit RecordedSetPermitSubpixelAA(bool aPermitSubpixelAA)
: RecordedEventDerived(SETPERMITSUBPIXELAA),
mPermitSubpixelAA(aPermitSubpixelAA) {}
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 "SetPermitSubpixelAA"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedSetPermitSubpixelAA(S& aStream);
bool mPermitSubpixelAA = false;
};
class RecordedSetTransform : public RecordedEventDerived<RecordedSetTransform> {
public:
explicit RecordedSetTransform(const Matrix& aTransform)
: RecordedEventDerived(SETTRANSFORM), 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 RecordedEventDerived<RecordedDrawSurface> {
public:
RecordedDrawSurface(ReferencePtr aRefSource, const Rect& aDest,
const Rect& aSource, const DrawSurfaceOptions& aDSOptions,
const DrawOptions& aOptions)
: RecordedEventDerived(DRAWSURFACE),
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 RecordedDrawSurfaceDescriptor
: public RecordedEventDerived<RecordedDrawSurfaceDescriptor> {
public:
RecordedDrawSurfaceDescriptor(const layers::SurfaceDescriptor& aDesc,
const Rect& aDest, const Rect& aSource,
const DrawSurfaceOptions& aDSOptions,
const DrawOptions& aOptions)
: RecordedEventDerived(DRAWSURFACEDESCRIPTOR),
mDesc(aDesc),
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 "DrawSurfaceDescriptor"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawSurfaceDescriptor(S& aStream);
layers::SurfaceDescriptor mDesc;
Rect mDest;
Rect mSource;
DrawSurfaceOptions mDSOptions;
DrawOptions mOptions;
};
class RecordedDrawDependentSurface
: public RecordedEventDerived<RecordedDrawDependentSurface> {
public:
RecordedDrawDependentSurface(uint64_t aId, const Rect& aDest)
: RecordedEventDerived(DRAWDEPENDENTSURFACE), 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 RecordedEventDerived<RecordedDrawSurfaceWithShadow> {
public:
RecordedDrawSurfaceWithShadow(ReferencePtr aRefSource, const Point& aDest,
const ShadowOptions& aShadow, CompositionOp aOp)
: RecordedEventDerived(DRAWSURFACEWITHSHADOW),
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 RecordedDrawShadow : public RecordedEventDerived<RecordedDrawShadow> {
public:
RecordedDrawShadow(ReferencePtr aPath, const Pattern& aPattern,
const ShadowOptions& aShadow, const DrawOptions& aOptions,
const StrokeOptions* aStrokeOptions)
: RecordedEventDerived(DRAWSHADOW),
mPath(aPath),
mPattern(),
mShadow(aShadow),
mOptions(aOptions),
mHasStrokeOptions(!!aStrokeOptions),
mStrokeOptions(aStrokeOptions ? *aStrokeOptions : StrokeOptions()) {
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 "DrawShadow"; }
private:
friend class RecordedEvent;
template <class S>
MOZ_IMPLICIT RecordedDrawShadow(S& aStream);
ReferencePtr mPath;
PatternStorage mPattern;
ShadowOptions mShadow;
DrawOptions mOptions;
bool mHasStrokeOptions;
StrokeOptions mStrokeOptions;
};
class RecordedDrawFilter : public RecordedEventDerived<RecordedDrawFilter> {
public:
RecordedDrawFilter(ReferencePtr aNode, const Rect& aSourceRect,
const Point& aDestPoint, const DrawOptions& aOptions)
: RecordedEventDerived(DRAWFILTER),
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 mDT;
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 aOptimizedSurface)
: RecordedEventDerived(OPTIMIZESOURCESURFACE),
mSurface(aSurface),
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 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 RecordedEventDerived<RecordedFlush> {
public:
explicit RecordedFlush() : RecordedEventDerived(FLUSH) {}
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 RecordedEventDerived<RecordedDetachAllSnapshots> {
public:
explicit RecordedDetachAllSnapshots()
: RecordedEventDerived(DETACHALLSNAPSHOTS) {}
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:
explicit RecordedSnapshot(ReferencePtr aRefPtr)
: RecordedEventDerived(SNAPSHOT), 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 "Snapshot"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
template <class S>
MOZ_IMPLICIT RecordedSnapshot(S& aStream);
};
class RecordedIntoLuminanceSource
: public RecordedEventDerived<RecordedIntoLuminanceSource> {
public:
RecordedIntoLuminanceSource(ReferencePtr aRefPtr,
LuminanceType aLuminanceType, float aOpacity)
: RecordedEventDerived(INTOLUMINANCE),
mRefPtr(aRefPtr),
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;
LuminanceType mLuminanceType;
float mOpacity;
template <class S>
MOZ_IMPLICIT RecordedIntoLuminanceSource(S& aStream);
};
class RecordedExtractSubrect
: public RecordedEventDerived<RecordedExtractSubrect> {
public:
RecordedExtractSubrect(ReferencePtr aRefPtr, ReferencePtr aSourceSurface,
const IntRect& aSubrect)
: RecordedEventDerived(EXTRACTSUBRECT),
mRefPtr(aRefPtr),
mSourceSurface(aSourceSurface),
mSubrect(aSubrect) {}
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 "ExtractSubrect"; }
private:
friend class RecordedEvent;
ReferencePtr mRefPtr;
ReferencePtr mSourceSurface;
IntRect mSubrect;
template <class S>
MOZ_IMPLICIT RecordedExtractSubrect(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:
</