hide SkPaint::getFlags/setFlags, use bool acessors instead

Bug: skia:
Change-Id: Ib44859bf69a9dfaae7fbbd220b41af0c198797c6
Reviewed-on: https://skia-review.googlesource.com/c/184388
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Mike Reed 2019-01-16 17:12:15 -05:00 committed by Skia Commit-Bot
parent 2a6ca81927
commit f738d4211c
5 changed files with 34 additions and 23 deletions

View File

@ -227,6 +227,7 @@ public:
};
#endif
#ifdef SK_SUPPORT_LEGACY_PAINT_FLAGS
/** Returns paint settings described by SkPaint::Flags. Each setting uses one
bit, and can be tested with SkPaint::Flags members.
@ -240,6 +241,7 @@ public:
@param flags union of SkPaint::Flags for SkPaint
*/
void setFlags(uint32_t flags);
#endif
/** Returns true if pixels on the active edges of SkPath may be drawn with partial transparency.
@ -248,7 +250,7 @@ public:
@return kAntiAlias_Flag state
*/
bool isAntiAlias() const {
return SkToBool(this->getFlags() & kAntiAlias_Flag);
return SkToBool(this->internal_getFlags() & kAntiAlias_Flag);
}
/** Requests, but does not require, that edge pixels draw opaque or with
@ -268,7 +270,7 @@ public:
@return kDither_Flag state
*/
bool isDither() const {
return SkToBool(this->getFlags() & kDither_Flag);
return SkToBool(this->internal_getFlags() & kDither_Flag);
}
/** Requests, but does not require, to distribute color error.
@ -288,7 +290,7 @@ public:
@return kLinearText_Flag state
*/
bool isLinearText() const {
return SkToBool(this->getFlags() & kLinearText_Flag);
return SkToBool(this->internal_getFlags() & kLinearText_Flag);
}
/** Requests, but does not require, that glyphs are converted to SkPath
@ -309,7 +311,7 @@ public:
@return kSubpixelText_Flag state
*/
bool isSubpixelText() const {
return SkToBool(this->getFlags() & kSubpixelText_Flag);
return SkToBool(this->internal_getFlags() & kSubpixelText_Flag);
}
/** Requests, but does not require, that glyphs respect sub-pixel positioning.
@ -328,7 +330,7 @@ public:
@return kLCDRenderText_Flag state
*/
bool isLCDRenderText() const {
return SkToBool(this->getFlags() & kLCDRenderText_Flag);
return SkToBool(this->internal_getFlags() & kLCDRenderText_Flag);
}
/** Requests, but does not require, that glyphs use LCD striping for glyph edges.
@ -347,7 +349,7 @@ public:
@return kEmbeddedBitmapText_Flag state
*/
bool isEmbeddedBitmapText() const {
return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag);
return SkToBool(this->internal_getFlags() & kEmbeddedBitmapText_Flag);
}
/** Requests, but does not require, to use bitmaps in fonts instead of outlines.
@ -368,7 +370,7 @@ public:
@return kAutoHinting_Flag state
*/
bool isAutohinted() const {
return SkToBool(this->getFlags() & kAutoHinting_Flag);
return SkToBool(this->internal_getFlags() & kAutoHinting_Flag);
}
/** Sets whether to always hint glyphs.
@ -394,7 +396,7 @@ public:
@return kFakeBoldText_Flag state
*/
bool isFakeBoldText() const {
return SkToBool(this->getFlags() & kFakeBoldText_Flag);
return SkToBool(this->internal_getFlags() & kFakeBoldText_Flag);
}
/** Increases stroke width when creating glyph bitmaps to approximate a bold typeface.
@ -1091,6 +1093,12 @@ private:
uint32_t fBitfieldsUInt;
};
uint32_t internal_getFlags() const { return fBitfields.fFlags; }
void internal_setFlags(uint32_t flags) {
fBitfields.fFlags = flags;
}
SkTextEncoding private_internal_getTextEncoding() const {
return (SkTextEncoding)fBitfields.fTextEncoding;
}
@ -1146,7 +1154,7 @@ private:
friend class SkPaintPriv;
friend class SkPicturePlayback;
friend class SkPDFDevice;
friend class SkScalerContext; // for computeLuminanceColor()
friend class SkScalerContext;
friend class SkTextBaseIter;
friend class SkTextBlobCacheDiffCanvas;
};

View File

@ -1030,7 +1030,8 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, const SkPaint& paint) cons
// We can't call drawBitmap, or we'll infinitely recurse. Instead
// we manually build a shader and draw that into our new mask
SkPaint tmpPaint;
tmpPaint.setFlags(paint.getFlags());
tmpPaint.setAntiAlias(paint.isAntiAlias());
tmpPaint.setDither(paint.isDither());
tmpPaint.setFilterQuality(paint.getFilterQuality());
SkPaint paintWithShader = make_paint_with_image(tmpPaint, bitmap);
SkRect rr;

View File

@ -200,41 +200,43 @@ void SkPaint::setHinting(SkFontHinting hintingLevel) {
fBitfields.fHinting = static_cast<unsigned>(hintingLevel);
}
#ifdef SK_SUPPORT_LEGACY_PAINT_FLAGS
void SkPaint::setFlags(uint32_t flags) {
fBitfields.fFlags = flags;
}
#endif
void SkPaint::setAntiAlias(bool doAA) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doAA, kAntiAlias_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doAA, kAntiAlias_Flag));
}
void SkPaint::setDither(bool doDither) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doDither, kDither_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doDither, kDither_Flag));
}
#ifdef SK_SUPPORT_LEGACY_PAINT_FONT_FIELDS
void SkPaint::setSubpixelText(bool doSubpixel) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doSubpixel, kSubpixelText_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doSubpixel, kSubpixelText_Flag));
}
void SkPaint::setLCDRenderText(bool doLCDRender) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doLCDRender, kLCDRenderText_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doLCDRender, kLCDRenderText_Flag));
}
void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doEmbeddedBitmapText, kEmbeddedBitmapText_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doEmbeddedBitmapText, kEmbeddedBitmapText_Flag));
}
void SkPaint::setAutohinted(bool useAutohinter) {
this->setFlags(set_clear_mask(fBitfields.fFlags, useAutohinter, kAutoHinting_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, useAutohinter, kAutoHinting_Flag));
}
void SkPaint::setLinearText(bool doLinearText) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doLinearText, kLinearText_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doLinearText, kLinearText_Flag));
}
void SkPaint::setFakeBoldText(bool doFakeBold) {
this->setFlags(set_clear_mask(fBitfields.fFlags, doFakeBold, kFakeBoldText_Flag));
this->internal_setFlags(set_clear_mask(fBitfields.fFlags, doFakeBold, kFakeBoldText_Flag));
}
#endif

View File

@ -85,10 +85,12 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo(
}
if (kEntirePaint_Bits == bits) {
// we've already computed these, so save it from the assignment
uint32_t f = dst->getFlags();
bool aa = dst->isAntiAlias();
bool di = dst->isDither();
SkColor4f c = dst->getColor4f();
*dst = src;
dst->setFlags(f);
dst->setAntiAlias(aa);
dst->setDither(di);
dst->setColor4f(c, sk_srgb_singleton());
return;
}

View File

@ -1003,9 +1003,7 @@ void SkScalerContext_DW::generateColorGlyphImage(const SkGlyph& glyph) {
draw.fRC = &rc;
SkPaint paint;
if (fRenderingMode != DWRITE_RENDERING_MODE_ALIASED) {
paint.setFlags(SkPaint::Flags::kAntiAlias_Flag);
}
paint.setAntiAlias(fRenderingMode != DWRITE_RENDERING_MODE_ALIASED);
BOOL hasNextRun = FALSE;
while (SUCCEEDED(colorLayers->MoveNext(&hasNextRun)) && hasNextRun) {