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

Unified Diff: src/gpu/GrBatchFontCache.h

Issue 1275393003: Fix for 510931, merge to m44 (Closed) Base URL: https://skia.googlesource.com/skia.git@m44
Patch Set: Created 5 years, 4 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/GrBatchAtlas.cpp ('k') | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBatchFontCache.h
diff --git a/src/gpu/GrBatchFontCache.h b/src/gpu/GrBatchFontCache.h
index f1c56ac00cc7f72ee8a5ae48e2d728da2b797eb4..f6617d0f74808a5f9672133052804b3ad8da01ef 100644
--- a/src/gpu/GrBatchFontCache.h
+++ b/src/gpu/GrBatchFontCache.h
@@ -12,6 +12,7 @@
#include "GrDrawTarget.h"
#include "GrFontScaler.h"
#include "GrGlyph.h"
+#include "SkGlyph.h"
#include "SkTDynamicHash.h"
#include "SkVarAlloc.h"
@@ -32,16 +33,36 @@ public:
const GrFontDescKey* getFontScalerKey() const { return fFontScalerKey; }
GrBatchFontCache* getBatchFontCache() const { return fBatchFontCache; }
- inline GrGlyph* getGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler) {
+ inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed,
+ GrFontScaler* scaler) {
GrGlyph* glyph = fCache.find(packed);
if (NULL == glyph) {
- glyph = this->generateGlyph(packed, scaler);
+ glyph = this->generateGlyph(skGlyph, packed, scaler);
}
return glyph;
}
- // returns true if glyph successfully added to texture atlas, false otherwise
- bool addGlyphToAtlas(GrBatchTarget*, GrGlyph*, GrFontScaler*);
+ // This variant of the above function is called by TextBatch. At this point, it is possible
+ // that the maskformat of the glyph differs from what we expect. In these cases we will just
+ // draw a clear square.
+ // skbug:4143 crbug:510931
+ inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed,
+ GrMaskFormat expectedMaskFormat, GrFontScaler* scaler) {
+ GrGlyph* glyph = fCache.find(packed);
+ if (NULL == glyph) {
+ glyph = this->generateGlyph(skGlyph, packed, scaler);
+ glyph->fMaskFormat = expectedMaskFormat;
+ }
+ return glyph;
+ }
+
+ // returns true if glyph successfully added to texture atlas, false otherwise. If the glyph's
+ // mask format has changed, then addGlyphToAtlas will draw a clear box. This will almost never
+ // happen.
+ // TODO we can handle some of these cases if we really want to, but the long term solution is to
+ // get the actual glyph image itself when we get the glyph metrics.
+ bool addGlyphToAtlas(GrBatchTarget*, GrGlyph*, GrFontScaler*, const SkGlyph&,
+ GrMaskFormat expectedMaskFormat);
// testing
int countGlyphs() const { return fCache.count(); }
@@ -68,7 +89,7 @@ private:
int fAtlasedGlyphs;
bool fIsAbandoned;
- GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler);
+ GrGlyph* generateGlyph(const SkGlyph&, GrGlyph::PackedID, GrFontScaler*);
friend class GrBatchFontCache;
};
« no previous file with comments | « src/gpu/GrBatchAtlas.cpp ('k') | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698