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

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

Issue 1643143002: Generate Signed Distance Field directly from vector path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Temporary use legacy distance field Created 3 years, 11 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
« no previous file with comments | « src/gpu/ops/GrAADistanceFieldPathRenderer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/text/GrAtlasGlyphCache.cpp
diff --git a/src/gpu/text/GrAtlasGlyphCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp
index 803dbb48e1afe40dc26f27c0b49ad0a4a23b2344..5d85f4919d52eda736b476f84d0bf355ecdcaf9b 100644
--- a/src/gpu/text/GrAtlasGlyphCache.cpp
+++ b/src/gpu/text/GrAtlasGlyphCache.cpp
@@ -14,6 +14,7 @@
#include "SkString.h"
#include "SkDistanceFieldGen.h"
+#include "GrDistanceFieldGenFromVector.h"
bool GrAtlasGlyphCache::initAtlas(GrMaskFormat format) {
int index = MaskFormatToAtlasIndex(format);
@@ -320,29 +321,57 @@ static bool get_packed_glyph_df_image(SkGlyphCache* cache, 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 = cache->findImage(glyph);
- if (nullptr == image) {
+
+#ifndef SK_USE_LEGACY_DISTANCE_FIELDS
+ const SkPath* path = cache->findPath(glyph);
+ if (nullptr == path) {
return false;
}
+
+ SkDEBUGCODE(SkRect glyphBounds = SkRect::MakeXYWH(glyph.fLeft,
+ glyph.fTop,
+ glyph.fWidth,
+ glyph.fHeight));
+ SkASSERT(glyphBounds.contains(path->getBounds()));
+
// 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;
- }
+ SkMatrix drawMatrix;
+ drawMatrix.setTranslate((SkScalar)-glyph.fLeft, (SkScalar)-glyph.fTop);
+ // Generate signed distance field directly from SkPath
+ bool succeed = GrGenerateDistanceFieldFromPath((unsigned char*)dst,
+ *path, drawMatrix,
+ width, height, width * sizeof(unsigned char));
+
+ if (!succeed) {
+#endif
+ const void* image = cache->findImage(glyph);
+ if (nullptr == image) {
+ return false;
+ }
+
+ // 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;
+ }
+#ifndef SK_USE_LEGACY_DISTANCE_FIELDS
+ }
+#endif
return true;
}
« no previous file with comments | « src/gpu/ops/GrAADistanceFieldPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698