Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: src/core/SkPaint.cpp

Issue 394603003: patch from issue 383923002 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPaint.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 62db71445ee160c6917ff8f6cd103c21f47a845e..8fc7c1959566e1d0569eb1cde00a5e29fd5aeab3 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -82,22 +82,22 @@ SkPaint::SkPaint() {
fImageFilter = NULL;
fAnnotation = NULL;
- fTextSize = SkPaintDefaults_TextSize;
- fTextScaleX = SK_Scalar1;
- fTextSkewX = 0;
- fColor = SK_ColorBLACK;
- fWidth = 0;
- fMiterLimit = SkPaintDefaults_MiterLimit;
+ fTextSize = SkPaintDefaults_TextSize;
+ fTextScaleX = SK_Scalar1;
+ fTextSkewX = 0;
+ fColor = SK_ColorBLACK;
+ fWidth = 0;
+ fMiterLimit = SkPaintDefaults_MiterLimit;
// Zero all bitfields, then set some non-zero defaults.
- fBitfields = 0;
- fFlags = SkPaintDefaults_Flags;
- fCapType = kDefault_Cap;
- fJoinType = kDefault_Join;
- fTextAlign = kLeft_Align;
- fStyle = kFill_Style;
- fTextEncoding = kUTF8_TextEncoding;
- fHinting = SkPaintDefaults_Hinting;
+ fBitfieldsUInt = 0;
+ fBitfields.fFlags = SkPaintDefaults_Flags;
+ fBitfields.fCapType = kDefault_Cap;
+ fBitfields.fJoinType = kDefault_Join;
+ fBitfields.fTextAlign = kLeft_Align;
+ fBitfields.fStyle = kFill_Style;
+ fBitfields.fTextEncoding = kUTF8_TextEncoding;
+ fBitfields.fHinting = SkPaintDefaults_Hinting;
fDirtyBits = 0;
#ifdef SK_BUILD_FOR_ANDROID
@@ -213,7 +213,7 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
&& EQUAL(fColor)
&& EQUAL(fWidth)
&& EQUAL(fMiterLimit)
- && EQUAL(fBitfields)
+ && EQUAL(fBitfieldsUInt)
#ifdef SK_BUILD_FOR_ANDROID
&& EQUAL(fPaintOptionsAndroid)
#endif
@@ -258,76 +258,76 @@ void SkPaint::setPaintOptionsAndroid(const SkPaintOptionsAndroid& options) {
#endif
void SkPaint::setFilterLevel(FilterLevel level) {
- GEN_ID_INC_EVAL((unsigned) level != fFilterLevel);
- fFilterLevel = level;
+ GEN_ID_INC_EVAL((unsigned) level != fBitfields.fFilterLevel);
+ fBitfields.fFilterLevel = level;
}
void SkPaint::setHinting(Hinting hintingLevel) {
- GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting);
- fHinting = hintingLevel;
+ GEN_ID_INC_EVAL((unsigned) hintingLevel != fBitfields.fHinting);
+ fBitfields.fHinting = hintingLevel;
}
void SkPaint::setFlags(uint32_t flags) {
- GEN_ID_INC_EVAL(fFlags != flags);
- fFlags = flags;
+ GEN_ID_INC_EVAL(flags != fBitfields.fFlags);
+ fBitfields.fFlags = flags;
}
void SkPaint::setAntiAlias(bool doAA) {
- this->setFlags(SkSetClearMask(fFlags, doAA, kAntiAlias_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doAA, kAntiAlias_Flag));
}
void SkPaint::setDither(bool doDither) {
- this->setFlags(SkSetClearMask(fFlags, doDither, kDither_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doDither, kDither_Flag));
}
void SkPaint::setSubpixelText(bool doSubpixel) {
- this->setFlags(SkSetClearMask(fFlags, doSubpixel, kSubpixelText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doSubpixel, kSubpixelText_Flag));
}
void SkPaint::setLCDRenderText(bool doLCDRender) {
- this->setFlags(SkSetClearMask(fFlags, doLCDRender, kLCDRenderText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doLCDRender, kLCDRenderText_Flag));
}
void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) {
- this->setFlags(SkSetClearMask(fFlags, doEmbeddedBitmapText, kEmbeddedBitmapText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doEmbeddedBitmapText, kEmbeddedBitmapText_Flag));
}
void SkPaint::setAutohinted(bool useAutohinter) {
- this->setFlags(SkSetClearMask(fFlags, useAutohinter, kAutoHinting_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, useAutohinter, kAutoHinting_Flag));
}
void SkPaint::setLinearText(bool doLinearText) {
- this->setFlags(SkSetClearMask(fFlags, doLinearText, kLinearText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doLinearText, kLinearText_Flag));
}
void SkPaint::setVerticalText(bool doVertical) {
- this->setFlags(SkSetClearMask(fFlags, doVertical, kVerticalText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doVertical, kVerticalText_Flag));
}
void SkPaint::setUnderlineText(bool doUnderline) {
- this->setFlags(SkSetClearMask(fFlags, doUnderline, kUnderlineText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doUnderline, kUnderlineText_Flag));
}
void SkPaint::setStrikeThruText(bool doStrikeThru) {
- this->setFlags(SkSetClearMask(fFlags, doStrikeThru, kStrikeThruText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doStrikeThru, kStrikeThruText_Flag));
}
void SkPaint::setFakeBoldText(bool doFakeBold) {
- this->setFlags(SkSetClearMask(fFlags, doFakeBold, kFakeBoldText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doFakeBold, kFakeBoldText_Flag));
}
void SkPaint::setDevKernText(bool doDevKern) {
- this->setFlags(SkSetClearMask(fFlags, doDevKern, kDevKernText_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doDevKern, kDevKernText_Flag));
}
void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) {
- this->setFlags(SkSetClearMask(fFlags, doDistanceFieldText, kDistanceFieldTextTEMP_Flag));
+ this->setFlags(SkSetClearMask(fBitfields.fFlags, doDistanceFieldText, kDistanceFieldTextTEMP_Flag));
}
void SkPaint::setStyle(Style style) {
if ((unsigned)style < kStyleCount) {
- GEN_ID_INC_EVAL((unsigned)style != fStyle);
- fStyle = style;
+ GEN_ID_INC_EVAL((unsigned)style != fBitfields.fStyle);
+ fBitfields.fStyle = style;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setStyle(%d) out of range\n", style);
@@ -376,8 +376,8 @@ void SkPaint::setStrokeMiter(SkScalar limit) {
void SkPaint::setStrokeCap(Cap ct) {
if ((unsigned)ct < kCapCount) {
- GEN_ID_INC_EVAL((unsigned)ct != fCapType);
- fCapType = SkToU8(ct);
+ GEN_ID_INC_EVAL((unsigned)ct != fBitfields.fCapType);
+ fBitfields.fCapType = SkToU8(ct);
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct);
@@ -387,8 +387,8 @@ void SkPaint::setStrokeCap(Cap ct) {
void SkPaint::setStrokeJoin(Join jt) {
if ((unsigned)jt < kJoinCount) {
- GEN_ID_INC_EVAL((unsigned)jt != fJoinType);
- fJoinType = SkToU8(jt);
+ GEN_ID_INC_EVAL((unsigned)jt != fBitfields.fJoinType);
+ fBitfields.fJoinType = SkToU8(jt);
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt);
@@ -400,8 +400,8 @@ void SkPaint::setStrokeJoin(Join jt) {
void SkPaint::setTextAlign(Align align) {
if ((unsigned)align < kAlignCount) {
- GEN_ID_INC_EVAL((unsigned)align != fTextAlign);
- fTextAlign = SkToU8(align);
+ GEN_ID_INC_EVAL((unsigned)align != fBitfields.fTextAlign);
+ fBitfields.fTextAlign = SkToU8(align);
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align);
@@ -435,8 +435,8 @@ void SkPaint::setTextSkewX(SkScalar skewX) {
void SkPaint::setTextEncoding(TextEncoding encoding) {
if ((unsigned)encoding <= kGlyphID_TextEncoding) {
- GEN_ID_INC_EVAL((unsigned)encoding != fTextEncoding);
- fTextEncoding = encoding;
+ GEN_ID_INC_EVAL((unsigned)encoding != fBitfields.fTextEncoding);
+ fBitfields.fTextEncoding = encoding;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding);
@@ -953,7 +953,7 @@ SkDrawCacheProc SkPaint::getDrawCacheProc() const {
};
unsigned index = this->getTextEncoding();
- if (fFlags & kSubpixelText_Flag) {
+ if (fBitfields.fFlags & kSubpixelText_Flag) {
index += 4;
}
@@ -2658,10 +2658,6 @@ bool SkPaint::nothingToDraw() const {
return false;
}
-void SkPaint::setBitfields(uint32_t bitfields) {
- fBitfields = bitfields;
-}
-
inline static unsigned popcount(uint8_t x) {
// As in Hacker's delight, adapted for just 8 bits.
x = (x & 0x55) + ((x >> 1) & 0x55); // a b c d w x y z -> a+b c+d w+x y+z
@@ -2679,7 +2675,7 @@ void SkPaint::FlatteningTraits::Flatten(SkWriteBuffer& buffer, const SkPaint& pa
SkASSERT(flatBytes <= 32);
uint32_t* u32 = buffer.reserve(flatBytes);
*u32++ = dirty;
- *u32++ = paint.getBitfields();
+ *u32++ = paint.fBitfieldsUInt;
if (0 == dirty) {
return;
}
@@ -2712,7 +2708,7 @@ void SkPaint::FlatteningTraits::Flatten(SkWriteBuffer& buffer, const SkPaint& pa
void SkPaint::FlatteningTraits::Unflatten(SkReadBuffer& buffer, SkPaint* paint) {
const uint32_t dirty = buffer.readUInt();
- paint->setBitfields(buffer.readUInt());
+ paint->fBitfieldsUInt = buffer.readUInt();
if (dirty == 0) {
return;
}
« no previous file with comments | « include/core/SkPaint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698