OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrAtlas.h" | 8 #include "GrAtlas.h" |
9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
10 #include "GrRectanizer.h" | 10 #include "GrRectanizer.h" |
11 #include "GrTextStrike.h" | 11 #include "GrTextStrike.h" |
12 #include "GrTextStrike_impl.h" | 12 #include "GrTextStrike_impl.h" |
13 #include "SkString.h" | 13 #include "SkString.h" |
14 | 14 |
15 #include "SkDistanceFieldGen.h" | 15 #include "SkDistanceFieldGen.h" |
16 | 16 |
17 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
18 | 18 |
| 19 #define GR_ATLAS_TEXTURE_WIDTH 1024 |
| 20 #define GR_ATLAS_TEXTURE_HEIGHT 2048 |
| 21 |
| 22 #define GR_PLOT_WIDTH 256 |
| 23 #define GR_PLOT_HEIGHT 256 |
| 24 |
| 25 #define GR_NUM_PLOTS_X (GR_ATLAS_TEXTURE_WIDTH / GR_PLOT_WIDTH) |
| 26 #define GR_NUM_PLOTS_Y (GR_ATLAS_TEXTURE_HEIGHT / GR_PLOT_HEIGHT) |
| 27 |
19 #define FONT_CACHE_STATS 0 | 28 #define FONT_CACHE_STATS 0 |
20 #if FONT_CACHE_STATS | 29 #if FONT_CACHE_STATS |
21 static int g_PurgeCount = 0; | 30 static int g_PurgeCount = 0; |
22 #endif | 31 #endif |
23 | 32 |
24 GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) { | 33 GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) { |
25 gpu->ref(); | 34 gpu->ref(); |
26 for (int i = 0; i < kAtlasCount; ++i) { | 35 for (int i = 0; i < kAtlasCount; ++i) { |
27 fAtlasMgr[i] = NULL; | 36 fAtlasMgr[i] = NULL; |
28 } | 37 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 SkASSERT(sAtlasIndices[format] < GrFontCache::kAtlasCount); | 74 SkASSERT(sAtlasIndices[format] < GrFontCache::kAtlasCount); |
66 return sAtlasIndices[format]; | 75 return sAtlasIndices[format]; |
67 } | 76 } |
68 | 77 |
69 GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler, | 78 GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler, |
70 const Key& key) { | 79 const Key& key) { |
71 GrMaskFormat format = scaler->getMaskFormat(); | 80 GrMaskFormat format = scaler->getMaskFormat(); |
72 GrPixelConfig config = mask_format_to_pixel_config(format); | 81 GrPixelConfig config = mask_format_to_pixel_config(format); |
73 int atlasIndex = mask_format_to_atlas_index(format); | 82 int atlasIndex = mask_format_to_atlas_index(format); |
74 if (NULL == fAtlasMgr[atlasIndex]) { | 83 if (NULL == fAtlasMgr[atlasIndex]) { |
75 fAtlasMgr[atlasIndex] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config)); | 84 SkISize textureSize = SkISize::Make(GR_ATLAS_TEXTURE_WIDTH, |
| 85 GR_ATLAS_TEXTURE_HEIGHT); |
| 86 fAtlasMgr[atlasIndex] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config, |
| 87 textureSize, |
| 88 GR_NUM_PLOTS_X, |
| 89 GR_NUM_PLOTS_Y)); |
76 } | 90 } |
77 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, | 91 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, |
78 (this, scaler->getKey(), format, fAtlasMgr
[atlasIndex])); | 92 (this, scaler->getKey(), format, fAtlasMgr
[atlasIndex])); |
79 fCache.insert(key, strike); | 93 fCache.insert(key, strike); |
80 | 94 |
81 if (fHead) { | 95 if (fHead) { |
82 fHead->fPrev = strike; | 96 fHead->fPrev = strike; |
83 } else { | 97 } else { |
84 SkASSERT(NULL == fTail); | 98 SkASSERT(NULL == fTail); |
85 fTail = strike; | 99 fTail = strike; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 &glyph->fAtlasLocation); | 369 &glyph->fAtlasLocation); |
356 } | 370 } |
357 | 371 |
358 if (NULL == plot) { | 372 if (NULL == plot) { |
359 return false; | 373 return false; |
360 } | 374 } |
361 | 375 |
362 glyph->fPlot = plot; | 376 glyph->fPlot = plot; |
363 return true; | 377 return true; |
364 } | 378 } |
OLD | NEW |