support lcd16 in text atlas (sans shader support)
git-svn-id: http://skia.googlecode.com/svn/trunk@939 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrTextStrike.cpp b/gpu/src/GrTextStrike.cpp
index c2d81d5..6cdb61c 100644
--- a/gpu/src/GrTextStrike.cpp
+++ b/gpu/src/GrTextStrike.cpp
@@ -41,7 +41,8 @@
if (NULL == fAtlasMgr) {
fAtlasMgr = new GrAtlasMgr(fGpu);
}
- GrTextStrike* strike = new GrTextStrike(this, scaler->getKey(), fAtlasMgr);
+ GrTextStrike* strike = new GrTextStrike(this, scaler->getKey(),
+ scaler->getMaskFormat(), fAtlasMgr);
fCache.insert(key, strike);
if (fHead) {
@@ -131,6 +132,7 @@
*/
GrTextStrike::GrTextStrike(GrFontCache* cache, const GrKey* key,
+ GrMaskFormat format,
GrAtlasMgr* atlasMgr) : fPool(64) {
fFontScalerKey = key;
fFontScalerKey->ref();
@@ -139,6 +141,8 @@
fAtlasMgr = atlasMgr; // no need to ref, it won't go away before we do
fAtlas = NULL;
+ fMaskFormat = format;
+
#if GR_DEBUG
GrPrintf(" GrTextStrike %p %d\n", this, gCounter);
gCounter += 1;
@@ -180,17 +184,20 @@
}
GrAutoRef ar(scaler);
-
- size_t size = glyph->fBounds.area();
+
+ int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
+ size_t size = glyph->fBounds.area() * bytesPerPixel;
GrAutoSMalloc<1024> storage(size);
if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
- glyph->height(), glyph->width(),
+ glyph->height(),
+ glyph->width() * bytesPerPixel,
storage.get())) {
return false;
}
GrAtlas* atlas = fAtlasMgr->addToAtlas(fAtlas, glyph->width(),
glyph->height(), storage.get(),
+ fMaskFormat,
&glyph->fAtlasLocation);
if (NULL == atlas) {
return false;