@@ -141,33 +141,6 @@ SkGlyphRunListPainter::SkGlyphRunListPainter(
141141SkGlyphRunListPainter::SkGlyphRunListPainter (const GrRenderTargetContext& rtc)
142142 : SkGlyphRunListPainter{rtc.surfaceProps (), rtc.colorSpaceInfo ()} {}
143143
144- // forEachMappedDrawableGlyph handles positioning for mask type glyph handling for both sub-pixel
145- // and full pixel positioning.
146- template <typename EachGlyph>
147- void SkGlyphRunListPainter::forEachMappedDrawableGlyph (
148- const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& deviceMatrix,
149- SkGlyphCacheInterface* cache, EachGlyph eachGlyph) {
150- SkMatrix mapping = deviceMatrix;
151- mapping.preTranslate (origin.x (), origin.y ());
152- SkVector rounding = cache->rounding ();
153- mapping.postTranslate (rounding.x (), rounding.y ());
154-
155- auto runSize = glyphRun.runSize ();
156- if (this ->ensureBitmapBuffers (runSize)) {
157- mapping.mapPoints (fPositions , glyphRun.positions ().data (), runSize);
158- const SkPoint* mappedPtCursor = fPositions ;
159- const SkPoint* ptCursor = glyphRun.positions ().data ();
160- for (auto glyphID : glyphRun.shuntGlyphsIDs ()) {
161- auto mappedPt = *mappedPtCursor++;
162- auto pt = origin + *ptCursor++;
163- if (SkScalarsAreFinite (mappedPt.x (), mappedPt.y ())) {
164- const SkGlyph& glyph = cache->getGlyphMetrics (glyphID, mappedPt);
165- eachGlyph (glyph, pt, mappedPt);
166- }
167- }
168- }
169- }
170-
171144#endif
172145
173146bool SkGlyphRunListPainter::ShouldDrawAsPath (const SkPaint& paint, const SkMatrix& matrix) {
@@ -779,59 +752,6 @@ size_t SkGlyphRunBuilder::simplifyDrawPosText(
779752
780753#if SK_SUPPORT_GPU
781754
782- static bool glyph_too_big_for_atlas (const SkGlyph& glyph) {
783- return glyph.fWidth >= 256 || glyph.fHeight >= 256 ;
784- }
785-
786- static SkRect rect_to_draw (
787- const SkGlyph& glyph, SkPoint origin, SkScalar textScale, GrGlyph::MaskStyle maskStyle) {
788-
789- SkScalar dx = SkIntToScalar (glyph.fLeft );
790- SkScalar dy = SkIntToScalar (glyph.fTop );
791- SkScalar width = SkIntToScalar (glyph.fWidth );
792- SkScalar height = SkIntToScalar (glyph.fHeight );
793-
794- if (maskStyle == GrGlyph::kDistance_MaskStyle ) {
795- dx += SK_DistanceFieldInset;
796- dy += SK_DistanceFieldInset;
797- width -= 2 * SK_DistanceFieldInset;
798- height -= 2 * SK_DistanceFieldInset;
799- }
800-
801- dx *= textScale;
802- dy *= textScale;
803- width *= textScale;
804- height *= textScale;
805-
806- return SkRect::MakeXYWH (origin.x () + dx, origin.y () + dy, width, height);
807- }
808-
809- template <typename PerGlyphT, typename PerPathT>
810- void SkGlyphRunListPainter::drawGlyphRunAsBMPWithPathFallback (
811- SkGlyphCacheInterface* cache, const SkGlyphRun& glyphRun,
812- SkPoint origin, const SkMatrix& deviceMatrix,
813- PerGlyphT perGlyph, PerPathT perPath) {
814- auto eachGlyph =
815- [perGlyph{std::move (perGlyph)}, perPath{std::move (perPath)}]
816- (const SkGlyph& glyph, SkPoint pt, SkPoint mappedPt) {
817- if (glyph_too_big_for_atlas (glyph)) {
818- SkScalar sx = SkScalarFloorToScalar (mappedPt.fX ),
819- sy = SkScalarFloorToScalar (mappedPt.fY );
820-
821- SkRect glyphRect =
822- rect_to_draw (glyph, {sx, sy}, SK_Scalar1, GrGlyph::kCoverage_MaskStyle );
823-
824- if (!glyphRect.isEmpty ()) {
825- perPath (glyph, mappedPt);
826- }
827- } else {
828- perGlyph (glyph, mappedPt);
829- }
830- };
831-
832- this ->forEachMappedDrawableGlyph (glyphRun, origin, deviceMatrix, cache, eachGlyph);
833- }
834-
835755template <typename PerSDFT, typename PerPathT, typename PerFallbackT>
836756void SkGlyphRunListPainter::drawGlyphRunAsSDFWithFallback (
837757 SkGlyphCache* cache, const SkGlyphRun& glyphRun,
@@ -847,8 +767,7 @@ void SkGlyphRunListPainter::drawGlyphRunAsSDFWithFallback(
847767
848768 if (glyph_too_big_for_atlas (glyph)) {
849769 SkRect glyphRect =
850- rect_to_draw (glyph, glyphPos, textRatio,
851- GrGlyph::kDistance_MaskStyle );
770+ rect_to_draw (glyph, glyphPos, textRatio, true );
852771 if (!glyphRect.isEmpty ()) {
853772 const SkPath* glyphPath = cache->findPath (glyph);
854773 if (glyphPath != nullptr ) {
@@ -866,28 +785,6 @@ void SkGlyphRunListPainter::drawGlyphRunAsSDFWithFallback(
866785 }
867786}
868787
869- // -- TrackLayerDevice -----------------------------------------------------------------------------
870- void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForMask (
871- const SkGlyphRun& glyphRun, const SkMatrix& runMatrix, SkPoint origin) {
872- TRACE_EVENT0 (" skia" , " SkTextBlobCacheDiffCanvas::processGlyphRunForMask" );
873- const SkPaint& runPaint = glyphRun.paint ();
874-
875- SkScalerContextEffects effects;
876- auto * glyphCacheState = fStrikeServer ->getOrCreateCache (
877- runPaint, &this ->surfaceProps (), &runMatrix,
878- SkScalerContextFlags::kFakeGammaAndBoostContrast , &effects);
879- SkASSERT (glyphCacheState);
880-
881- auto perGlyph = [glyphCacheState] (const SkGlyph& glyph, SkPoint mappedPt) {
882- glyphCacheState->addGlyph (glyph.getPackedID (), false );
883- };
884-
885- auto perPath = [](const SkGlyph& glyph, SkPoint position) {};
886-
887- fPainter .drawGlyphRunAsBMPWithPathFallback (
888- glyphCacheState, glyphRun, origin, runMatrix, perGlyph, perPath);
889- }
890-
891788// -- GrTextContext --------------------------------------------------------------------------------
892789GrColor generate_filtered_color (const SkPaint& paint, const GrColorSpaceInfo& colorSpaceInfo) {
893790 GrColor4f filteredColor = SkColorToUnpremulGrColor4f (paint.getColor (), colorSpaceInfo);
@@ -1014,7 +911,9 @@ void GrTextContext::AppendGlyph(GrTextBlob* blob, int runIndex,
1014911 SkASSERT (skGlyph.fWidth == glyph->width ());
1015912 SkASSERT (skGlyph.fHeight == glyph->height ());
1016913
1017- SkRect glyphRect = rect_to_draw (skGlyph, {sx, sy}, textRatio, maskStyle);
914+ bool isDFT = maskStyle == GrGlyph::kDistance_MaskStyle ;
915+
916+ SkRect glyphRect = rect_to_draw (skGlyph, {sx, sy}, textRatio, isDFT);
1018917
1019918 if (!glyphRect.isEmpty ()) {
1020919 blob->appendGlyph (runIndex, glyphRect, color, *strike, glyph, !needsTransform);
0 commit comments