Funtion to say if an SkFont has anti aliasing.

This will be used in a couple of places in the glyph painter,
best they all agree.

Change-Id: I67079b000bdede437de8fdc0a09538593775ab41
Reviewed-on: https://skia-review.googlesource.com/c/177000
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
This commit is contained in:
Herb Derby 2018-12-12 11:45:42 -05:00 committed by Skia Commit-Bot
parent bff4e07398
commit e9da1d6b19
3 changed files with 8 additions and 3 deletions

View File

@ -491,6 +491,7 @@ private:
uint8_t fHinting;
SkScalar setupForAsPaths(SkPaint*);
bool hasSomeAntiAliasing() const;
void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const;

View File

@ -120,6 +120,12 @@ SkScalar SkFont::setupForAsPaths(SkPaint* paint) {
return textSize / SkPaint::kCanonicalTextSizeForPaths;
}
bool SkFont::hasSomeAntiAliasing() const {
Edging edging = this->getEdging();
return edging == SkFont::Edging::kAntiAlias
|| edging == SkFont::Edging::kSubpixelAntiAlias;
}
class SkCanonicalizeFont {
public:
SkCanonicalizeFont(const SkFont& font) : fFont(&font), fScale(0) {

View File

@ -203,9 +203,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
// The paint we draw paths with must have the same anti-aliasing state as the runFont
// allowing the paths to have the same edging as the glyph masks.
pathPaint = runPaint;
bool isAntiAlias = runFont.getEdging() == SkFont::Edging::kAntiAlias
|| runFont.getEdging() == SkFont::Edging::kSubpixelAntiAlias;
pathPaint.setAntiAlias(isAntiAlias);
pathPaint.setAntiAlias(runFont.hasSomeAntiAliasing());
bitmapDevice->paintPaths(
SkSpan<const PathAndPos>{pathsAndPositions.begin(), pathsAndPositions.size()},