aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGlyph.h
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2015-03-18 14:46:38 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-18 14:46:38 -0700
commit8dc58edd71c11f232860724dfa3b566895478034 (patch)
tree8dd333c577d99ab103eda7bb2e2c1ad48bfbb325 /src/gpu/GrGlyph.h
parent905d01b95a6b3f7dd18701e211006bd80215d536 (diff)
Ensure that we use different glyph entries for regular and df text.
Currently if we switch between regular text and df text while using the same GrContext, they may use the same entry in the Ganesh font cache, which is incorrect. This change ensures that they will have different entries. Review URL: https://codereview.chromium.org/1020593003
Diffstat (limited to 'src/gpu/GrGlyph.h')
-rw-r--r--src/gpu/GrGlyph.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gpu/GrGlyph.h b/src/gpu/GrGlyph.h
index 0e534d694a..108f2f0fe7 100644
--- a/src/gpu/GrGlyph.h
+++ b/src/gpu/GrGlyph.h
@@ -23,6 +23,11 @@ class GrPlot;
- failed to get metrics
*/
struct GrGlyph {
+ enum MaskStyle {
+ kCoverage_MaskStyle,
+ kDistance_MaskStyle
+ };
+
typedef uint32_t PackedID;
GrPlot* fPlot;
@@ -60,10 +65,11 @@ struct GrGlyph {
return (pos >> 14) & 3;
}
- static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y) {
+ static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y, MaskStyle ms) {
x = ExtractSubPixelBitsFromFixed(x);
y = ExtractSubPixelBitsFromFixed(y);
- return (x << 18) | (y << 16) | glyphID;
+ int dfFlag = (ms == kDistance_MaskStyle) ? 0x1 : 0x0;
+ return (dfFlag << 20) | (x << 18) | (y << 16) | glyphID;
}
static inline SkFixed UnpackFixedX(PackedID packed) {
@@ -74,6 +80,10 @@ struct GrGlyph {
return ((packed >> 16) & 3) << 14;
}
+ static inline MaskStyle UnpackMaskStyle(PackedID packed) {
+ return ((packed >> 20) & 1) ? kDistance_MaskStyle : kCoverage_MaskStyle;
+ }
+
static inline uint16_t UnpackID(PackedID packed) {
return (uint16_t)packed;
}