Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: src/gpu/text/GrFontScaler.cpp

Issue 1643143002: Generate Signed Distance Field directly from vector path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove get direction and add text SDF support Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/text/GrFontScaler.cpp
diff --git a/src/gpu/text/GrFontScaler.cpp b/src/gpu/text/GrFontScaler.cpp
index c8412027c04df8cca2ac69c2847ffac1e00f5baf..bf6e2d1c44bb2425291f18ce53d94065b53d4ed2 100644
--- a/src/gpu/text/GrFontScaler.cpp
+++ b/src/gpu/text/GrFontScaler.cpp
@@ -9,6 +9,7 @@
#include "GrFontScaler.h"
#include "SkDescriptor.h"
#include "SkDistanceFieldGen.h"
+#include "GrDistanceFieldGenFromVector.h"
#include "SkGlyphCache.h"
///////////////////////////////////////////////////////////////////////////////
@@ -170,28 +171,20 @@ bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig
bool GrFontScaler::getPackedGlyphDFImage(const SkGlyph& glyph, int width, int height, void* dst) {
SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width);
SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height);
- const void* image = fStrike->findImage(glyph);
- if (nullptr == image) {
+ const SkPath* path = fStrike->findPath(glyph);
+ if (nullptr == path) {
return false;
}
+
+ SkMatrix drawMatrix;
+ drawMatrix.setTranslate(-glyph.fLeft, -glyph.fTop);
+
// now generate the distance field
SkASSERT(dst);
- SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
- if (SkMask::kA8_Format == maskFormat) {
- // make the distance field from the image
- SkGenerateDistanceFieldFromA8Image((unsigned char*)dst,
- (unsigned char*)image,
- glyph.fWidth, glyph.fHeight,
- glyph.rowBytes());
- } else if (SkMask::kBW_Format == maskFormat) {
- // make the distance field from the image
- SkGenerateDistanceFieldFromBWImage((unsigned char*)dst,
- (unsigned char*)image,
- glyph.fWidth, glyph.fHeight,
- glyph.rowBytes());
- } else {
- return false;
- }
+ // Generate signed distance field directly from SkPath
+ GrGenerateDistanceFieldFromPath((unsigned char*)dst,
+ *path, drawMatrix,
+ width, height, width * sizeof(unsigned char));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698