Chromium Code Reviews| 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 #if 0 | |
| 20 #define GR_NUM_PLOTS_X 4 | |
| 21 #define GR_NUM_PLOTS_Y 8 | |
| 22 #define GR_ATLAS_WIDTH 256 | |
| 23 #define GR_ATLAS_HEIGHT 256 | |
| 24 | |
| 25 #define GR_ATLAS_TEXTURE_WIDTH (GR_PLOT_WIDTH * GR_ATLAS_WIDTH) | |
|
jvanverth1
2014/04/01 15:32:43
This won't compile. I'm not sure we need this sect
robertphillips
2014/04/01 15:45:54
Done.
| |
| 26 #define GR_ATLAS_TEXTURE_HEIGHT (GR_PLOT_HEIGHT * GR_ATLAS_HEIGHT) | |
| 27 | |
| 28 #else | |
| 29 | |
| 30 #define GR_ATLAS_TEXTURE_WIDTH 1024 | |
| 31 #define GR_ATLAS_TEXTURE_HEIGHT 2048 | |
| 32 | |
| 33 #define GR_ATLAS_WIDTH 256 | |
|
jvanverth1
2014/04/01 15:32:43
Since you're changing stuff, this should be GR_PLO
robertphillips
2014/04/01 15:45:54
Done.
| |
| 34 #define GR_ATLAS_HEIGHT 256 | |
| 35 | |
| 36 #define GR_NUM_PLOTS_X (GR_ATLAS_TEXTURE_WIDTH / GR_ATLAS_WIDTH) | |
| 37 #define GR_NUM_PLOTS_Y (GR_ATLAS_TEXTURE_HEIGHT / GR_ATLAS_HEIGHT) | |
| 38 | |
| 39 #endif | |
| 40 | |
| 19 #define FONT_CACHE_STATS 0 | 41 #define FONT_CACHE_STATS 0 |
| 20 #if FONT_CACHE_STATS | 42 #if FONT_CACHE_STATS |
| 21 static int g_PurgeCount = 0; | 43 static int g_PurgeCount = 0; |
| 22 #endif | 44 #endif |
| 23 | 45 |
| 24 GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) { | 46 GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) { |
| 25 gpu->ref(); | 47 gpu->ref(); |
| 26 for (int i = 0; i < kAtlasCount; ++i) { | 48 for (int i = 0; i < kAtlasCount; ++i) { |
| 27 fAtlasMgr[i] = NULL; | 49 fAtlasMgr[i] = NULL; |
| 28 } | 50 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 SkASSERT(sAtlasIndices[format] < GrFontCache::kAtlasCount); | 87 SkASSERT(sAtlasIndices[format] < GrFontCache::kAtlasCount); |
| 66 return sAtlasIndices[format]; | 88 return sAtlasIndices[format]; |
| 67 } | 89 } |
| 68 | 90 |
| 69 GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler, | 91 GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler, |
| 70 const Key& key) { | 92 const Key& key) { |
| 71 GrMaskFormat format = scaler->getMaskFormat(); | 93 GrMaskFormat format = scaler->getMaskFormat(); |
| 72 GrPixelConfig config = mask_format_to_pixel_config(format); | 94 GrPixelConfig config = mask_format_to_pixel_config(format); |
| 73 int atlasIndex = mask_format_to_atlas_index(format); | 95 int atlasIndex = mask_format_to_atlas_index(format); |
| 74 if (NULL == fAtlasMgr[atlasIndex]) { | 96 if (NULL == fAtlasMgr[atlasIndex]) { |
| 75 fAtlasMgr[atlasIndex] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config)); | 97 fAtlasMgr[atlasIndex] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config, |
| 98 GR_ATLAS_TEXTURE_WIDTH, | |
| 99 GR_ATLAS_TEXTURE_HEIGHT, | |
| 100 GR_NUM_PLOTS_X, | |
| 101 GR_NUM_PLOTS_Y)); | |
| 76 } | 102 } |
| 77 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, | 103 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, |
| 78 (this, scaler->getKey(), format, fAtlasMgr [atlasIndex])); | 104 (this, scaler->getKey(), format, fAtlasMgr [atlasIndex])); |
| 79 fCache.insert(key, strike); | 105 fCache.insert(key, strike); |
| 80 | 106 |
| 81 if (fHead) { | 107 if (fHead) { |
| 82 fHead->fPrev = strike; | 108 fHead->fPrev = strike; |
| 83 } else { | 109 } else { |
| 84 SkASSERT(NULL == fTail); | 110 SkASSERT(NULL == fTail); |
| 85 fTail = strike; | 111 fTail = strike; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 &glyph->fAtlasLocation); | 381 &glyph->fAtlasLocation); |
| 356 } | 382 } |
| 357 | 383 |
| 358 if (NULL == plot) { | 384 if (NULL == plot) { |
| 359 return false; | 385 return false; |
| 360 } | 386 } |
| 361 | 387 |
| 362 glyph->fPlot = plot; | 388 glyph->fPlot = plot; |
| 363 return true; | 389 return true; |
| 364 } | 390 } |
| OLD | NEW |