SkPaint: clean up ctor, dtor, etc
Change-Id: I5a333112f68fcd001f39e646570a246875c03bc3 Reviewed-on: https://skia-review.googlesource.com/c/191566 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
7c979f52c3
commit
59cf562826
@ -680,6 +680,7 @@ private:
|
||||
unsigned fStyle : 2;
|
||||
unsigned fFilterQuality : 2;
|
||||
unsigned fBlendMode : 8; // only need 5-6?
|
||||
unsigned fPadding : 14; // 14==32-1-1-2-2-2-2-8
|
||||
} fBitfields;
|
||||
uint32_t fBitfieldsUInt;
|
||||
};
|
||||
|
@ -39,97 +39,32 @@
|
||||
// e.g. setTextSize(-1)
|
||||
//#define SK_REPORT_API_RANGE_CHECK
|
||||
|
||||
SkPaint::SkPaint() {
|
||||
fColor4f = { 0, 0, 0, 1 }; // opaque black
|
||||
fWidth = 0;
|
||||
fMiterLimit = SkPaintDefaults_MiterLimit;
|
||||
|
||||
// we init (to 0) and copy using fBitfieldsUInt rather than fBitfields, so we need it
|
||||
// to be large enough to cover all of the bits.
|
||||
static_assert(sizeof(fBitfields) <= sizeof(fBitfieldsUInt),
|
||||
"need union uint to be large enough");
|
||||
|
||||
// Zero all bitfields, then set some non-zero defaults.
|
||||
fBitfieldsUInt = 0;
|
||||
fBitfields.fCapType = kDefault_Cap;
|
||||
fBitfields.fJoinType = kDefault_Join;
|
||||
fBitfields.fStyle = kFill_Style;
|
||||
fBitfields.fBlendMode = (unsigned)SkBlendMode::kSrcOver;
|
||||
SkPaint::SkPaint()
|
||||
: fColor4f{0, 0, 0, 1} // opaque black
|
||||
, fWidth{0}
|
||||
, fMiterLimit{SkPaintDefaults_MiterLimit}
|
||||
, fBitfields{0, // fAntiAlias
|
||||
0, // fDither
|
||||
kDefault_Cap, // fCapType
|
||||
kDefault_Join, // fJoinType
|
||||
kFill_Style, // fStyle
|
||||
0, // fFilterQuality
|
||||
(unsigned)SkBlendMode::kSrcOver, // fBlendMode
|
||||
0} // fPadding
|
||||
{
|
||||
static_assert(sizeof(fBitfields) == sizeof(fBitfieldsUInt), "");
|
||||
}
|
||||
|
||||
SkPaint::SkPaint(const SkPaint& src)
|
||||
#define COPY(field) field(src.field)
|
||||
: COPY(fPathEffect)
|
||||
, COPY(fShader)
|
||||
, COPY(fMaskFilter)
|
||||
, COPY(fColorFilter)
|
||||
, COPY(fDrawLooper)
|
||||
, COPY(fImageFilter)
|
||||
, COPY(fColor4f)
|
||||
, COPY(fWidth)
|
||||
, COPY(fMiterLimit)
|
||||
, COPY(fBitfieldsUInt)
|
||||
#undef COPY
|
||||
{}
|
||||
SkPaint::SkPaint(const SkPaint& src) = default;
|
||||
|
||||
SkPaint::SkPaint(SkPaint&& src) {
|
||||
#define MOVE(field) field = std::move(src.field)
|
||||
MOVE(fPathEffect);
|
||||
MOVE(fShader);
|
||||
MOVE(fMaskFilter);
|
||||
MOVE(fColorFilter);
|
||||
MOVE(fDrawLooper);
|
||||
MOVE(fImageFilter);
|
||||
MOVE(fColor4f);
|
||||
MOVE(fWidth);
|
||||
MOVE(fMiterLimit);
|
||||
MOVE(fBitfieldsUInt);
|
||||
#undef MOVE
|
||||
}
|
||||
SkPaint::SkPaint(SkPaint&& src) = default;
|
||||
|
||||
SkPaint::~SkPaint() {}
|
||||
SkPaint::~SkPaint() = default;
|
||||
|
||||
SkPaint& SkPaint::operator=(const SkPaint& src) {
|
||||
if (this == &src) {
|
||||
return *this;
|
||||
}
|
||||
SkPaint& SkPaint::operator=(const SkPaint& src) = default;
|
||||
|
||||
#define ASSIGN(field) field = src.field
|
||||
ASSIGN(fPathEffect);
|
||||
ASSIGN(fShader);
|
||||
ASSIGN(fMaskFilter);
|
||||
ASSIGN(fColorFilter);
|
||||
ASSIGN(fDrawLooper);
|
||||
ASSIGN(fImageFilter);
|
||||
ASSIGN(fColor4f);
|
||||
ASSIGN(fWidth);
|
||||
ASSIGN(fMiterLimit);
|
||||
ASSIGN(fBitfieldsUInt);
|
||||
#undef ASSIGN
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkPaint& SkPaint::operator=(SkPaint&& src) {
|
||||
if (this == &src) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#define MOVE(field) field = std::move(src.field)
|
||||
MOVE(fPathEffect);
|
||||
MOVE(fShader);
|
||||
MOVE(fMaskFilter);
|
||||
MOVE(fColorFilter);
|
||||
MOVE(fDrawLooper);
|
||||
MOVE(fImageFilter);
|
||||
MOVE(fColor4f);
|
||||
MOVE(fWidth);
|
||||
MOVE(fMiterLimit);
|
||||
MOVE(fBitfieldsUInt);
|
||||
#undef MOVE
|
||||
|
||||
return *this;
|
||||
}
|
||||
SkPaint& SkPaint::operator=(SkPaint&& src) = default;
|
||||
|
||||
bool operator==(const SkPaint& a, const SkPaint& b) {
|
||||
#define EQUAL(field) (a.field == b.field)
|
||||
@ -156,10 +91,7 @@ DEFINE_REF_FOO(PathEffect)
|
||||
DEFINE_REF_FOO(Shader)
|
||||
#undef DEFINE_REF_FOO
|
||||
|
||||
void SkPaint::reset() {
|
||||
SkPaint init;
|
||||
*this = init;
|
||||
}
|
||||
void SkPaint::reset() { *this = SkPaint(); }
|
||||
|
||||
void SkPaint::setFilterQuality(SkFilterQuality quality) {
|
||||
fBitfields.fFilterQuality = quality;
|
||||
|
Loading…
Reference in New Issue
Block a user