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

Unified Diff: src/gpu/SkGrFontScaler.cpp

Issue 227593010: Move distance field generation to the glyph cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Re-disable distance fields Created 6 years, 8 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/SkGrFontScaler.cpp
diff --git a/src/gpu/SkGrFontScaler.cpp b/src/gpu/SkGrFontScaler.cpp
index 8fdae48a2adde48c7f5f1ffd42e7f8299ddf461f..f49fd67035c6bff3e2c0574a4fb856d6b4e85b41 100644
--- a/src/gpu/SkGrFontScaler.cpp
+++ b/src/gpu/SkGrFontScaler.cpp
@@ -10,6 +10,7 @@
#include "GrTemplates.h"
#include "SkGr.h"
#include "SkDescriptor.h"
+#include "SkDistanceFieldGen.h"
#include "SkGlyphCache.h"
class SkGrDescKey : public GrKey {
@@ -108,8 +109,19 @@ bool SkGrFontScaler::getPackedGlyphBounds(GrGlyph::PackedID packed,
GrGlyph::UnpackFixedX(packed),
GrGlyph::UnpackFixedY(packed));
bounds->setXYWH(glyph.fLeft, glyph.fTop, glyph.fWidth, glyph.fHeight);
+
return true;
+}
+
+bool SkGrFontScaler::getPackedGlyphDFBounds(GrGlyph::PackedID packed,
robertphillips 2014/04/11 14:13:00 Align or fit on one line?
jvanverth1 2014/04/11 17:54:14 Done.
+ SkIRect* bounds) {
+ const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
robertphillips 2014/04/11 14:13:00 align?
jvanverth1 2014/04/11 17:54:14 Done.
+ GrGlyph::UnpackFixedX(packed),
+ GrGlyph::UnpackFixedY(packed));
+ bounds->setXYWH(glyph.fLeft, glyph.fTop, glyph.fWidth, glyph.fHeight);
+ bounds->outset(SK_DistanceFieldPad, SK_DistanceFieldPad);
+ return true;
}
namespace {
@@ -190,6 +202,24 @@ bool SkGrFontScaler::getPackedGlyphImage(GrGlyph::PackedID packed,
return true;
}
+bool SkGrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed,
+ int width, int height,
+ int dstRB, void* dst) {
+ const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
robertphillips 2014/04/11 14:13:00 align?
jvanverth1 2014/04/11 17:54:14 Done.
+ GrGlyph::UnpackFixedX(packed),
+ GrGlyph::UnpackFixedY(packed));
+ SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width);
+ SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height);
+ const void* src = fStrike->findDistanceField(glyph);
+ if (NULL == src) {
+ return false;
+ }
+
robertphillips 2014/04/11 14:13:00 At a higher-level why are we copying out here?
jvanverth1 2014/04/11 17:54:14 The short answer is: to match getPackedGlyphImage.
+ memcpy(dst, src, width * height);
+
+ return true;
+}
+
// we should just return const SkPath* (NULL means false)
bool SkGrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) {

Powered by Google App Engine
This is Rietveld 408576698