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

Unified Diff: src/gpu/GrTextStrike.cpp

Issue 99993002: Add GPU support for color bitmap fonts (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add ignored test Created 7 years 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/GrTextStrike.cpp
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index ddab1e95a90798b6853b79d63bd303651f64ae00..e353c0fa396d06764684ec33497209d8cabcd90d 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -28,7 +28,7 @@ static int g_PurgeCount = 0;
GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) {
gpu->ref();
- for (int i = 0; i < kMaskFormatCount; ++i) {
+ for (int i = 0; i < kAtlasCount; ++i) {
fAtlasMgr[i] = NULL;
}
@@ -37,7 +37,7 @@ GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) {
GrFontCache::~GrFontCache() {
fCache.deleteAll();
- for (int i = 0; i < kMaskFormatCount; ++i) {
+ for (int i = 0; i < kAtlasCount; ++i) {
delete fAtlasMgr[i];
}
fGpu->unref();
@@ -47,28 +47,33 @@ GrFontCache::~GrFontCache() {
}
static GrPixelConfig mask_format_to_pixel_config(GrMaskFormat format) {
robertphillips 2013/12/02 21:05:40 const?
- switch (format) {
- case kA8_GrMaskFormat:
- return kAlpha_8_GrPixelConfig;
- case kA565_GrMaskFormat:
- return kRGB_565_GrPixelConfig;
- case kA888_GrMaskFormat:
- return kSkia8888_GrPixelConfig;
- default:
- SkDEBUGFAIL("unknown maskformat");
- }
- return kUnknown_GrPixelConfig;
+ static GrPixelConfig sPixelConfigs[kMaskFormatCount] = {
+ kAlpha_8_GrPixelConfig,
+ kRGB_565_GrPixelConfig,
+ kSkia8888_GrPixelConfig,
+ kSkia8888_GrPixelConfig
+ };
+
+ return sPixelConfigs[format];
+}
+
+static int mask_format_to_atlas_index(GrMaskFormat format) {
robertphillips 2013/12/02 21:05:40 const?
+ static int sAtlasIndices[kMaskFormatCount] = { 0, 1, 2, 2 };
robertphillips 2013/12/02 21:05:40 assert "sAtlasIndices[format] < kAtlasCount" or a
+
+ return sAtlasIndices[format];
}
GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
const Key& key) {
GrMaskFormat format = scaler->getMaskFormat();
GrPixelConfig config = mask_format_to_pixel_config(format);
- if (NULL == fAtlasMgr[format]) {
- fAtlasMgr[format] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config));
+ int atlasIndex = mask_format_to_atlas_index(format);
robertphillips 2013/12/02 21:05:40 Move assert up into mask_format_to_atlas?
+ SkASSERT(atlasIndex < kAtlasCount);
+ if (NULL == fAtlasMgr[atlasIndex]) {
+ fAtlasMgr[atlasIndex] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config));
}
GrTextStrike* strike = SkNEW_ARGS(GrTextStrike,
- (this, scaler->getKey(), format, fAtlasMgr[format]));
+ (this, scaler->getKey(), format, fAtlasMgr[atlasIndex]));
fCache.insert(key, strike);
if (fHead) {
@@ -86,7 +91,7 @@ GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
void GrFontCache::freeAll() {
fCache.deleteAll();
- for (int i = 0; i < kMaskFormatCount; ++i) {
+ for (int i = 0; i < kAtlasCount; ++i) {
delete fAtlasMgr[i];
fAtlasMgr[i] = NULL;
}
@@ -177,7 +182,7 @@ void GrFontCache::validate() const {
#ifdef SK_DEVELOPER
void GrFontCache::dump() const {
static int gDumpCount = 0;
- for (int i = 0; i < kMaskFormatCount; ++i) {
+ for (int i = 0; i < kAtlasCount; ++i) {
if (NULL != fAtlasMgr[i]) {
GrTexture* texture = fAtlasMgr[i]->getTexture();
if (NULL != texture) {
« src/gpu/GrTextStrike.h ('K') | « src/gpu/GrTextStrike.h ('k') | src/gpu/SkGrFontScaler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698