Bug 1471761 - Virtualize mType to reduce DrawingCommand size. r=bas

MozReview-Commit-ID: EFcVLZ6amNr

--HG--
extra : rebase_source : 0111dea6e377dff75b70a8b0e6d25f670e57d297
extra : histedit_source : 5bc07620340f71731918a99dcd95dcb3ee3b99c9
This commit is contained in:
Ryan Hunt 2018-06-27 18:26:38 -05:00
Родитель 5233d2ccc5
Коммит ab5640b5e6
2 изменённых файлов: 135 добавлений и 57 удалений

Просмотреть файл

@ -53,20 +53,10 @@ class DrawingCommand
public:
virtual ~DrawingCommand() {}
virtual CommandType GetType() const = 0;
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform = nullptr) const = 0;
virtual void CloneInto(CaptureCommandList* aList) = 0;
virtual void Log(TreeLog& aLog) const = 0;
CommandType GetType() { return mType; }
protected:
explicit DrawingCommand(CommandType aType)
: mType(aType)
{
}
private:
CommandType mType;
};
} // namespace gfx

Просмотреть файл

@ -26,10 +26,8 @@ namespace gfx {
class StrokeOptionsCommand : public DrawingCommand
{
public:
StrokeOptionsCommand(CommandType aType,
const StrokeOptions& aStrokeOptions)
: DrawingCommand(aType)
, mStrokeOptions(aStrokeOptions)
StrokeOptionsCommand(const StrokeOptions& aStrokeOptions)
: mStrokeOptions(aStrokeOptions)
{
// Stroke Options dashes are owned by the caller.
// Have to copy them here so they don't get freed
@ -129,13 +127,17 @@ public:
DrawSurfaceCommand(SourceSurface *aSurface, const Rect& aDest,
const Rect& aSource, const DrawSurfaceOptions& aSurfOptions,
const DrawOptions& aOptions)
: DrawingCommand(DrawSurfaceCommand::Type)
, mSurface(aSurface), mDest(aDest)
: mSurface(aSurface), mDest(aDest)
, mSource(aSource), mSurfOptions(aSurfOptions)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return DrawSurfaceCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(DrawSurfaceCommand)(mSurface, mDest, mSource, mSurfOptions, mOptions);
@ -176,8 +178,7 @@ public:
const Point &aOffset,
Float aSigma,
CompositionOp aOperator)
: DrawingCommand(DrawSurfaceWithShadowCommand::Type),
mSurface(aSurface),
: mSurface(aSurface),
mDest(aDest),
mColor(aColor),
mOffset(aOffset),
@ -186,6 +187,11 @@ public:
{
}
CommandType GetType() const override
{
return DrawSurfaceWithShadowCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(DrawSurfaceWithShadowCommand)(mSurface, mDest, mColor, mOffset, mSigma, mOperator);
@ -224,12 +230,16 @@ class DrawFilterCommand : public DrawingCommand
public:
DrawFilterCommand(FilterNode* aFilter, const Rect& aSourceRect,
const Point& aDestPoint, const DrawOptions& aOptions)
: DrawingCommand(DrawFilterCommand::Type)
, mFilter(aFilter), mSourceRect(aSourceRect)
: mFilter(aFilter), mSourceRect(aSourceRect)
, mDestPoint(aDestPoint), mOptions(aOptions)
{
}
CommandType GetType() const override
{
return DrawFilterCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(DrawFilterCommand)(mFilter, mSourceRect, mDestPoint, mOptions);
@ -274,11 +284,15 @@ class ClearRectCommand : public DrawingCommand
{
public:
explicit ClearRectCommand(const Rect& aRect)
: DrawingCommand(ClearRectCommand::Type)
, mRect(aRect)
: mRect(aRect)
{
}
CommandType GetType() const override
{
return ClearRectCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(ClearRectCommand)(mRect);
@ -307,13 +321,17 @@ public:
CopySurfaceCommand(SourceSurface* aSurface,
const IntRect& aSourceRect,
const IntPoint& aDestination)
: DrawingCommand(CopySurfaceCommand::Type)
, mSurface(aSurface)
: mSurface(aSurface)
, mSourceRect(aSourceRect)
, mDestination(aDestination)
{
}
CommandType GetType() const override
{
return CopySurfaceCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(CopySurfaceCommand)(mSurface, mSourceRect, mDestination);
@ -352,13 +370,17 @@ public:
FillRectCommand(const Rect& aRect,
const Pattern& aPattern,
const DrawOptions& aOptions)
: DrawingCommand(FillRectCommand::Type)
, mRect(aRect)
: mRect(aRect)
, mPattern(aPattern)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return FillRectCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(FillRectCommand)(mRect, mPattern, mOptions);
@ -393,13 +415,18 @@ public:
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: StrokeOptionsCommand(StrokeRectCommand::Type, aStrokeOptions)
: StrokeOptionsCommand(aStrokeOptions)
, mRect(aRect)
, mPattern(aPattern)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return StrokeRectCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(StrokeRectCommand)(mRect, mPattern, mStrokeOptions, mOptions);
@ -435,7 +462,7 @@ public:
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: StrokeOptionsCommand(StrokeLineCommand::Type, aStrokeOptions)
: StrokeOptionsCommand(aStrokeOptions)
, mStart(aStart)
, mEnd(aEnd)
, mPattern(aPattern)
@ -443,6 +470,11 @@ public:
{
}
CommandType GetType() const override
{
return StrokeLineCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(StrokeLineCommand)(mStart, mEnd, mPattern, mStrokeOptions, mOptions);
@ -478,13 +510,17 @@ public:
FillCommand(const Path* aPath,
const Pattern& aPattern,
const DrawOptions& aOptions)
: DrawingCommand(FillCommand::Type)
, mPath(const_cast<Path*>(aPath))
: mPath(const_cast<Path*>(aPath))
, mPattern(aPattern)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return FillCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(FillCommand)(mPath, mPattern, mOptions);
@ -519,13 +555,18 @@ public:
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: StrokeOptionsCommand(StrokeCommand::Type, aStrokeOptions)
: StrokeOptionsCommand(aStrokeOptions)
, mPath(const_cast<Path*>(aPath))
, mPattern(aPattern)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return StrokeCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(StrokeCommand)(mPath, mPattern, mStrokeOptions, mOptions);
@ -561,8 +602,7 @@ public:
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const DrawOptions& aOptions)
: DrawingCommand(FillGlyphsCommand::Type)
, mFont(aFont)
: mFont(aFont)
, mPattern(aPattern)
, mOptions(aOptions)
{
@ -570,6 +610,11 @@ public:
memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs);
}
CommandType GetType() const override
{
return FillGlyphsCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
GlyphBuffer glyphs = {
@ -615,7 +660,7 @@ public:
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions)
: StrokeOptionsCommand(StrokeGlyphsCommand::Type, aStrokeOptions)
: StrokeOptionsCommand(aStrokeOptions)
, mFont(aFont)
, mPattern(aPattern)
, mOptions(aOptions)
@ -624,6 +669,11 @@ public:
memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs);
}
CommandType GetType() const override
{
return StrokeGlyphsCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
GlyphBuffer glyphs = {
@ -666,13 +716,17 @@ public:
MaskCommand(const Pattern& aSource,
const Pattern& aMask,
const DrawOptions& aOptions)
: DrawingCommand(MaskCommand::Type)
, mSource(aSource)
: mSource(aSource)
, mMask(aMask)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return MaskCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(MaskCommand)(mSource, mMask, mOptions);
@ -707,14 +761,18 @@ public:
const SourceSurface* aMask,
const Point& aOffset,
const DrawOptions& aOptions)
: DrawingCommand(MaskSurfaceCommand::Type)
, mSource(aSource)
: mSource(aSource)
, mMask(const_cast<SourceSurface*>(aMask))
, mOffset(aOffset)
, mOptions(aOptions)
{
}
CommandType GetType() const override
{
return MaskSurfaceCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(MaskSurfaceCommand)(mSource, mMask, mOffset, mOptions);
@ -748,11 +806,15 @@ class PushClipCommand : public DrawingCommand
{
public:
explicit PushClipCommand(const Path* aPath)
: DrawingCommand(PushClipCommand::Type)
, mPath(const_cast<Path*>(aPath))
: mPath(const_cast<Path*>(aPath))
{
}
CommandType GetType() const override
{
return PushClipCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(PushClipCommand)(mPath);
@ -779,11 +841,15 @@ class PushClipRectCommand : public DrawingCommand
{
public:
explicit PushClipRectCommand(const Rect& aRect)
: DrawingCommand(PushClipRectCommand::Type)
, mRect(aRect)
: mRect(aRect)
{
}
CommandType GetType() const override
{
return PushClipRectCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(PushClipRectCommand)(mRect);
@ -815,8 +881,7 @@ public:
const Matrix& aMaskTransform,
const IntRect& aBounds,
bool aCopyBackground)
: DrawingCommand(PushLayerCommand::Type)
, mOpaque(aOpaque)
: mOpaque(aOpaque)
, mOpacity(aOpacity)
, mMask(aMask)
, mMaskTransform(aMaskTransform)
@ -825,6 +890,11 @@ public:
{
}
CommandType GetType() const override
{
return PushLayerCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(PushLayerCommand)(mOpaque, mOpacity, mMask, mMaskTransform, mBounds, mCopyBackground);
@ -862,9 +932,11 @@ private:
class PopClipCommand : public DrawingCommand
{
public:
PopClipCommand()
: DrawingCommand(PopClipCommand::Type)
PopClipCommand() {}
CommandType GetType() const override
{
return PopClipCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
@ -889,9 +961,11 @@ public:
class PopLayerCommand : public DrawingCommand
{
public:
PopLayerCommand()
: DrawingCommand(PopLayerCommand::Type)
PopLayerCommand() {}
CommandType GetType() const override
{
return PopLayerCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
@ -918,11 +992,15 @@ class SetTransformCommand : public DrawingCommand
friend class DrawTargetCaptureImpl;
public:
explicit SetTransformCommand(const Matrix& aTransform)
: DrawingCommand(SetTransformCommand::Type)
, mTransform(aTransform)
: mTransform(aTransform)
{
}
CommandType GetType() const override
{
return SetTransformCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(SetTransformCommand)(mTransform);
@ -954,11 +1032,15 @@ class SetPermitSubpixelAACommand : public DrawingCommand
friend class DrawTargetCaptureImpl;
public:
explicit SetPermitSubpixelAACommand(bool aPermitSubpixelAA)
: DrawingCommand(SetPermitSubpixelAACommand::Type)
, mPermitSubpixelAA(aPermitSubpixelAA)
: mPermitSubpixelAA(aPermitSubpixelAA)
{
}
CommandType GetType() const override
{
return SetPermitSubpixelAACommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(SetPermitSubpixelAACommand)(mPermitSubpixelAA);
@ -984,9 +1066,11 @@ private:
class FlushCommand : public DrawingCommand
{
public:
explicit FlushCommand()
: DrawingCommand(FlushCommand::Type)
explicit FlushCommand() {}
CommandType GetType() const override
{
return FlushCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
@ -1012,10 +1096,14 @@ class BlurCommand : public DrawingCommand
{
public:
explicit BlurCommand(const AlphaBoxBlur& aBlur)
: DrawingCommand(BlurCommand::Type)
, mBlur(aBlur)
: mBlur(aBlur)
{}
CommandType GetType() const override
{
return BlurCommand::Type;
}
void CloneInto(CaptureCommandList* aList) override
{
CLONE_INTO(BlurCommand)(mBlur);