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

Unified Diff: src/core/SkPaint.cpp

Issue 240273004: always store bitfields along with dirty in FlatteningTraits (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | « no previous file | tests/PaintTest.cpp » ('j') | 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 682c4ed19ec1346a9309674eaf2feb582f67ee41..45d1d2b36265e97039a2892220ffc2afd6860d22 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -37,7 +37,7 @@
enum {
kColor_DirtyBit = 1 << 0,
robertphillips 2014/04/16 15:39:33 Just delete?
mtklein 2014/04/16 15:53:23 Or // Bit 1 is safe to reuse.
mtklein 2014/04/16 15:54:43 Actually. Hold on. Let's just shift everyone dow
- kBitfields_DirtyBit = 1 << 1,
+// kBitfields_DirtyBit = 1 << 1,
kTextSize_DirtyBit = 1 << 2,
kTextScaleX_DirtyBit = 1 << 3,
kTextSkewX_DirtyBit = 1 << 4,
@@ -254,19 +254,16 @@ void SkPaint::setPaintOptionsAndroid(const SkPaintOptionsAndroid& options) {
void SkPaint::setFilterLevel(FilterLevel level) {
GEN_ID_INC_EVAL((unsigned) level != fFilterLevel);
fFilterLevel = level;
- fDirtyBits |= kBitfields_DirtyBit;
}
void SkPaint::setHinting(Hinting hintingLevel) {
GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting);
fHinting = hintingLevel;
- fDirtyBits |= kBitfields_DirtyBit;
}
void SkPaint::setFlags(uint32_t flags) {
GEN_ID_INC_EVAL(fFlags != flags);
fFlags = flags;
- fDirtyBits |= kBitfields_DirtyBit;
}
void SkPaint::setAntiAlias(bool doAA) {
@@ -325,7 +322,6 @@ void SkPaint::setStyle(Style style) {
if ((unsigned)style < kStyleCount) {
GEN_ID_INC_EVAL((unsigned)style != fStyle);
fStyle = style;
- fDirtyBits |= kBitfields_DirtyBit;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setStyle(%d) out of range\n", style);
@@ -376,7 +372,6 @@ void SkPaint::setStrokeCap(Cap ct) {
if ((unsigned)ct < kCapCount) {
GEN_ID_INC_EVAL((unsigned)ct != fCapType);
fCapType = SkToU8(ct);
- fDirtyBits |= kBitfields_DirtyBit;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct);
@@ -388,7 +383,6 @@ void SkPaint::setStrokeJoin(Join jt) {
if ((unsigned)jt < kJoinCount) {
GEN_ID_INC_EVAL((unsigned)jt != fJoinType);
fJoinType = SkToU8(jt);
- fDirtyBits |= kBitfields_DirtyBit;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt);
@@ -402,7 +396,6 @@ void SkPaint::setTextAlign(Align align) {
if ((unsigned)align < kAlignCount) {
GEN_ID_INC_EVAL((unsigned)align != fTextAlign);
fTextAlign = SkToU8(align);
- fDirtyBits |= kBitfields_DirtyBit;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align);
@@ -438,7 +431,6 @@ void SkPaint::setTextEncoding(TextEncoding encoding) {
if ((unsigned)encoding <= kGlyphID_TextEncoding) {
GEN_ID_INC_EVAL((unsigned)encoding != fTextEncoding);
fTextEncoding = encoding;
- fDirtyBits |= kBitfields_DirtyBit;
} else {
#ifdef SK_REPORT_API_RANGE_CHECK
SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding);
@@ -2650,7 +2642,6 @@ bool SkPaint::nothingToDraw() const {
void SkPaint::setBitfields(uint32_t bitfields) {
fBitfields = bitfields;
- fDirtyBits |= kBitfields_DirtyBit;
}
inline static unsigned popcount(uint8_t x) {
@@ -2664,18 +2655,19 @@ inline static unsigned popcount(uint8_t x) {
void SkPaint::FlatteningTraits::Flatten(SkWriteBuffer& buffer, const SkPaint& paint) {
const uint32_t dirty = paint.fDirtyBits;
- // Each of the low 7 dirty bits corresponds to a 4-byte flat value, plus one for the dirty bits.
- const size_t flatBytes = 4 * (popcount(dirty & 127) + 1);
+ // Each of the low 7 dirty bits corresponds to a 4-byte flat value,
mtklein 2014/04/16 15:53:23 // Each of bits 0,2,3,4,5, and 6 corresponds to a
+ // plus one for the dirty bits and one for the bitfields
+ const size_t flatBytes = 4 * (popcount(dirty & 127) + 2);
SkASSERT(flatBytes <= 32);
uint32_t* u32 = buffer.reserve(flatBytes);
*u32++ = dirty;
robertphillips 2014/04/16 15:39:33 This is minor but, would it make more sense to rea
- if (dirty == 0) {
+ *u32++ = paint.getBitfields();
+ if (0 == dirty) {
return;
}
#define F(dst, field) if (dirty & k##field##_DirtyBit) *dst++ = paint.get##field()
F(u32, Color);
- F(u32, Bitfields);
SkScalar* f32 = reinterpret_cast<SkScalar*>(u32);
F(f32, TextSize);
F(f32, TextScaleX);
@@ -2702,6 +2694,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());
if (dirty == 0) {
return;
}
@@ -2712,7 +2705,6 @@ void SkPaint::FlatteningTraits::Unflatten(SkReadBuffer& buffer, SkPaint* paint)
paint->set##field(buffer.reader())->unref()
F(Color, readUInt);
- F(Bitfields, readUInt);
F(TextSize, readScalar);
F(TextScaleX, readScalar);
F(TextSkewX, readScalar);
« no previous file with comments | « no previous file | tests/PaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698