diff --git a/gfx/2d/DrawCommand.h b/gfx/2d/DrawCommand.h index 7f8d8cc52593..9333a152e779 100644 --- a/gfx/2d/DrawCommand.h +++ b/gfx/2d/DrawCommand.h @@ -29,6 +29,7 @@ enum class CommandType : int8_t { COPYSURFACE, COPYRECT, FILLRECT, + FILLROUNDEDRECT, STROKERECT, STROKELINE, STROKE, diff --git a/gfx/2d/DrawCommands.h b/gfx/2d/DrawCommands.h index 216b2455e588..89318d1a9b82 100644 --- a/gfx/2d/DrawCommands.h +++ b/gfx/2d/DrawCommands.h @@ -369,6 +369,38 @@ class FillRectCommand : public DrawingCommand { DrawOptions mOptions; }; +class FillRoundedRectCommand : public DrawingCommand { + public: + FillRoundedRectCommand(const RoundedRect& aRect, const Pattern& aPattern, + const DrawOptions& aOptions) + : mRect(aRect), mPattern(aPattern), mOptions(aOptions) {} + + CommandType GetType() const override { return FillRoundedRectCommand::Type; } + + void CloneInto(CaptureCommandList* aList) override { + CLONE_INTO(FillRoundedRectCommand)(mRect, mPattern, mOptions); + } + + void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const override { + aDT->FillRoundedRect(mRect, mPattern, mOptions); + } + + void Log(TreeLog& aStream) const override { + aStream << "[FillRoundedRect rect=" << mRect.rect; + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + + static const bool AffectsSnapshot = true; + static const CommandType Type = CommandType::FILLROUNDEDRECT; + + private: + RoundedRect mRect; + StoredPattern mPattern; + DrawOptions mOptions; +}; + class StrokeRectCommand : public StrokeOptionsCommand { public: StrokeRectCommand(const Rect& aRect, const Pattern& aPattern, diff --git a/gfx/2d/DrawTargetCapture.cpp b/gfx/2d/DrawTargetCapture.cpp index 7ee399293cb1..c89147acd739 100644 --- a/gfx/2d/DrawTargetCapture.cpp +++ b/gfx/2d/DrawTargetCapture.cpp @@ -189,6 +189,12 @@ void DrawTargetCaptureImpl::FillRect(const Rect& aRect, const Pattern& aPattern, AppendCommand(FillRectCommand)(aRect, aPattern, aOptions); } +void DrawTargetCaptureImpl::FillRoundedRect(const RoundedRect& aRect, + const Pattern& aPattern, + const DrawOptions& aOptions) { + AppendCommand(FillRoundedRectCommand)(aRect, aPattern, aOptions); +} + void DrawTargetCaptureImpl::StrokeRect(const Rect& aRect, const Pattern& aPattern, const StrokeOptions& aStrokeOptions, diff --git a/gfx/2d/DrawTargetCapture.h b/gfx/2d/DrawTargetCapture.h index f1f05f1efa82..c5467df794c0 100644 --- a/gfx/2d/DrawTargetCapture.h +++ b/gfx/2d/DrawTargetCapture.h @@ -65,6 +65,9 @@ class DrawTargetCaptureImpl : public DrawTargetCapture { virtual void FillRect(const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions = DrawOptions()) override; + virtual void FillRoundedRect( + const RoundedRect &aRect, const Pattern &aPattern, + const DrawOptions &aOptions = DrawOptions()) override; virtual void StrokeRect(const Rect &aRect, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), const DrawOptions &aOptions = DrawOptions()) override;