Bug 1083101 - Make gfx::DrawingCommand methods const. r=jrmuizel

This commit is contained in:
Nicolas Silva 2015-09-24 17:35:27 +02:00
parent c41df579c1
commit 1ccd18a5b5
3 changed files with 25 additions and 25 deletions

View File

@ -44,9 +44,9 @@ class DrawingCommand
public: public:
virtual ~DrawingCommand() {} virtual ~DrawingCommand() {}
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform = nullptr) = 0; virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform = nullptr) const = 0;
virtual bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) { return false; } virtual bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const { return false; }
protected: protected:
explicit DrawingCommand(CommandType aType) explicit DrawingCommand(CommandType aType)
@ -137,7 +137,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->DrawSurface(mSurface, mDest, mSource, mSurfOptions, mOptions); aDT->DrawSurface(mSurface, mDest, mSource, mSurfOptions, mOptions);
} }
@ -161,7 +161,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->DrawFilter(mFilter, mSourceRect, mDestPoint, mOptions); aDT->DrawFilter(mFilter, mSourceRect, mDestPoint, mOptions);
} }
@ -182,7 +182,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->ClearRect(mRect); aDT->ClearRect(mRect);
} }
@ -204,7 +204,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform) const
{ {
MOZ_ASSERT(!aTransform || !aTransform->HasNonIntegerTranslation()); MOZ_ASSERT(!aTransform || !aTransform->HasNonIntegerTranslation());
Point dest(Float(mDestination.x), Float(mDestination.y)); Point dest(Float(mDestination.x), Float(mDestination.y));
@ -233,12 +233,12 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->FillRect(mRect, mPattern, mOptions); aDT->FillRect(mRect, mPattern, mOptions);
} }
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const
{ {
aDeviceRect = aTransform.TransformBounds(mRect); aDeviceRect = aTransform.TransformBounds(mRect);
return true; return true;
@ -270,7 +270,7 @@ public:
} }
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->StrokeRect(mRect, mPattern, mStrokeOptions, mOptions); aDT->StrokeRect(mRect, mPattern, mStrokeOptions, mOptions);
} }
@ -300,7 +300,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->StrokeLine(mStart, mEnd, mPattern, mStrokeOptions, mOptions); aDT->StrokeLine(mStart, mEnd, mPattern, mStrokeOptions, mOptions);
} }
@ -326,12 +326,12 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->Fill(mPath, mPattern, mOptions); aDT->Fill(mPath, mPattern, mOptions);
} }
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const
{ {
aDeviceRect = mPath->GetBounds(aTransform); aDeviceRect = mPath->GetBounds(aTransform);
return true; return true;
@ -398,12 +398,12 @@ public:
} }
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->Stroke(mPath, mPattern, mStrokeOptions, mOptions); aDT->Stroke(mPath, mPattern, mStrokeOptions, mOptions);
} }
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const
{ {
aDeviceRect = PathExtentsToMaxStrokeExtents(mStrokeOptions, mPath->GetBounds(aTransform), aTransform); aDeviceRect = PathExtentsToMaxStrokeExtents(mStrokeOptions, mPath->GetBounds(aTransform), aTransform);
return true; return true;
@ -435,7 +435,7 @@ public:
memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs); memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs);
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
GlyphBuffer buf; GlyphBuffer buf;
buf.mNumGlyphs = mGlyphs.size(); buf.mNumGlyphs = mGlyphs.size();
@ -464,7 +464,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->Mask(mSource, mMask, mOptions); aDT->Mask(mSource, mMask, mOptions);
} }
@ -490,7 +490,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->MaskSurface(mSource, mMask, mOffset, mOptions); aDT->MaskSurface(mSource, mMask, mOffset, mOptions);
} }
@ -511,7 +511,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->PushClip(mPath); aDT->PushClip(mPath);
} }
@ -529,7 +529,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->PushClipRect(mRect); aDT->PushClipRect(mRect);
} }
@ -546,7 +546,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->PopClip(); aDT->PopClip();
} }
@ -561,7 +561,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aMatrix) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aMatrix) const
{ {
if (aMatrix) { if (aMatrix) {
aDT->SetTransform(mTransform * (*aMatrix)); aDT->SetTransform(mTransform * (*aMatrix));
@ -582,7 +582,7 @@ public:
{ {
} }
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
{ {
aDT->Flush(); aDT->Flush();
} }

View File

@ -70,7 +70,7 @@ DrawingJob::Run()
{ {
while (mCursor < mCommandOffsets.size()) { while (mCursor < mCommandOffsets.size()) {
DrawingCommand* cmd = mCommandBuffer->GetDrawingCommand(mCommandOffsets[mCursor]); const DrawingCommand* cmd = mCommandBuffer->GetDrawingCommand(mCommandOffsets[mCursor]);
if (!cmd) { if (!cmd) {
return JobStatus::Error; return JobStatus::Error;
@ -89,7 +89,7 @@ DrawingJob::~DrawingJob()
Clear(); Clear();
} }
DrawingCommand* const DrawingCommand*
CommandBuffer::GetDrawingCommand(ptrdiff_t aId) CommandBuffer::GetDrawingCommand(ptrdiff_t aId)
{ {
return static_cast<DrawingCommand*>(mStorage.GetStorage(aId)); return static_cast<DrawingCommand*>(mStorage.GetStorage(aId));

View File

@ -43,7 +43,7 @@ public:
~CommandBuffer(); ~CommandBuffer();
DrawingCommand* GetDrawingCommand(ptrdiff_t aId); const DrawingCommand* GetDrawingCommand(ptrdiff_t aId);
protected: protected:
explicit CommandBuffer(size_t aSize = 256) explicit CommandBuffer(size_t aSize = 256)