Check for too small rect for path
This check was dropped in skia cl/145000. Add it back
in to bring it back into parity with the SkRemoteGlyphCache.
BUG=chromium:873020
Change-Id: I04c12e54145e0ebd1bdec2f01f5f40f26648f78a
Reviewed-on: https://skia-review.googlesource.com/148384
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Auto-Submit: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp
index ca5bac3..de44313 100644
--- a/src/core/SkGlyphRun.cpp
+++ b/src/core/SkGlyphRun.cpp
@@ -828,30 +828,6 @@
return glyph.fWidth >= 256 || glyph.fHeight >= 256;
}
-template <typename PerGlyphT, typename PerPathT>
-void SkGlyphRunListDrawer::drawGlyphRunAsBMPWithPathFallback(
- SkGlyphCache* cache, const SkGlyphRun& glyphRun,
- SkPoint origin, const SkMatrix& deviceMatrix,
- PerGlyphT perGlyph, PerPathT perPath) {
- auto eachGlyph =
- [cache, perGlyph{std::move(perGlyph)}, perPath{std::move(perPath)}]
- (const SkGlyph& glyph, SkPoint pt, SkPoint mappedPt) {
- if (glyph_too_big_for_atlas(glyph)) {
- const SkPath* glyphPath = cache->findPath(glyph);
- if (glyphPath != nullptr) {
- perPath(glyphPath, glyph, mappedPt);
- }
- } else {
- const void* glyphImage = cache->findImage(glyph);
- if (glyphImage != nullptr) {
- perGlyph(glyph, mappedPt);
- }
- }
- };
-
- this->forEachMappedDrawableGlyph(glyphRun, origin, deviceMatrix, cache, eachGlyph);
-}
-
static SkRect rect_to_draw(
const SkGlyph& glyph, SkPoint origin, SkScalar textScale, GrGlyph::MaskStyle maskStyle) {
@@ -875,6 +851,38 @@
return SkRect::MakeXYWH(origin.x() + dx, origin.y() + dy, width, height);
}
+template <typename PerGlyphT, typename PerPathT>
+void SkGlyphRunListDrawer::drawGlyphRunAsBMPWithPathFallback(
+ SkGlyphCache* cache, const SkGlyphRun& glyphRun,
+ SkPoint origin, const SkMatrix& deviceMatrix,
+ PerGlyphT perGlyph, PerPathT perPath) {
+ auto eachGlyph =
+ [cache, perGlyph{std::move(perGlyph)}, perPath{std::move(perPath)}]
+ (const SkGlyph& glyph, SkPoint pt, SkPoint mappedPt) {
+ if (glyph_too_big_for_atlas(glyph)) {
+ SkScalar sx = SkScalarFloorToScalar(mappedPt.fX),
+ sy = SkScalarFloorToScalar(mappedPt.fY);
+
+ SkRect glyphRect =
+ rect_to_draw(glyph, {sx, sy}, SK_Scalar1, GrGlyph::kCoverage_MaskStyle);
+
+ if (!glyphRect.isEmpty()) {
+ const SkPath* glyphPath = cache->findPath(glyph);
+ if (glyphPath != nullptr) {
+ perPath(glyphPath, glyph, mappedPt);
+ }
+ }
+ } else {
+ const void* glyphImage = cache->findImage(glyph);
+ if (glyphImage != nullptr) {
+ perGlyph(glyph, mappedPt);
+ }
+ }
+ };
+
+ this->forEachMappedDrawableGlyph(glyphRun, origin, deviceMatrix, cache, eachGlyph);
+}
+
template <typename PerSDFT, typename PerPathT, typename PerFallbackT>
void SkGlyphRunListDrawer::drawGlyphRunAsSDFWithFallback(
SkGlyphCache* cache, const SkGlyphRun& glyphRun,