2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2014-08-01 20:01:47 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_DRAWCOMMAND_H_
|
|
|
|
#define MOZILLA_GFX_DRAWCOMMAND_H_
|
|
|
|
|
2015-06-10 20:57:08 +03:00
|
|
|
#include <math.h>
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
#include "2D.h"
|
2017-10-31 22:02:30 +03:00
|
|
|
#include "Blur.h"
|
2014-08-01 20:01:47 +04:00
|
|
|
#include "Filters.h"
|
|
|
|
#include <vector>
|
2017-10-31 22:02:31 +03:00
|
|
|
#include "CaptureCommandList.h"
|
2014-08-01 20:01:47 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
2015-01-26 01:22:07 +03:00
|
|
|
enum class CommandType : int8_t {
|
2014-08-01 20:01:47 +04:00
|
|
|
DRAWSURFACE = 0,
|
|
|
|
DRAWFILTER,
|
|
|
|
DRAWSURFACEWITHSHADOW,
|
|
|
|
CLEARRECT,
|
|
|
|
COPYSURFACE,
|
|
|
|
COPYRECT,
|
|
|
|
FILLRECT,
|
|
|
|
STROKERECT,
|
|
|
|
STROKELINE,
|
|
|
|
STROKE,
|
|
|
|
FILL,
|
|
|
|
FILLGLYPHS,
|
2017-07-15 03:48:00 +03:00
|
|
|
STROKEGLYPHS,
|
2014-08-01 20:01:47 +04:00
|
|
|
MASK,
|
|
|
|
MASKSURFACE,
|
|
|
|
PUSHCLIP,
|
|
|
|
PUSHCLIPRECT,
|
2017-06-22 00:19:42 +03:00
|
|
|
PUSHLAYER,
|
2014-08-01 20:01:47 +04:00
|
|
|
POPCLIP,
|
2017-06-22 00:19:42 +03:00
|
|
|
POPLAYER,
|
2015-06-10 20:57:08 +03:00
|
|
|
SETTRANSFORM,
|
2017-09-13 22:15:16 +03:00
|
|
|
SETPERMITSUBPIXELAA,
|
2017-10-31 22:02:30 +03:00
|
|
|
FLUSH,
|
|
|
|
BLUR
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
2014-08-01 20:01:47 +04:00
|
|
|
|
|
|
|
class DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~DrawingCommand() {}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform = nullptr) const = 0;
|
|
|
|
virtual bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const { return false; }
|
2017-10-31 22:02:31 +03:00
|
|
|
virtual void CloneInto(CaptureCommandList* aList) = 0;
|
2015-06-10 20:57:08 +03:00
|
|
|
|
2016-11-24 08:11:29 +03:00
|
|
|
CommandType GetType() { return mType; }
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
protected:
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit DrawingCommand(CommandType aType)
|
2014-08-01 20:01:47 +04:00
|
|
|
: mType(aType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CommandType mType;
|
|
|
|
};
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
#define CLONE_INTO(Type) new (aList->Append<Type>()) Type
|
|
|
|
|
2017-07-20 23:14:51 +03:00
|
|
|
class StrokeOptionsCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StrokeOptionsCommand(CommandType aType,
|
|
|
|
const StrokeOptions& aStrokeOptions)
|
|
|
|
: DrawingCommand(aType)
|
|
|
|
, mStrokeOptions(aStrokeOptions)
|
|
|
|
{
|
|
|
|
// Stroke Options dashes are owned by the caller.
|
|
|
|
// Have to copy them here so they don't get freed
|
|
|
|
// between now and replay.
|
|
|
|
if (aStrokeOptions.mDashLength) {
|
|
|
|
mDashes.resize(aStrokeOptions.mDashLength);
|
|
|
|
mStrokeOptions.mDashPattern = &mDashes.front();
|
|
|
|
PodCopy(&mDashes.front(), aStrokeOptions.mDashPattern, mStrokeOptions.mDashLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~StrokeOptionsCommand() {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
StrokeOptions mStrokeOptions;
|
|
|
|
std::vector<Float> mDashes;
|
|
|
|
};
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
class StoredPattern
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit StoredPattern(const Pattern& aPattern)
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
Assign(aPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Assign(const Pattern& aPattern)
|
|
|
|
{
|
|
|
|
switch (aPattern.GetType()) {
|
|
|
|
case PatternType::COLOR:
|
|
|
|
new (mColor)ColorPattern(*static_cast<const ColorPattern*>(&aPattern));
|
|
|
|
return;
|
|
|
|
case PatternType::SURFACE:
|
|
|
|
{
|
2016-08-24 12:06:41 +03:00
|
|
|
SurfacePattern* surfPat = new (mSurface)SurfacePattern(*static_cast<const SurfacePattern*>(&aPattern));
|
2014-08-01 20:01:47 +04:00
|
|
|
surfPat->mSurface->GuaranteePersistance();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case PatternType::LINEAR_GRADIENT:
|
2016-08-24 12:06:41 +03:00
|
|
|
new (mLinear)LinearGradientPattern(*static_cast<const LinearGradientPattern*>(&aPattern));
|
2014-08-01 20:01:47 +04:00
|
|
|
return;
|
|
|
|
case PatternType::RADIAL_GRADIENT:
|
2016-08-24 12:06:41 +03:00
|
|
|
new (mRadial)RadialGradientPattern(*static_cast<const RadialGradientPattern*>(&aPattern));
|
2014-08-01 20:01:47 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~StoredPattern()
|
|
|
|
{
|
2016-08-24 12:06:41 +03:00
|
|
|
reinterpret_cast<Pattern*>(mPattern)->~Pattern();
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
operator Pattern&()
|
|
|
|
{
|
2016-08-24 12:06:41 +03:00
|
|
|
return *reinterpret_cast<Pattern*>(mPattern);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
operator const Pattern&() const
|
|
|
|
{
|
2016-08-24 12:06:41 +03:00
|
|
|
return *reinterpret_cast<const Pattern*>(mPattern);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
StoredPattern(const StoredPattern& aPattern)
|
|
|
|
{
|
|
|
|
Assign(aPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
StoredPattern operator=(const StoredPattern& aOther)
|
|
|
|
{
|
|
|
|
// Block this so that we notice if someone's doing excessive assigning.
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
union {
|
2016-08-24 12:06:41 +03:00
|
|
|
char mPattern[sizeof(Pattern)];
|
2014-08-01 20:01:47 +04:00
|
|
|
char mColor[sizeof(ColorPattern)];
|
|
|
|
char mLinear[sizeof(LinearGradientPattern)];
|
|
|
|
char mRadial[sizeof(RadialGradientPattern)];
|
|
|
|
char mSurface[sizeof(SurfacePattern)];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class DrawSurfaceCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DrawSurfaceCommand(SourceSurface *aSurface, const Rect& aDest,
|
|
|
|
const Rect& aSource, const DrawSurfaceOptions& aSurfOptions,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
: DrawingCommand(CommandType::DRAWSURFACE)
|
|
|
|
, mSurface(aSurface), mDest(aDest)
|
|
|
|
, mSource(aSource), mSurfOptions(aSurfOptions)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(DrawSurfaceCommand)(mSurface, mDest, mSource, mSurfOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->DrawSurface(mSurface, mDest, mSource, mSurfOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> mSurface;
|
2014-08-01 20:01:47 +04:00
|
|
|
Rect mDest;
|
|
|
|
Rect mSource;
|
|
|
|
DrawSurfaceOptions mSurfOptions;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
class DrawSurfaceWithShadowCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DrawSurfaceWithShadowCommand(SourceSurface *aSurface,
|
|
|
|
const Point &aDest,
|
|
|
|
const Color &aColor,
|
|
|
|
const Point &aOffset,
|
|
|
|
Float aSigma,
|
|
|
|
CompositionOp aOperator)
|
|
|
|
: DrawingCommand(CommandType::DRAWSURFACEWITHSHADOW),
|
|
|
|
mSurface(aSurface),
|
|
|
|
mDest(aDest),
|
|
|
|
mColor(aColor),
|
|
|
|
mOffset(aOffset),
|
|
|
|
mSigma(aSigma),
|
|
|
|
mOperator(aOperator)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(DrawSurfaceWithShadowCommand)(mSurface, mDest, mColor, mOffset, mSigma, mOperator);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
|
|
|
{
|
|
|
|
aDT->DrawSurfaceWithShadow(mSurface, mDest, mColor, mOffset, mSigma, mOperator);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
private:
|
|
|
|
RefPtr<SourceSurface> mSurface;
|
|
|
|
Point mDest;
|
|
|
|
Color mColor;
|
|
|
|
Point mOffset;
|
|
|
|
Float mSigma;
|
|
|
|
CompositionOp mOperator;
|
|
|
|
};
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
class DrawFilterCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DrawFilterCommand(FilterNode* aFilter, const Rect& aSourceRect,
|
|
|
|
const Point& aDestPoint, const DrawOptions& aOptions)
|
2015-05-26 09:59:47 +03:00
|
|
|
: DrawingCommand(CommandType::DRAWSURFACE)
|
2014-08-01 20:01:47 +04:00
|
|
|
, mFilter(aFilter), mSourceRect(aSourceRect)
|
|
|
|
, mDestPoint(aDestPoint), mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(DrawFilterCommand)(mFilter, mSourceRect, mDestPoint, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->DrawFilter(mFilter, mSourceRect, mDestPoint, mOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FilterNode> mFilter;
|
2014-08-01 20:01:47 +04:00
|
|
|
Rect mSourceRect;
|
|
|
|
Point mDestPoint;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ClearRectCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit ClearRectCommand(const Rect& aRect)
|
2014-08-01 20:01:47 +04:00
|
|
|
: DrawingCommand(CommandType::CLEARRECT)
|
|
|
|
, mRect(aRect)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(ClearRectCommand)(mRect);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->ClearRect(mRect);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
Rect mRect;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CopySurfaceCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CopySurfaceCommand(SourceSurface* aSurface,
|
|
|
|
const IntRect& aSourceRect,
|
|
|
|
const IntPoint& aDestination)
|
|
|
|
: DrawingCommand(CommandType::COPYSURFACE)
|
|
|
|
, mSurface(aSurface)
|
|
|
|
, mSourceRect(aSourceRect)
|
|
|
|
, mDestination(aDestination)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(CopySurfaceCommand)(mSurface, mSourceRect, mDestination);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
2015-09-28 14:49:45 +03:00
|
|
|
MOZ_ASSERT(!aTransform || !aTransform->HasNonIntegerTranslation());
|
2014-08-01 20:01:47 +04:00
|
|
|
Point dest(Float(mDestination.x), Float(mDestination.y));
|
2015-09-28 14:49:45 +03:00
|
|
|
if (aTransform) {
|
2016-09-08 19:26:03 +03:00
|
|
|
dest = aTransform->TransformPoint(dest);
|
2015-09-28 14:49:45 +03:00
|
|
|
}
|
2014-08-01 20:01:47 +04:00
|
|
|
aDT->CopySurface(mSurface, mSourceRect, IntPoint(uint32_t(dest.x), uint32_t(dest.y)));
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> mSurface;
|
2014-08-01 20:01:47 +04:00
|
|
|
IntRect mSourceRect;
|
|
|
|
IntPoint mDestination;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FillRectCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FillRectCommand(const Rect& aRect,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
: DrawingCommand(CommandType::FILLRECT)
|
|
|
|
, mRect(aRect)
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(FillRectCommand)(mRect, mPattern, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->FillRect(mRect, mPattern, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const
|
2015-06-10 20:57:08 +03:00
|
|
|
{
|
|
|
|
aDeviceRect = aTransform.TransformBounds(mRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
Rect mRect;
|
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
2017-07-20 23:14:51 +03:00
|
|
|
class StrokeRectCommand : public StrokeOptionsCommand
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StrokeRectCommand(const Rect& aRect,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions)
|
2017-07-20 23:14:51 +03:00
|
|
|
: StrokeOptionsCommand(CommandType::STROKERECT, aStrokeOptions)
|
2014-08-01 20:01:47 +04:00
|
|
|
, mRect(aRect)
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(StrokeRectCommand)(mRect, mPattern, mStrokeOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->StrokeRect(mRect, mPattern, mStrokeOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
Rect mRect;
|
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
2017-07-20 23:14:51 +03:00
|
|
|
class StrokeLineCommand : public StrokeOptionsCommand
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StrokeLineCommand(const Point& aStart,
|
|
|
|
const Point& aEnd,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions)
|
2017-07-20 23:14:51 +03:00
|
|
|
: StrokeOptionsCommand(CommandType::STROKELINE, aStrokeOptions)
|
2014-08-01 20:01:47 +04:00
|
|
|
, mStart(aStart)
|
|
|
|
, mEnd(aEnd)
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(StrokeLineCommand)(mStart, mEnd, mPattern, mStrokeOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->StrokeLine(mStart, mEnd, mPattern, mStrokeOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
Point mStart;
|
|
|
|
Point mEnd;
|
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FillCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FillCommand(const Path* aPath,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
: DrawingCommand(CommandType::FILL)
|
|
|
|
, mPath(const_cast<Path*>(aPath))
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(FillCommand)(mPath, mPattern, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->Fill(mPath, mPattern, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const
|
2015-06-10 20:57:08 +03:00
|
|
|
{
|
|
|
|
aDeviceRect = mPath->GetBounds(aTransform);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> mPath;
|
2014-08-01 20:01:47 +04:00
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
2015-06-10 20:57:08 +03:00
|
|
|
#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);
|
|
|
|
|
2017-02-28 23:48:04 +03:00
|
|
|
// 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);
|
|
|
|
|
2015-06-10 20:57:08 +03:00
|
|
|
Rect result = aRect;
|
|
|
|
result.Inflate(dx, dy);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-07-20 23:14:51 +03:00
|
|
|
|
|
|
|
class StrokeCommand : public StrokeOptionsCommand
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StrokeCommand(const Path* aPath,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions)
|
2017-07-20 23:14:51 +03:00
|
|
|
: StrokeOptionsCommand(CommandType::STROKE, aStrokeOptions)
|
2014-08-01 20:01:47 +04:00
|
|
|
, mPath(const_cast<Path*>(aPath))
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(StrokeCommand)(mPath, mPattern, mStrokeOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->Stroke(mPath, mPattern, mStrokeOptions, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const
|
2015-06-10 20:57:08 +03:00
|
|
|
{
|
|
|
|
aDeviceRect = PathExtentsToMaxStrokeExtents(mStrokeOptions, mPath->GetBounds(aTransform), aTransform);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> mPath;
|
2014-08-01 20:01:47 +04:00
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FillGlyphsCommand : public DrawingCommand
|
|
|
|
{
|
2016-11-24 08:11:29 +03:00
|
|
|
friend class DrawTargetCaptureImpl;
|
2014-08-01 20:01:47 +04:00
|
|
|
public:
|
|
|
|
FillGlyphsCommand(ScaledFont* aFont,
|
|
|
|
const GlyphBuffer& aBuffer,
|
|
|
|
const Pattern& aPattern,
|
2017-11-03 04:42:56 +03:00
|
|
|
const DrawOptions& aOptions)
|
2014-08-01 20:01:47 +04:00
|
|
|
: DrawingCommand(CommandType::FILLGLYPHS)
|
|
|
|
, mFont(aFont)
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
mGlyphs.resize(aBuffer.mNumGlyphs);
|
|
|
|
memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
GlyphBuffer glyphs = {
|
|
|
|
mGlyphs.data(),
|
|
|
|
(uint32_t)mGlyphs.size(),
|
|
|
|
};
|
2017-11-03 04:42:56 +03:00
|
|
|
CLONE_INTO(FillGlyphsCommand)(mFont, glyphs, mPattern, mOptions);
|
2017-10-31 22:02:31 +03:00
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
GlyphBuffer buf;
|
|
|
|
buf.mNumGlyphs = mGlyphs.size();
|
|
|
|
buf.mGlyphs = &mGlyphs.front();
|
2017-11-03 04:42:56 +03:00
|
|
|
aDT->FillGlyphs(mFont, buf, mPattern, mOptions);
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ScaledFont> mFont;
|
2014-08-01 20:01:47 +04:00
|
|
|
std::vector<Glyph> mGlyphs;
|
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
2017-07-20 23:14:51 +03:00
|
|
|
class StrokeGlyphsCommand : public StrokeOptionsCommand
|
2017-07-15 03:48:00 +03:00
|
|
|
{
|
|
|
|
friend class DrawTargetCaptureImpl;
|
|
|
|
public:
|
|
|
|
StrokeGlyphsCommand(ScaledFont* aFont,
|
|
|
|
const GlyphBuffer& aBuffer,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
2017-11-03 04:42:56 +03:00
|
|
|
const DrawOptions& aOptions)
|
2017-07-20 23:14:51 +03:00
|
|
|
: StrokeOptionsCommand(CommandType::STROKEGLYPHS, aStrokeOptions)
|
2017-07-15 03:48:00 +03:00
|
|
|
, mFont(aFont)
|
|
|
|
, mPattern(aPattern)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
mGlyphs.resize(aBuffer.mNumGlyphs);
|
|
|
|
memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
GlyphBuffer glyphs = {
|
|
|
|
mGlyphs.data(),
|
|
|
|
(uint32_t)mGlyphs.size(),
|
|
|
|
};
|
2017-11-03 04:42:56 +03:00
|
|
|
CLONE_INTO(StrokeGlyphsCommand)(mFont, glyphs, mPattern, mStrokeOptions, mOptions);
|
2017-10-31 22:02:31 +03:00
|
|
|
}
|
|
|
|
|
2017-07-15 03:48:00 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
|
|
|
{
|
|
|
|
GlyphBuffer buf;
|
|
|
|
buf.mNumGlyphs = mGlyphs.size();
|
|
|
|
buf.mGlyphs = &mGlyphs.front();
|
2017-11-03 04:42:56 +03:00
|
|
|
aDT->StrokeGlyphs(mFont, buf, mPattern, mStrokeOptions, mOptions);
|
2017-07-15 03:48:00 +03:00
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2017-07-15 03:48:00 +03:00
|
|
|
private:
|
|
|
|
RefPtr<ScaledFont> mFont;
|
|
|
|
std::vector<Glyph> mGlyphs;
|
|
|
|
StoredPattern mPattern;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
class MaskCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MaskCommand(const Pattern& aSource,
|
|
|
|
const Pattern& aMask,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
: DrawingCommand(CommandType::MASK)
|
|
|
|
, mSource(aSource)
|
|
|
|
, mMask(aMask)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(MaskCommand)(mSource, mMask, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->Mask(mSource, mMask, mOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
StoredPattern mSource;
|
|
|
|
StoredPattern mMask;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MaskSurfaceCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MaskSurfaceCommand(const Pattern& aSource,
|
|
|
|
const SourceSurface* aMask,
|
|
|
|
const Point& aOffset,
|
|
|
|
const DrawOptions& aOptions)
|
|
|
|
: DrawingCommand(CommandType::MASKSURFACE)
|
|
|
|
, mSource(aSource)
|
|
|
|
, mMask(const_cast<SourceSurface*>(aMask))
|
|
|
|
, mOffset(aOffset)
|
|
|
|
, mOptions(aOptions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(MaskSurfaceCommand)(mSource, mMask, mOffset, mOptions);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->MaskSurface(mSource, mMask, mOffset, mOptions);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
StoredPattern mSource;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> mMask;
|
2014-08-01 20:01:47 +04:00
|
|
|
Point mOffset;
|
|
|
|
DrawOptions mOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PushClipCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit PushClipCommand(const Path* aPath)
|
2014-08-01 20:01:47 +04:00
|
|
|
: DrawingCommand(CommandType::PUSHCLIP)
|
|
|
|
, mPath(const_cast<Path*>(aPath))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(PushClipCommand)(mPath);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->PushClip(mPath);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = false;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> mPath;
|
2014-08-01 20:01:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class PushClipRectCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit PushClipRectCommand(const Rect& aRect)
|
2014-08-01 20:01:47 +04:00
|
|
|
: DrawingCommand(CommandType::PUSHCLIPRECT)
|
|
|
|
, mRect(aRect)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(PushClipRectCommand)(mRect);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->PushClipRect(mRect);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = false;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
Rect mRect;
|
|
|
|
};
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
class PushLayerCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PushLayerCommand(const bool aOpaque,
|
|
|
|
const Float aOpacity,
|
|
|
|
SourceSurface* aMask,
|
|
|
|
const Matrix& aMaskTransform,
|
|
|
|
const IntRect& aBounds,
|
|
|
|
bool aCopyBackground)
|
|
|
|
: DrawingCommand(CommandType::PUSHLAYER)
|
|
|
|
, mOpaque(aOpaque)
|
|
|
|
, mOpacity(aOpacity)
|
|
|
|
, mMask(aMask)
|
|
|
|
, mMaskTransform(aMaskTransform)
|
|
|
|
, mBounds(aBounds)
|
|
|
|
, mCopyBackground(aCopyBackground)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(PushLayerCommand)(mOpaque, mOpacity, mMask, mMaskTransform, mBounds, mCopyBackground);
|
|
|
|
}
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
|
|
|
{
|
|
|
|
aDT->PushLayer(mOpaque, mOpacity, mMask,
|
|
|
|
mMaskTransform, mBounds, mCopyBackground);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = false;
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
private:
|
|
|
|
bool mOpaque;
|
|
|
|
float mOpacity;
|
|
|
|
RefPtr<SourceSurface> mMask;
|
|
|
|
Matrix mMaskTransform;
|
|
|
|
IntRect mBounds;
|
|
|
|
bool mCopyBackground;
|
|
|
|
};
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
class PopClipCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PopClipCommand()
|
|
|
|
: DrawingCommand(CommandType::POPCLIP)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(PopClipCommand)();
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
|
|
|
aDT->PopClip();
|
|
|
|
}
|
2017-10-31 22:02:31 +03:00
|
|
|
|
|
|
|
static const bool AffectsSnapshot = false;
|
2014-08-01 20:01:47 +04:00
|
|
|
};
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
class PopLayerCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PopLayerCommand()
|
|
|
|
: DrawingCommand(CommandType::POPLAYER)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(PopLayerCommand)();
|
|
|
|
}
|
|
|
|
|
2017-06-22 00:19:42 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
|
|
|
{
|
|
|
|
aDT->PopLayer();
|
|
|
|
}
|
2017-10-31 22:02:31 +03:00
|
|
|
|
|
|
|
static const bool AffectsSnapshot = true;
|
2017-06-22 00:19:42 +03:00
|
|
|
};
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
class SetTransformCommand : public DrawingCommand
|
|
|
|
{
|
2016-11-24 08:11:29 +03:00
|
|
|
friend class DrawTargetCaptureImpl;
|
2014-08-01 20:01:47 +04:00
|
|
|
public:
|
2014-09-01 07:31:20 +04:00
|
|
|
explicit SetTransformCommand(const Matrix& aTransform)
|
2014-08-01 20:01:47 +04:00
|
|
|
: DrawingCommand(CommandType::SETTRANSFORM)
|
|
|
|
, mTransform(aTransform)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(SetTransformCommand)(mTransform);
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aMatrix) const
|
2014-08-01 20:01:47 +04:00
|
|
|
{
|
2015-09-28 14:49:45 +03:00
|
|
|
if (aMatrix) {
|
|
|
|
aDT->SetTransform(mTransform * (*aMatrix));
|
|
|
|
} else {
|
|
|
|
aDT->SetTransform(mTransform);
|
|
|
|
}
|
2014-08-01 20:01:47 +04:00
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = false;
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
private:
|
|
|
|
Matrix mTransform;
|
|
|
|
};
|
|
|
|
|
2017-09-13 22:15:16 +03:00
|
|
|
class SetPermitSubpixelAACommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
friend class DrawTargetCaptureImpl;
|
|
|
|
public:
|
|
|
|
explicit SetPermitSubpixelAACommand(bool aPermitSubpixelAA)
|
|
|
|
: DrawingCommand(CommandType::SETPERMITSUBPIXELAA)
|
|
|
|
, mPermitSubpixelAA(aPermitSubpixelAA)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(SetPermitSubpixelAACommand)(mPermitSubpixelAA);
|
|
|
|
}
|
|
|
|
|
2017-09-13 22:15:16 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aMatrix) const
|
|
|
|
{
|
|
|
|
aDT->SetPermitSubpixelAA(mPermitSubpixelAA);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = false;
|
|
|
|
|
2017-09-13 22:15:16 +03:00
|
|
|
private:
|
|
|
|
bool mPermitSubpixelAA;
|
|
|
|
};
|
|
|
|
|
2015-06-10 20:57:08 +03:00
|
|
|
class FlushCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit FlushCommand()
|
|
|
|
: DrawingCommand(CommandType::FLUSH)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(FlushCommand)();
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:49:50 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
|
2015-06-10 20:57:08 +03:00
|
|
|
{
|
|
|
|
aDT->Flush();
|
|
|
|
}
|
2017-10-31 22:02:31 +03:00
|
|
|
|
|
|
|
static const bool AffectsSnapshot = false;
|
2015-06-10 20:57:08 +03:00
|
|
|
};
|
|
|
|
|
2017-10-31 22:02:30 +03:00
|
|
|
class BlurCommand : public DrawingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit BlurCommand(const AlphaBoxBlur& aBlur)
|
|
|
|
: DrawingCommand(CommandType::BLUR)
|
|
|
|
, mBlur(aBlur)
|
|
|
|
{}
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
void CloneInto(CaptureCommandList* aList) {
|
|
|
|
CLONE_INTO(BlurCommand)(mBlur);
|
|
|
|
}
|
|
|
|
|
2017-10-31 22:02:30 +03:00
|
|
|
virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const {
|
|
|
|
aDT->Blur(mBlur);
|
|
|
|
}
|
2015-07-13 18:25:42 +03:00
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
static const bool AffectsSnapshot = true;
|
|
|
|
|
2017-10-31 22:02:30 +03:00
|
|
|
private:
|
|
|
|
AlphaBoxBlur mBlur;
|
|
|
|
};
|
|
|
|
|
2017-10-31 22:02:31 +03:00
|
|
|
#undef CLONE_INTO
|
|
|
|
|
2017-10-31 22:02:30 +03:00
|
|
|
} // namespace gfx
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-08-01 20:01:47 +04:00
|
|
|
#endif /* MOZILLA_GFX_DRAWCOMMAND_H_ */
|