Bug 1471761 - Drop unused GetAffectedRect and fix virtual styling. r=bas

MozReview-Commit-ID: 9Gra35FVeQY

--HG--
extra : rebase_source : bf45336df86147657d2e851fadff6c25672d6288
extra : histedit_source : 517be1662712adb718f459f6f2c3a3fe6972e67b
This commit is contained in:
Ryan Hunt 2018-06-27 18:11:38 -05:00
Родитель 533d5ab90b
Коммит 5233d2ccc5
2 изменённых файлов: 20 добавлений и 80 удалений

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

@ -54,7 +54,6 @@ public:
virtual ~DrawingCommand() {}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform = nullptr) const = 0;
virtual bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const { return false; }
virtual void CloneInto(CaptureCommandList* aList) = 0;
virtual void Log(TreeLog& aLog) const = 0;

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

@ -141,7 +141,7 @@ public:
CLONE_INTO(DrawSurfaceCommand)(mSurface, mDest, mSource, mSurfOptions, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->DrawSurface(mSurface, mDest, mSource, mSurfOptions, mOptions);
}
@ -191,7 +191,7 @@ public:
CLONE_INTO(DrawSurfaceWithShadowCommand)(mSurface, mDest, mColor, mOffset, mSigma, mOperator);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->DrawSurfaceWithShadow(mSurface, mDest, mColor, mOffset, mSigma, mOperator);
}
@ -235,7 +235,7 @@ public:
CLONE_INTO(DrawFilterCommand)(mFilter, mSourceRect, mDestPoint, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
RefPtr<FilterNode> filter = mFilter;
if (mFilter->GetBackendType() == FilterBackend::FILTER_BACKEND_CAPTURE) {
@ -284,7 +284,7 @@ public:
CLONE_INTO(ClearRectCommand)(mRect);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->ClearRect(mRect);
}
@ -364,17 +364,11 @@ public:
CLONE_INTO(FillRectCommand)(mRect, mPattern, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->FillRect(mRect, mPattern, mOptions);
}
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const override
{
aDeviceRect = aTransform.TransformBounds(mRect);
return true;
}
void Log(TreeLog& aStream) const override
{
aStream << "[FillRect rect=" << mRect;
@ -411,7 +405,7 @@ public:
CLONE_INTO(StrokeRectCommand)(mRect, mPattern, mStrokeOptions, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->StrokeRect(mRect, mPattern, mStrokeOptions, mOptions);
}
@ -454,7 +448,7 @@ public:
CLONE_INTO(StrokeLineCommand)(mStart, mEnd, mPattern, mStrokeOptions, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->StrokeLine(mStart, mEnd, mPattern, mStrokeOptions, mOptions);
}
@ -496,17 +490,11 @@ public:
CLONE_INTO(FillCommand)(mPath, mPattern, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->Fill(mPath, mPattern, mOptions);
}
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const override
{
aDeviceRect = mPath->GetBounds(aTransform);
return true;
}
void Log(TreeLog& aStream) const override
{
aStream << "[FillCommand path=" << mPath;
@ -524,47 +512,6 @@ private:
DrawOptions mOptions;
};
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 0.707106781186547524400844362104849039
#endif
// The logic for this comes from _cairo_stroke_style_max_distance_from_path
static Rect
PathExtentsToMaxStrokeExtents(const StrokeOptions &aStrokeOptions,
const Rect &aRect,
const Matrix &aTransform)
{
double styleExpansionFactor = 0.5f;
if (aStrokeOptions.mLineCap == CapStyle::SQUARE) {
styleExpansionFactor = M_SQRT1_2;
}
if (aStrokeOptions.mLineJoin == JoinStyle::MITER &&
styleExpansionFactor < M_SQRT2 * aStrokeOptions.mMiterLimit) {
styleExpansionFactor = M_SQRT2 * aStrokeOptions.mMiterLimit;
}
styleExpansionFactor *= aStrokeOptions.mLineWidth;
double dx = styleExpansionFactor * hypot(aTransform._11, aTransform._21);
double dy = styleExpansionFactor * hypot(aTransform._22, aTransform._12);
// Even if the stroke only partially covers a pixel, it must still render to
// full pixels. Round up to compensate for this.
dx = ceil(dx);
dy = ceil(dy);
Rect result = aRect;
result.Inflate(dx, dy);
return result;
}
class StrokeCommand : public StrokeOptionsCommand
{
public:
@ -584,17 +531,11 @@ public:
CLONE_INTO(StrokeCommand)(mPath, mPattern, mStrokeOptions, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->Stroke(mPath, mPattern, mStrokeOptions, mOptions);
}
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const override
{
aDeviceRect = PathExtentsToMaxStrokeExtents(mStrokeOptions, mPath->GetBounds(aTransform), aTransform);
return true;
}
void Log(TreeLog& aStream) const override
{
aStream << "[Stroke path=" << mPath;
@ -638,7 +579,7 @@ public:
CLONE_INTO(FillGlyphsCommand)(mFont, glyphs, mPattern, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
GlyphBuffer buf;
buf.mNumGlyphs = mGlyphs.size();
@ -692,7 +633,7 @@ public:
CLONE_INTO(StrokeGlyphsCommand)(mFont, glyphs, mPattern, mStrokeOptions, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
GlyphBuffer buf;
buf.mNumGlyphs = mGlyphs.size();
@ -737,7 +678,7 @@ public:
CLONE_INTO(MaskCommand)(mSource, mMask, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->Mask(mSource, mMask, mOptions);
}
@ -779,7 +720,7 @@ public:
CLONE_INTO(MaskSurfaceCommand)(mSource, mMask, mOffset, mOptions);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->MaskSurface(mSource, mMask, mOffset, mOptions);
}
@ -817,7 +758,7 @@ public:
CLONE_INTO(PushClipCommand)(mPath);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->PushClip(mPath);
}
@ -848,7 +789,7 @@ public:
CLONE_INTO(PushClipRectCommand)(mRect);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->PushClipRect(mRect);
}
@ -889,7 +830,7 @@ public:
CLONE_INTO(PushLayerCommand)(mOpaque, mOpacity, mMask, mMaskTransform, mBounds, mCopyBackground);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->PushLayer(mOpaque, mOpacity, mMask,
mMaskTransform, mBounds, mCopyBackground);
@ -931,7 +872,7 @@ public:
CLONE_INTO(PopClipCommand)();
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->PopClip();
}
@ -958,7 +899,7 @@ public:
CLONE_INTO(PopLayerCommand)();
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->PopLayer();
}
@ -1053,7 +994,7 @@ public:
CLONE_INTO(FlushCommand)();
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->Flush();
}
@ -1080,7 +1021,7 @@ public:
CLONE_INTO(BlurCommand)(mBlur);
}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override
{
aDT->Blur(mBlur);
}