1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_GFX_DRAWCOMMANDS_H_
8 #define MOZILLA_GFX_DRAWCOMMANDS_H_
16 #include "CaptureCommandList.h"
17 #include "DrawCommand.h"
18 #include "FilterNodeCapture.h"
25 #define CLONE_INTO(Type) new (aList->Append<Type>()) Type
27 class StrokeOptionsCommand
: public DrawingCommand
{
29 StrokeOptionsCommand(const StrokeOptions
& aStrokeOptions
)
30 : mStrokeOptions(aStrokeOptions
) {
31 // Stroke Options dashes are owned by the caller.
32 // Have to copy them here so they don't get freed
33 // between now and replay.
34 if (aStrokeOptions
.mDashLength
) {
35 mDashes
.resize(aStrokeOptions
.mDashLength
);
36 mStrokeOptions
.mDashPattern
= &mDashes
.front();
37 PodCopy(&mDashes
.front(), aStrokeOptions
.mDashPattern
,
38 mStrokeOptions
.mDashLength
);
42 virtual ~StrokeOptionsCommand() = default;
45 StrokeOptions mStrokeOptions
;
46 std::vector
<Float
> mDashes
;
51 explicit StoredPattern(const Pattern
& aPattern
) { Assign(aPattern
); }
53 void Assign(const Pattern
& aPattern
) {
54 switch (aPattern
.GetType()) {
55 case PatternType::COLOR
:
56 new (mColor
) ColorPattern(*static_cast<const ColorPattern
*>(&aPattern
));
58 case PatternType::SURFACE
: {
59 SurfacePattern
* surfPat
= new (mSurface
)
60 SurfacePattern(*static_cast<const SurfacePattern
*>(&aPattern
));
61 surfPat
->mSurface
->GuaranteePersistance();
64 case PatternType::LINEAR_GRADIENT
:
65 new (mLinear
) LinearGradientPattern(
66 *static_cast<const LinearGradientPattern
*>(&aPattern
));
68 case PatternType::RADIAL_GRADIENT
:
69 new (mRadial
) RadialGradientPattern(
70 *static_cast<const RadialGradientPattern
*>(&aPattern
));
72 case PatternType::CONIC_GRADIENT
:
73 new (mConic
) ConicGradientPattern(
74 *static_cast<const ConicGradientPattern
*>(&aPattern
));
79 ~StoredPattern() { reinterpret_cast<Pattern
*>(mPattern
)->~Pattern(); }
81 Pattern
* Get() { return reinterpret_cast<Pattern
*>(mPattern
); }
83 const Pattern
* Get() const {
84 return reinterpret_cast<const Pattern
*>(mPattern
);
87 operator Pattern
&() { return *reinterpret_cast<Pattern
*>(mPattern
); }
89 operator const Pattern
&() const {
90 return *reinterpret_cast<const Pattern
*>(mPattern
);
93 StoredPattern(const StoredPattern
& aPattern
) { Assign(aPattern
); }
96 StoredPattern
operator=(const StoredPattern
& aOther
) {
97 // Block this so that we notice if someone's doing excessive assigning.
102 char mPattern
[sizeof(Pattern
)];
103 char mColor
[sizeof(ColorPattern
)];
104 char mLinear
[sizeof(LinearGradientPattern
)];
105 char mRadial
[sizeof(RadialGradientPattern
)];
106 char mConic
[sizeof(ConicGradientPattern
)];
107 char mSurface
[sizeof(SurfacePattern
)];
111 class DrawSurfaceCommand
: public DrawingCommand
{
113 DrawSurfaceCommand(SourceSurface
* aSurface
, const Rect
& aDest
,
115 const DrawSurfaceOptions
& aSurfOptions
,
116 const DrawOptions
& aOptions
)
117 : mSurface(aSurface
),
120 mSurfOptions(aSurfOptions
),
121 mOptions(aOptions
) {}
123 CommandType
GetType() const override
{ return DrawSurfaceCommand::Type
; }
125 void CloneInto(CaptureCommandList
* aList
) override
{
126 CLONE_INTO(DrawSurfaceCommand
)
127 (mSurface
, mDest
, mSource
, mSurfOptions
, mOptions
);
130 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
131 aDT
->DrawSurface(mSurface
, mDest
, mSource
, mSurfOptions
, mOptions
);
134 void Log(TreeLog
<>& aStream
) const override
{
135 aStream
<< "[DrawSurface surf=" << mSurface
;
136 aStream
<< " dest=" << mDest
;
137 aStream
<< " src=" << mSource
;
138 aStream
<< " surfOpt=" << mSurfOptions
;
139 aStream
<< " opt=" << mOptions
;
143 static const bool AffectsSnapshot
= true;
144 static const CommandType Type
= CommandType::DRAWSURFACE
;
147 RefPtr
<SourceSurface
> mSurface
;
150 DrawSurfaceOptions mSurfOptions
;
151 DrawOptions mOptions
;
154 class DrawSurfaceWithShadowCommand
: public DrawingCommand
{
156 DrawSurfaceWithShadowCommand(SourceSurface
* aSurface
, const Point
& aDest
,
157 const DeviceColor
& aColor
, const Point
& aOffset
,
158 Float aSigma
, CompositionOp aOperator
)
159 : mSurface(aSurface
),
164 mOperator(aOperator
) {}
166 CommandType
GetType() const override
{
167 return DrawSurfaceWithShadowCommand::Type
;
170 void CloneInto(CaptureCommandList
* aList
) override
{
171 CLONE_INTO(DrawSurfaceWithShadowCommand
)
172 (mSurface
, mDest
, mColor
, mOffset
, mSigma
, mOperator
);
175 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
176 aDT
->DrawSurfaceWithShadow(mSurface
, mDest
, mColor
, mOffset
, mSigma
,
180 void Log(TreeLog
<>& aStream
) const override
{
181 aStream
<< "[DrawSurfaceWithShadow surf=" << mSurface
;
182 aStream
<< " dest=" << mDest
;
183 aStream
<< " color=" << mColor
;
184 aStream
<< " offset=" << mOffset
;
185 aStream
<< " sigma=" << mSigma
;
186 aStream
<< " op=" << mOperator
;
190 static const bool AffectsSnapshot
= true;
191 static const CommandType Type
= CommandType::DRAWSURFACEWITHSHADOW
;
194 RefPtr
<SourceSurface
> mSurface
;
199 CompositionOp mOperator
;
202 class DrawFilterCommand
: public DrawingCommand
{
204 DrawFilterCommand(FilterNode
* aFilter
, const Rect
& aSourceRect
,
205 const Point
& aDestPoint
, const DrawOptions
& aOptions
)
207 mSourceRect(aSourceRect
),
208 mDestPoint(aDestPoint
),
209 mOptions(aOptions
) {}
211 CommandType
GetType() const override
{ return DrawFilterCommand::Type
; }
213 void CloneInto(CaptureCommandList
* aList
) override
{
214 CLONE_INTO(DrawFilterCommand
)(mFilter
, mSourceRect
, mDestPoint
, mOptions
);
217 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
218 RefPtr
<FilterNode
> filter
= mFilter
;
219 if (mFilter
->GetBackendType() == FilterBackend::FILTER_BACKEND_CAPTURE
) {
220 filter
= static_cast<FilterNodeCapture
*>(filter
.get())->Validate(aDT
);
222 // This can happen if the FilterNodeCapture is unable to create a
223 // backing FilterNode on the target backend. Normally this would be
224 // handled by the painting code, but here there's not much we can do.
229 aDT
->DrawFilter(filter
, mSourceRect
, mDestPoint
, mOptions
);
232 void Log(TreeLog
<>& aStream
) const override
{
233 aStream
<< "[DrawFilter surf=" << mFilter
;
234 aStream
<< " src=" << mSourceRect
;
235 aStream
<< " dest=" << mDestPoint
;
236 aStream
<< " opt=" << mOptions
;
240 static const bool AffectsSnapshot
= true;
241 static const CommandType Type
= CommandType::DRAWFILTER
;
244 RefPtr
<FilterNode
> mFilter
;
247 DrawOptions mOptions
;
250 class ClearRectCommand
: public DrawingCommand
{
252 explicit ClearRectCommand(const Rect
& aRect
) : mRect(aRect
) {}
254 CommandType
GetType() const override
{ return ClearRectCommand::Type
; }
256 void CloneInto(CaptureCommandList
* aList
) override
{
257 CLONE_INTO(ClearRectCommand
)(mRect
);
260 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
261 aDT
->ClearRect(mRect
);
264 void Log(TreeLog
<>& aStream
) const override
{
265 aStream
<< "[ClearRect rect=" << mRect
<< "]";
268 static const bool AffectsSnapshot
= true;
269 static const CommandType Type
= CommandType::CLEARRECT
;
275 class CopySurfaceCommand
: public DrawingCommand
{
277 CopySurfaceCommand(SourceSurface
* aSurface
, const IntRect
& aSourceRect
,
278 const IntPoint
& aDestination
)
279 : mSurface(aSurface
),
280 mSourceRect(aSourceRect
),
281 mDestination(aDestination
) {}
283 CommandType
GetType() const override
{ return CopySurfaceCommand::Type
; }
285 void CloneInto(CaptureCommandList
* aList
) override
{
286 CLONE_INTO(CopySurfaceCommand
)(mSurface
, mSourceRect
, mDestination
);
289 virtual void ExecuteOnDT(DrawTarget
* aDT
,
290 const Matrix
* aTransform
) const override
{
291 MOZ_ASSERT(!aTransform
|| !aTransform
->HasNonIntegerTranslation());
292 Point
dest(Float(mDestination
.x
), Float(mDestination
.y
));
294 dest
= aTransform
->TransformPoint(dest
);
296 aDT
->CopySurface(mSurface
, mSourceRect
,
297 IntPoint(uint32_t(dest
.x
), uint32_t(dest
.y
)));
300 void Log(TreeLog
<>& aStream
) const override
{
301 aStream
<< "[CopySurface surf=" << mSurface
;
302 aStream
<< " src=" << mSourceRect
;
303 aStream
<< " dest=" << mDestination
;
307 static const bool AffectsSnapshot
= true;
308 static const CommandType Type
= CommandType::COPYSURFACE
;
311 RefPtr
<SourceSurface
> mSurface
;
313 IntPoint mDestination
;
316 class CopyRectCommand
: public DrawingCommand
{
318 CopyRectCommand(const IntRect
& aSourceRect
, const IntPoint
& aDestination
)
319 : mSourceRect(aSourceRect
), mDestination(aDestination
) {}
321 CommandType
GetType() const override
{ return CopyRectCommand::Type
; }
323 void CloneInto(CaptureCommandList
* aList
) override
{
324 CLONE_INTO(CopyRectCommand
)(mSourceRect
, mDestination
);
327 virtual void ExecuteOnDT(DrawTarget
* aDT
,
328 const Matrix
* aTransform
) const override
{
329 aDT
->CopyRect(mSourceRect
, mDestination
);
332 void Log(TreeLog
<>& aStream
) const override
{
333 aStream
<< "[CopyRect src=" << mSourceRect
;
334 aStream
<< " dest=" << mDestination
;
338 static const bool AffectsSnapshot
= true;
339 static const CommandType Type
= CommandType::COPYRECT
;
343 IntPoint mDestination
;
346 class FillRectCommand
: public DrawingCommand
{
348 FillRectCommand(const Rect
& aRect
, const Pattern
& aPattern
,
349 const DrawOptions
& aOptions
)
350 : mRect(aRect
), mPattern(aPattern
), mOptions(aOptions
) {}
352 CommandType
GetType() const override
{ return FillRectCommand::Type
; }
354 void CloneInto(CaptureCommandList
* aList
) override
{
355 CLONE_INTO(FillRectCommand
)(mRect
, mPattern
, mOptions
);
358 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
359 aDT
->FillRect(mRect
, mPattern
, mOptions
);
362 void Log(TreeLog
<>& aStream
) const override
{
363 aStream
<< "[FillRect rect=" << mRect
;
364 aStream
<< " pattern=" << mPattern
.Get();
365 aStream
<< " opt=" << mOptions
;
369 static const bool AffectsSnapshot
= true;
370 static const CommandType Type
= CommandType::FILLRECT
;
374 StoredPattern mPattern
;
375 DrawOptions mOptions
;
378 class FillRoundedRectCommand
: public DrawingCommand
{
380 FillRoundedRectCommand(const RoundedRect
& aRect
, const Pattern
& aPattern
,
381 const DrawOptions
& aOptions
)
382 : mRect(aRect
), mPattern(aPattern
), mOptions(aOptions
) {}
384 CommandType
GetType() const override
{ return FillRoundedRectCommand::Type
; }
386 void CloneInto(CaptureCommandList
* aList
) override
{
387 CLONE_INTO(FillRoundedRectCommand
)(mRect
, mPattern
, mOptions
);
390 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
391 aDT
->FillRoundedRect(mRect
, mPattern
, mOptions
);
394 void Log(TreeLog
<>& aStream
) const override
{
395 aStream
<< "[FillRoundedRect rect=" << mRect
.rect
;
396 aStream
<< " pattern=" << mPattern
.Get();
397 aStream
<< " opt=" << mOptions
;
401 static const bool AffectsSnapshot
= true;
402 static const CommandType Type
= CommandType::FILLROUNDEDRECT
;
406 StoredPattern mPattern
;
407 DrawOptions mOptions
;
410 class StrokeRectCommand
: public StrokeOptionsCommand
{
412 StrokeRectCommand(const Rect
& aRect
, const Pattern
& aPattern
,
413 const StrokeOptions
& aStrokeOptions
,
414 const DrawOptions
& aOptions
)
415 : StrokeOptionsCommand(aStrokeOptions
),
418 mOptions(aOptions
) {}
420 CommandType
GetType() const override
{ return StrokeRectCommand::Type
; }
422 void CloneInto(CaptureCommandList
* aList
) override
{
423 CLONE_INTO(StrokeRectCommand
)(mRect
, mPattern
, mStrokeOptions
, mOptions
);
426 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
427 aDT
->StrokeRect(mRect
, mPattern
, mStrokeOptions
, mOptions
);
430 void Log(TreeLog
<>& aStream
) const override
{
431 aStream
<< "[StrokeRect rect=" << mRect
;
432 aStream
<< " pattern=" << mPattern
.Get();
433 aStream
<< " opt=" << mOptions
;
437 static const bool AffectsSnapshot
= true;
438 static const CommandType Type
= CommandType::STROKERECT
;
442 StoredPattern mPattern
;
443 DrawOptions mOptions
;
446 class StrokeLineCommand
: public StrokeOptionsCommand
{
448 StrokeLineCommand(const Point
& aStart
, const Point
& aEnd
,
449 const Pattern
& aPattern
,
450 const StrokeOptions
& aStrokeOptions
,
451 const DrawOptions
& aOptions
)
452 : StrokeOptionsCommand(aStrokeOptions
),
456 mOptions(aOptions
) {}
458 CommandType
GetType() const override
{ return StrokeLineCommand::Type
; }
460 void CloneInto(CaptureCommandList
* aList
) override
{
461 CLONE_INTO(StrokeLineCommand
)
462 (mStart
, mEnd
, mPattern
, mStrokeOptions
, mOptions
);
465 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
466 aDT
->StrokeLine(mStart
, mEnd
, mPattern
, mStrokeOptions
, mOptions
);
469 void Log(TreeLog
<>& aStream
) const override
{
470 aStream
<< "[StrokeLine start=" << mStart
;
471 aStream
<< " end=" << mEnd
;
472 aStream
<< " pattern=" << mPattern
.Get();
473 aStream
<< " opt=" << mOptions
;
477 static const bool AffectsSnapshot
= true;
478 static const CommandType Type
= CommandType::STROKELINE
;
483 StoredPattern mPattern
;
484 DrawOptions mOptions
;
487 class FillCommand
: public DrawingCommand
{
489 FillCommand(const Path
* aPath
, const Pattern
& aPattern
,
490 const DrawOptions
& aOptions
)
491 : mPath(const_cast<Path
*>(aPath
)),
493 mOptions(aOptions
) {}
495 CommandType
GetType() const override
{ return FillCommand::Type
; }
497 void CloneInto(CaptureCommandList
* aList
) override
{
498 CLONE_INTO(FillCommand
)(mPath
, mPattern
, mOptions
);
501 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
502 aDT
->Fill(mPath
, mPattern
, mOptions
);
505 void Log(TreeLog
<>& aStream
) const override
{
506 aStream
<< "[FillCommand path=" << mPath
;
507 aStream
<< " pattern=" << mPattern
.Get();
508 aStream
<< " opt=" << mOptions
;
512 static const bool AffectsSnapshot
= true;
513 static const CommandType Type
= CommandType::FILL
;
517 StoredPattern mPattern
;
518 DrawOptions mOptions
;
521 class StrokeCommand
: public StrokeOptionsCommand
{
523 StrokeCommand(const Path
* aPath
, const Pattern
& aPattern
,
524 const StrokeOptions
& aStrokeOptions
,
525 const DrawOptions
& aOptions
)
526 : StrokeOptionsCommand(aStrokeOptions
),
527 mPath(const_cast<Path
*>(aPath
)),
529 mOptions(aOptions
) {}
531 CommandType
GetType() const override
{ return StrokeCommand::Type
; }
533 void CloneInto(CaptureCommandList
* aList
) override
{
534 CLONE_INTO(StrokeCommand
)(mPath
, mPattern
, mStrokeOptions
, mOptions
);
537 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
538 aDT
->Stroke(mPath
, mPattern
, mStrokeOptions
, mOptions
);
541 void Log(TreeLog
<>& aStream
) const override
{
542 aStream
<< "[Stroke path=" << mPath
;
543 aStream
<< " pattern=" << mPattern
.Get();
544 aStream
<< " opt=" << mOptions
;
548 static const bool AffectsSnapshot
= true;
549 static const CommandType Type
= CommandType::STROKE
;
553 StoredPattern mPattern
;
554 DrawOptions mOptions
;
557 class FillGlyphsCommand
: public DrawingCommand
{
558 friend class DrawTargetCaptureImpl
;
561 FillGlyphsCommand(ScaledFont
* aFont
, const GlyphBuffer
& aBuffer
,
562 const Pattern
& aPattern
, const DrawOptions
& aOptions
)
563 : mFont(aFont
), mPattern(aPattern
), mOptions(aOptions
) {
564 mGlyphs
.resize(aBuffer
.mNumGlyphs
);
565 memcpy(&mGlyphs
.front(), aBuffer
.mGlyphs
,
566 sizeof(Glyph
) * aBuffer
.mNumGlyphs
);
569 CommandType
GetType() const override
{ return FillGlyphsCommand::Type
; }
571 void CloneInto(CaptureCommandList
* aList
) override
{
572 GlyphBuffer glyphs
= {
574 (uint32_t)mGlyphs
.size(),
576 CLONE_INTO(FillGlyphsCommand
)(mFont
, glyphs
, mPattern
, mOptions
);
579 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
581 buf
.mNumGlyphs
= mGlyphs
.size();
582 buf
.mGlyphs
= &mGlyphs
.front();
583 aDT
->FillGlyphs(mFont
, buf
, mPattern
, mOptions
);
586 void Log(TreeLog
<>& aStream
) const override
{
587 aStream
<< "[FillGlyphs font=" << mFont
;
588 aStream
<< " glyphCount=" << mGlyphs
.size();
589 aStream
<< " pattern=" << mPattern
.Get();
590 aStream
<< " opt=" << mOptions
;
594 static const bool AffectsSnapshot
= true;
595 static const CommandType Type
= CommandType::FILLGLYPHS
;
598 RefPtr
<ScaledFont
> mFont
;
599 std::vector
<Glyph
> mGlyphs
;
600 StoredPattern mPattern
;
601 DrawOptions mOptions
;
604 class StrokeGlyphsCommand
: public StrokeOptionsCommand
{
605 friend class DrawTargetCaptureImpl
;
608 StrokeGlyphsCommand(ScaledFont
* aFont
, const GlyphBuffer
& aBuffer
,
609 const Pattern
& aPattern
,
610 const StrokeOptions
& aStrokeOptions
,
611 const DrawOptions
& aOptions
)
612 : StrokeOptionsCommand(aStrokeOptions
),
616 mGlyphs
.resize(aBuffer
.mNumGlyphs
);
617 memcpy(&mGlyphs
.front(), aBuffer
.mGlyphs
,
618 sizeof(Glyph
) * aBuffer
.mNumGlyphs
);
621 CommandType
GetType() const override
{ return StrokeGlyphsCommand::Type
; }
623 void CloneInto(CaptureCommandList
* aList
) override
{
624 GlyphBuffer glyphs
= {
626 (uint32_t)mGlyphs
.size(),
628 CLONE_INTO(StrokeGlyphsCommand
)
629 (mFont
, glyphs
, mPattern
, mStrokeOptions
, mOptions
);
632 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
634 buf
.mNumGlyphs
= mGlyphs
.size();
635 buf
.mGlyphs
= &mGlyphs
.front();
636 aDT
->StrokeGlyphs(mFont
, buf
, mPattern
, mStrokeOptions
, mOptions
);
639 void Log(TreeLog
<>& aStream
) const override
{
640 aStream
<< "[StrokeGlyphs font=" << mFont
;
641 aStream
<< " glyphCount=" << mGlyphs
.size();
642 aStream
<< " pattern=" << mPattern
.Get();
643 aStream
<< " opt=" << mOptions
;
647 static const bool AffectsSnapshot
= true;
648 static const CommandType Type
= CommandType::STROKEGLYPHS
;
651 RefPtr
<ScaledFont
> mFont
;
652 std::vector
<Glyph
> mGlyphs
;
653 StoredPattern mPattern
;
654 DrawOptions mOptions
;
657 class MaskCommand
: public DrawingCommand
{
659 MaskCommand(const Pattern
& aSource
, const Pattern
& aMask
,
660 const DrawOptions
& aOptions
)
661 : mSource(aSource
), mMask(aMask
), mOptions(aOptions
) {}
663 CommandType
GetType() const override
{ return MaskCommand::Type
; }
665 void CloneInto(CaptureCommandList
* aList
) override
{
666 CLONE_INTO(MaskCommand
)(mSource
, mMask
, mOptions
);
669 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
670 aDT
->Mask(mSource
, mMask
, mOptions
);
673 void Log(TreeLog
<>& aStream
) const override
{
674 aStream
<< "[Mask source=" << mSource
.Get();
675 aStream
<< " mask=" << mMask
.Get();
676 aStream
<< " opt=" << mOptions
;
680 static const bool AffectsSnapshot
= true;
681 static const CommandType Type
= CommandType::MASK
;
684 StoredPattern mSource
;
686 DrawOptions mOptions
;
689 class MaskSurfaceCommand
: public DrawingCommand
{
691 MaskSurfaceCommand(const Pattern
& aSource
, const SourceSurface
* aMask
,
692 const Point
& aOffset
, const DrawOptions
& aOptions
)
694 mMask(const_cast<SourceSurface
*>(aMask
)),
696 mOptions(aOptions
) {}
698 CommandType
GetType() const override
{ return MaskSurfaceCommand::Type
; }
700 void CloneInto(CaptureCommandList
* aList
) override
{
701 CLONE_INTO(MaskSurfaceCommand
)(mSource
, mMask
, mOffset
, mOptions
);
704 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
705 aDT
->MaskSurface(mSource
, mMask
, mOffset
, mOptions
);
708 void Log(TreeLog
<>& aStream
) const override
{
709 aStream
<< "[Mask source=" << mSource
.Get();
710 aStream
<< " mask=" << mMask
;
711 aStream
<< " offset=" << &mOffset
;
712 aStream
<< " opt=" << mOptions
;
716 static const bool AffectsSnapshot
= true;
717 static const CommandType Type
= CommandType::MASKSURFACE
;
720 StoredPattern mSource
;
721 RefPtr
<SourceSurface
> mMask
;
723 DrawOptions mOptions
;
726 class PushClipCommand
: public DrawingCommand
{
728 explicit PushClipCommand(const Path
* aPath
)
729 : mPath(const_cast<Path
*>(aPath
)) {}
731 CommandType
GetType() const override
{ return PushClipCommand::Type
; }
733 void CloneInto(CaptureCommandList
* aList
) override
{
734 CLONE_INTO(PushClipCommand
)(mPath
);
737 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
738 aDT
->PushClip(mPath
);
741 void Log(TreeLog
<>& aStream
) const override
{
742 aStream
<< "[PushClip path=" << mPath
<< "]";
745 static const bool AffectsSnapshot
= false;
746 static const CommandType Type
= CommandType::PUSHCLIP
;
752 class PushClipRectCommand
: public DrawingCommand
{
754 explicit PushClipRectCommand(const Rect
& aRect
) : mRect(aRect
) {}
756 CommandType
GetType() const override
{ return PushClipRectCommand::Type
; }
758 void CloneInto(CaptureCommandList
* aList
) override
{
759 CLONE_INTO(PushClipRectCommand
)(mRect
);
762 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
763 aDT
->PushClipRect(mRect
);
766 void Log(TreeLog
<>& aStream
) const override
{
767 aStream
<< "[PushClipRect rect=" << mRect
<< "]";
770 static const bool AffectsSnapshot
= false;
771 static const CommandType Type
= CommandType::PUSHCLIPRECT
;
777 class PushLayerCommand
: public DrawingCommand
{
779 PushLayerCommand(const bool aOpaque
, const Float aOpacity
,
780 SourceSurface
* aMask
, const Matrix
& aMaskTransform
,
781 const IntRect
& aBounds
, bool aCopyBackground
)
785 mMaskTransform(aMaskTransform
),
787 mCopyBackground(aCopyBackground
) {}
789 CommandType
GetType() const override
{ return PushLayerCommand::Type
; }
791 void CloneInto(CaptureCommandList
* aList
) override
{
792 CLONE_INTO(PushLayerCommand
)
793 (mOpaque
, mOpacity
, mMask
, mMaskTransform
, mBounds
, mCopyBackground
);
796 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
797 aDT
->PushLayer(mOpaque
, mOpacity
, mMask
, mMaskTransform
, mBounds
,
801 void Log(TreeLog
<>& aStream
) const override
{
802 aStream
<< "[PushLayer opaque=" << mOpaque
;
803 aStream
<< " opacity=" << mOpacity
;
804 aStream
<< " mask=" << mMask
;
805 aStream
<< " maskTransform=" << mMaskTransform
;
806 aStream
<< " bounds=" << mBounds
;
807 aStream
<< " copyBackground=" << mCopyBackground
;
811 static const bool AffectsSnapshot
= false;
812 static const CommandType Type
= CommandType::PUSHLAYER
;
817 RefPtr
<SourceSurface
> mMask
;
818 Matrix mMaskTransform
;
820 bool mCopyBackground
;
823 class PopClipCommand
: public DrawingCommand
{
825 PopClipCommand() = default;
827 CommandType
GetType() const override
{ return PopClipCommand::Type
; }
829 void CloneInto(CaptureCommandList
* aList
) override
{
830 CLONE_INTO(PopClipCommand
)();
833 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
837 void Log(TreeLog
<>& aStream
) const override
{ aStream
<< "[PopClip]"; }
839 static const bool AffectsSnapshot
= false;
840 static const CommandType Type
= CommandType::POPCLIP
;
843 class PopLayerCommand
: public DrawingCommand
{
845 PopLayerCommand() = default;
847 CommandType
GetType() const override
{ return PopLayerCommand::Type
; }
849 void CloneInto(CaptureCommandList
* aList
) override
{
850 CLONE_INTO(PopLayerCommand
)();
853 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
857 void Log(TreeLog
<>& aStream
) const override
{ aStream
<< "[PopLayer]"; }
859 static const bool AffectsSnapshot
= true;
860 static const CommandType Type
= CommandType::POPLAYER
;
863 class SetTransformCommand
: public DrawingCommand
{
864 friend class DrawTargetCaptureImpl
;
867 explicit SetTransformCommand(const Matrix
& aTransform
)
868 : mTransform(aTransform
) {}
870 CommandType
GetType() const override
{ return SetTransformCommand::Type
; }
872 void CloneInto(CaptureCommandList
* aList
) override
{
873 CLONE_INTO(SetTransformCommand
)(mTransform
);
876 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
* aMatrix
) const override
{
878 aDT
->SetTransform(mTransform
* (*aMatrix
));
880 aDT
->SetTransform(mTransform
);
884 void Log(TreeLog
<>& aStream
) const override
{
885 aStream
<< "[SetTransform transform=" << mTransform
<< "]";
888 static const bool AffectsSnapshot
= false;
889 static const CommandType Type
= CommandType::SETTRANSFORM
;
895 class SetPermitSubpixelAACommand
: public DrawingCommand
{
896 friend class DrawTargetCaptureImpl
;
899 explicit SetPermitSubpixelAACommand(bool aPermitSubpixelAA
)
900 : mPermitSubpixelAA(aPermitSubpixelAA
) {}
902 CommandType
GetType() const override
{
903 return SetPermitSubpixelAACommand::Type
;
906 void CloneInto(CaptureCommandList
* aList
) override
{
907 CLONE_INTO(SetPermitSubpixelAACommand
)(mPermitSubpixelAA
);
910 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
* aMatrix
) const override
{
911 aDT
->SetPermitSubpixelAA(mPermitSubpixelAA
);
914 void Log(TreeLog
<>& aStream
) const override
{
915 aStream
<< "[SetPermitSubpixelAA permitSubpixelAA=" << mPermitSubpixelAA
919 static const bool AffectsSnapshot
= false;
920 static const CommandType Type
= CommandType::SETPERMITSUBPIXELAA
;
923 bool mPermitSubpixelAA
;
926 class FlushCommand
: public DrawingCommand
{
928 FlushCommand() = default;
930 CommandType
GetType() const override
{ return FlushCommand::Type
; }
932 void CloneInto(CaptureCommandList
* aList
) override
{
933 CLONE_INTO(FlushCommand
)();
936 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
940 void Log(TreeLog
<>& aStream
) const override
{ aStream
<< "[Flush]"; }
942 static const bool AffectsSnapshot
= false;
943 static const CommandType Type
= CommandType::FLUSH
;
946 class BlurCommand
: public DrawingCommand
{
948 explicit BlurCommand(const AlphaBoxBlur
& aBlur
) : mBlur(aBlur
) {}
950 CommandType
GetType() const override
{ return BlurCommand::Type
; }
952 void CloneInto(CaptureCommandList
* aList
) override
{
953 CLONE_INTO(BlurCommand
)(mBlur
);
956 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
960 void Log(TreeLog
<>& aStream
) const override
{ aStream
<< "[Blur]"; }
962 static const bool AffectsSnapshot
= true;
963 static const CommandType Type
= CommandType::BLUR
;
969 class PadEdgesCommand
: public DrawingCommand
{
971 explicit PadEdgesCommand(const IntRegion
& aRegion
) : mRegion(aRegion
) {}
973 CommandType
GetType() const override
{ return PadEdgesCommand::Type
; }
975 void CloneInto(CaptureCommandList
* aList
) override
{
976 CLONE_INTO(PadEdgesCommand
)(IntRegion(mRegion
));
979 void ExecuteOnDT(DrawTarget
* aDT
, const Matrix
*) const override
{
980 aDT
->PadEdges(mRegion
);
983 void Log(TreeLog
<>& aStream
) const override
{ aStream
<< "[PADEDGES]"; }
985 static const bool AffectsSnapshot
= true;
986 static const CommandType Type
= CommandType::PADEDGES
;
995 } // namespace mozilla
997 #endif /* MOZILLA_GFX_DRAWCOMMANDS_H_ */