/* -*- 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 RecordedRemoveAllClips
:
public RecordedEventDerived<RecordedRemoveAllClips> {
public:
MOZ_IMPLICIT RecordedRemoveAllClips()
: RecordedEventDerived(REMOVEALLCLIPS) {}
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 "RemoveAllClips"; }
private:
friend class RecordedEvent;
template <
class S>
MOZ_IMPLICIT RecordedRemoveAllClips(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 =
false;
Float mOpacity = 1.0f;
ReferencePtr mMask;
Matrix mMaskTransform;
IntRect mBounds;
bool mCopyBackground =
false;
};
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 =
false;
Float mOpacity = 1.0f;
ReferencePtr mMask;
Matrix mMaskTransform;
IntRect mBounds;
bool mCopyBackground =
false;
CompositionOp mCompositionOp = CompositionOp::OP_OVER;
};
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 =
false;
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:
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 RecordedEventDerived<RecordedMaskSurface> {
public:
RecordedMaskSurface(
const Pattern& aPattern, ReferencePtr aRefMask,
const Point& aOffset,
const DrawOptions& aOptions)
: RecordedEventDerived(MASKSURFACE),
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 RecordedEventDerived<RecordedLink> {
public:
RecordedLink(
const char* aLocalDest,
const char* aURI,
const Rect& aRect)
: RecordedEventDerived(LINK),
mLocalDest(aLocalDest),
mURI(aURI),
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 "Link"; }
private:
friend class RecordedEvent;
std::string mLocalDest;
std::string mURI;
Rect mRect;
template <
class S>
MOZ_IMPLICIT RecordedLink(S& aStream);
};
class RecordedDestination :
public RecordedEventDerived<RecordedDestination> {
public:
RecordedDestination(
const char* aDestination,
const Point& aPoint)
: RecordedEventDerived(DESTINATION),
mDestination(aDestination),
mPoint(aPoint) {}
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 "Destination"; }
private:
friend class RecordedEvent;
std::string mDestination;
Point mPoint;
template <
class S>
MOZ_IMPLICIT RecordedDestination(S& aStream);
};
static std::string NameFromBackend(BackendType aType) {
switch (aType) {
case BackendType::NONE:
return "None";
case BackendType::DIRECT2D:
return "Direct2D";
default:
return "Unknown";
}
}
template <
class S>
void RecordedEvent::RecordPatternData(S& aStream,
const PatternStorage& aPattern)
const {
WriteElement(aStream, aPattern.mType);
switch (aPattern.mType) {
case PatternType::COLOR: {
WriteElement(aStream, *
reinterpret_cast<
const ColorPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::LINEAR_GRADIENT: {
WriteElement(aStream,
*
reinterpret_cast<
const LinearGradientPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::RADIAL_GRADIENT: {
WriteElement(aStream,
*
reinterpret_cast<
const RadialGradientPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::CONIC_GRADIENT: {
WriteElement(aStream,
*
reinterpret_cast<
const ConicGradientPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::SURFACE: {
WriteElement(aStream, *
reinterpret_cast<
const SurfacePatternStorage*>(
&aPattern.mStorage));
return;
}
default:
return;
}
}
template <
class S>
void RecordedEvent::ReadPatternData(S& aStream,
PatternStorage& aPattern)
const {
ReadElementConstrained(aStream, aPattern.mType, PatternType::COLOR,
kHighestPatternType);
switch (aPattern.mType) {
case PatternType::COLOR: {
ReadElement(aStream,
*
reinterpret_cast<ColorPatternStorage*>(&aPattern.mStorage));
return;
}
case PatternType::LINEAR_GRADIENT: {
ReadElement(aStream, *
reinterpret_cast<LinearGradientPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::RADIAL_GRADIENT: {
ReadElement(aStream, *
reinterpret_cast<RadialGradientPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::CONIC_GRADIENT: {
ReadElement(aStream, *
reinterpret_cast<ConicGradientPatternStorage*>(
&aPattern.mStorage));
return;
}
case PatternType::SURFACE: {
SurfacePatternStorage* sps =
reinterpret_cast<SurfacePatternStorage*>(&aPattern.mStorage);
ReadElement(aStream, *sps);
if (sps->mExtend < ExtendMode::CLAMP ||
sps->mExtend > ExtendMode::REFLECT) {
aStream.SetIsBad();
return;
}
if (sps->mSamplingFilter < SamplingFilter::GOOD ||
sps->mSamplingFilter >= SamplingFilter::SENTINEL) {
aStream.SetIsBad();
}
return;
}
default:
return;
}
}
inline void RecordedEvent::StorePattern(PatternStorage& aDestination,
const Pattern& aSource)
const {
aDestination.mType = aSource.GetType();
switch (aSource.GetType()) {
case PatternType::COLOR: {
reinterpret_cast<ColorPatternStorage*>(&aDestination.mStorage)->mColor =
static_cast<
const ColorPattern*>(&aSource)->mColor;
return;
}
case PatternType::LINEAR_GRADIENT: {
LinearGradientPatternStorage* store =
reinterpret_cast<LinearGradientPatternStorage*>(
&aDestination.mStorage);
const LinearGradientPattern* pat =
static_cast<
const LinearGradientPattern*>(&aSource);
store->mBegin = pat->mBegin;
store->mEnd = pat->mEnd;
store->mMatrix = pat->mMatrix;
store->mStops = pat->mStops.get();
return;
}
case PatternType::RADIAL_GRADIENT: {
RadialGradientPatternStorage* store =
reinterpret_cast<RadialGradientPatternStorage*>(
&aDestination.mStorage);
const RadialGradientPattern* pat =
static_cast<
const RadialGradientPattern*>(&aSource);
store->mCenter1 = pat->mCenter1;
store->mCenter2 = pat->mCenter2;
store->mRadius1 = pat->mRadius1;
store->mRadius2 = pat->mRadius2;
store->mMatrix = pat->mMatrix;
store->mStops = pat->mStops.get();
return;
}
case PatternType::CONIC_GRADIENT: {
ConicGradientPatternStorage* store =
reinterpret_cast<ConicGradientPatternStorage*>(
&aDestination.mStorage);
const ConicGradientPattern* pat =
static_cast<
const ConicGradientPattern*>(&aSource);
store->mCenter = pat->mCenter;
store->mAngle = pat->mAngle;
store->mStartOffset = pat->mStartOffset;
store->mEndOffset = pat->mEndOffset;
store->mMatrix = pat->mMatrix;
store->mStops = pat->mStops.get();
return;
}
case PatternType::SURFACE: {
SurfacePatternStorage* store =
reinterpret_cast<SurfacePatternStorage*>(&aDestination.mStorage);
const SurfacePattern* pat =
static_cast<
const SurfacePattern*>(&aSource);
store->mExtend = pat->mExtendMode;
store->mSamplingFilter = pat->mSamplingFilter;
store->mMatrix = pat->mMatrix;
store->mSurface = pat->mSurface;
store->mSamplingRect = pat->mSamplingRect;
return;
}
}
}
template <
class S>
void RecordedEvent::RecordStrokeOptions(
S& aStream,
const StrokeOptions& aStrokeOptions)
const {
JoinStyle joinStyle = aStrokeOptions.mLineJoin;
CapStyle capStyle = aStrokeOptions.mLineCap;
WriteElement(aStream, uint64_t(aStrokeOptions.mDashLength));
WriteElement(aStream, aStrokeOptions.mLineWidth);
WriteElement(aStream, aStrokeOptions.mMiterLimit);
WriteElement(aStream, joinStyle);
WriteElement(aStream, capStyle);
if (!aStrokeOptions.mDashPattern) {
return;
}
WriteElement(aStream, aStrokeOptions.mDashOffset);
aStream.write((
char*)aStrokeOptions.mDashPattern,
sizeof(
Float) * aStrokeOptions.mDashLength);
}
template <
class S>
void RecordedEvent::ReadStrokeOptions(S& aStream,
StrokeOptions& aStrokeOptions) {
uint64_t dashLength;
JoinStyle joinStyle;
CapStyle capStyle;
ReadElement(aStream, dashLength);
ReadElement(aStream, aStrokeOptions.mLineWidth);
ReadElement(aStream, aStrokeOptions.mMiterLimit);
ReadElementConstrained(aStream, joinStyle, JoinStyle::BEVEL,
JoinStyle::MITER_OR_BEVEL);
ReadElementConstrained(aStream, capStyle, CapStyle::BUTT, CapStyle::SQUARE);
// On 32 bit we truncate the value of dashLength.
// See also bug 811850 for history.
aStrokeOptions.mDashLength = size_t(dashLength);
aStrokeOptions.mLineJoin = joinStyle;
aStrokeOptions.mLineCap = capStyle;
if (!aStrokeOptions.mDashLength || !aStream.good()) {
return;
}
ReadElement(aStream, aStrokeOptions.mDashOffset);
mDashPatternStorage.resize(aStrokeOptions.mDashLength);
aStrokeOptions.mDashPattern = &mDashPatternStorage.front();
aStream.read((
char*)aStrokeOptions.mDashPattern,
sizeof(
Float) * aStrokeOptions.mDashLength);
}
template <
class S>
static void ReadDrawOptions(S& aStream, DrawOptions& aDrawOptions) {
ReadElement(aStream, aDrawOptions);
if (aDrawOptions.mAntialiasMode < AntialiasMode::NONE ||
aDrawOptions.mAntialiasMode > AntialiasMode::
DEFAULT) {
aStream.SetIsBad();
return;
}
if (aDrawOptions.mCompositionOp < CompositionOp::OP_CLEAR ||
aDrawOptions.mCompositionOp > CompositionOp::OP_COUNT) {
aStream.SetIsBad();
}
}
template <
class S>
static void ReadDrawSurfaceOptions(S& aStream,
DrawSurfaceOptions& aDrawSurfaceOptions) {
ReadElement(aStream, aDrawSurfaceOptions);
if (aDrawSurfaceOptions.mSamplingFilter < SamplingFilter::GOOD ||
aDrawSurfaceOptions.mSamplingFilter >= SamplingFilter::SENTINEL) {
aStream.SetIsBad();
return;
}
if (aDrawSurfaceOptions.mSamplingBounds < SamplingBounds::UNBOUNDED ||
aDrawSurfaceOptions.mSamplingBounds > SamplingBounds::BOUNDED) {
aStream.SetIsBad();
}
}
inline void RecordedEvent::OutputSimplePatternInfo(
const PatternStorage& aStorage, std::stringstream& aOutput)
const {
switch (aStorage.mType) {
case PatternType::COLOR: {
const DeviceColor color =
reinterpret_cast<
const ColorPatternStorage*>(&aStorage.mStorage)
->mColor;
aOutput <<
"DeviceColor: (" << color.r <<
", " << color.g <<
", "
<< color.b <<
", " << color.a <<
")";
return;
}
case PatternType::LINEAR_GRADIENT: {
const LinearGradientPatternStorage* store =
reinterpret_cast<
const LinearGradientPatternStorage*>(
&aStorage.mStorage);
aOutput <<
"LinearGradient (" << store->mBegin.x <<
", "
<< store->mBegin.y <<
") - (" << store->mEnd.x <<
", "
<< store->mEnd.y <<
") Stops: " << store->mStops;
return;
}
case PatternType::RADIAL_GRADIENT: {
const RadialGradientPatternStorage* store =
reinterpret_cast<
const RadialGradientPatternStorage*>(
&aStorage.mStorage);
aOutput <<
"RadialGradient (Center 1: (" << store->mCenter1.x <<
", "
<< store->mCenter2.y <<
") Radius 2: " << store->mRadius2;
return;
}
case PatternType::CONIC_GRADIENT: {
const ConicGradientPatternStorage* store =
reinterpret_cast<
const ConicGradientPatternStorage*>(
&aStorage.mStorage);
aOutput <<
"ConicGradient (Center: (" << store->mCenter.x <<
", "
<< store->mCenter.y <<
") Angle: " << store->mAngle
<<
" Range:" << store->mStartOffset <<
" - " << store->mEndOffset;
return;
}
case PatternType::SURFACE: {
const SurfacePatternStorage* store =
reinterpret_cast<
const SurfacePatternStorage*>(&aStorage.mStorage);
aOutput <<
"Surface (0x" << store->mSurface <<
")";
return;
}
}
}
inline bool RecordedDrawTargetCreation::PlayEvent(
Translator* aTranslator)
const {
RefPtr<DrawTarget> newDT =
aTranslator->CreateDrawTarget(mRefPtr, mRect.Size(), mFormat);
// If we couldn't create a DrawTarget this will probably cause us to crash
// with nullptr later in the playback, so return false to abort.
if (!newDT) {
return false;
}
if (mHasExistingData) {
Rect dataRect(0, 0, mExistingData->GetSize().width,
mExistingData->GetSize().height);
newDT->DrawSurface(mExistingData, dataRect, dataRect);
}
return true;
}
template <
class S>
void RecordedDrawTargetCreation::Record(S& aStream)
const {
WriteElement(aStream, mRefPtr);
WriteElement(aStream, mBackendType);
WriteElement(aStream, mRect);
WriteElement(aStream, mFormat);
WriteElement(aStream, mHasExistingData);
if (mHasExistingData) {
MOZ_ASSERT(mExistingData);
MOZ_ASSERT(mExistingData->GetSize() == mRect.Size());
RefPtr<DataSourceSurface> dataSurf = mExistingData->GetDataSurface();
DataSourceSurface::ScopedMap map(dataSurf, DataSourceSurface::READ);
for (
int y = 0; y < mRect.height; y++) {
aStream.write((
const char*)map.GetData() + y * map.GetStride(),
BytesPerPixel(mFormat) * mRect.width);
}
}
}
template <
class S>
RecordedDrawTargetCreation::RecordedDrawTargetCreation(S& aStream)
: RecordedEventDerived(DRAWTARGETCREATION), mExistingData(nullptr) {
ReadElement(aStream, mRefPtr);
ReadElementConstrained(aStream, mBackendType, BackendType::NONE,
BackendType::WEBRENDER_TEXT);
ReadElement(aStream, mRect);
ReadElementConstrained(aStream, mFormat, SurfaceFormat::A8R8G8B8_UINT32,
SurfaceFormat::UNKNOWN);
ReadElement(aStream, mHasExistingData);
if (mHasExistingData) {
RefPtr<DataSourceSurface> dataSurf =
Factory::CreateDataSourceSurface(mRect.Size(), mFormat);
if (!dataSurf) {
gfxWarning()
<<
"RecordedDrawTargetCreation had to reset mHasExistingData";
mHasExistingData =
false;
return;
}
DataSourceSurface::ScopedMap map(dataSurf, DataSourceSurface::READ);
for (
int y = 0; y < mRect.height; y++) {
--> --------------------
--> maximum size reached
--> --------------------