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>
diff --git a/include/core/SkFont.h b/include/core/SkFont.h
index 413d042..fb3c037 100644
--- a/include/core/SkFont.h
+++ b/include/core/SkFont.h
@@ -491,6 +491,7 @@
uint8_t fHinting;
SkScalar setupForAsPaths(SkPaint*);
+ bool hasSomeAntiAliasing() const;
void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const;
diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp
index 6db43ea..b17de02 100644
--- a/src/core/SkFont.cpp
+++ b/src/core/SkFont.cpp
@@ -120,6 +120,12 @@
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) {
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index 35320eb..486aa09 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -203,9 +203,7 @@
// 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()},