OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #define GR_PLOT_WIDTH (GR_ATLAS_TEXTURE_WIDTH / GR_ATLAS_WIDTH) | 34 #define GR_PLOT_WIDTH (GR_ATLAS_TEXTURE_WIDTH / GR_ATLAS_WIDTH) |
35 #define GR_PLOT_HEIGHT (GR_ATLAS_TEXTURE_HEIGHT / GR_ATLAS_HEIGHT) | 35 #define GR_PLOT_HEIGHT (GR_ATLAS_TEXTURE_HEIGHT / GR_ATLAS_HEIGHT) |
36 | 36 |
37 #endif | 37 #endif |
38 | 38 |
39 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
40 | 40 |
41 #define BORDER 1 | 41 #define BORDER 1 |
42 | 42 |
43 #if GR_DEBUG | 43 #if SK_DEBUG |
44 static int gCounter; | 44 static int gCounter; |
45 #endif | 45 #endif |
46 | 46 |
47 // for testing | 47 // for testing |
48 #define FONT_CACHE_STATS 0 | 48 #define FONT_CACHE_STATS 0 |
49 #if FONT_CACHE_STATS | 49 #if FONT_CACHE_STATS |
50 static int g_UploadCount = 0; | 50 static int g_UploadCount = 0; |
51 #endif | 51 #endif |
52 | 52 |
53 GrAtlas::GrAtlas(GrAtlasMgr* mgr, int plotX, int plotY, GrMaskFormat format) : | 53 GrAtlas::GrAtlas(GrAtlasMgr* mgr, int plotX, int plotY, GrMaskFormat format) : |
54 fDrawToken(NULL, 0) { | 54 fDrawToken(NULL, 0) { |
55 fAtlasMgr = mgr; // just a pointer, not an owner | 55 fAtlasMgr = mgr; // just a pointer, not an owner |
56 fNext = NULL; | 56 fNext = NULL; |
57 | 57 |
58 fTexture = mgr->getTexture(format); // we're not an owner, just a pointer | 58 fTexture = mgr->getTexture(format); // we're not an owner, just a pointer |
59 fPlot.set(plotX, plotY); | 59 fPlot.set(plotX, plotY); |
60 | 60 |
61 fRects = GrRectanizer::Factory(GR_ATLAS_WIDTH - BORDER, | 61 fRects = GrRectanizer::Factory(GR_ATLAS_WIDTH - BORDER, |
62 GR_ATLAS_HEIGHT - BORDER); | 62 GR_ATLAS_HEIGHT - BORDER); |
63 | 63 |
64 fMaskFormat = format; | 64 fMaskFormat = format; |
65 | 65 |
66 #if GR_DEBUG | 66 #if SK_DEBUG |
67 // GrPrintf(" GrAtlas %p [%d %d] %d\n", this, plotX, plotY, gCounter); | 67 // GrPrintf(" GrAtlas %p [%d %d] %d\n", this, plotX, plotY, gCounter); |
68 gCounter += 1; | 68 gCounter += 1; |
69 #endif | 69 #endif |
70 } | 70 } |
71 | 71 |
72 GrAtlas::~GrAtlas() { | 72 GrAtlas::~GrAtlas() { |
73 fAtlasMgr->freePlot(fMaskFormat, fPlot.fX, fPlot.fY); | 73 fAtlasMgr->freePlot(fMaskFormat, fPlot.fX, fPlot.fY); |
74 | 74 |
75 delete fRects; | 75 delete fRects; |
76 | 76 |
77 #if GR_DEBUG | 77 #if SK_DEBUG |
78 --gCounter; | 78 --gCounter; |
79 // GrPrintf("~GrAtlas %p [%d %d] %d\n", this, fPlot.fX, fPlot.fY, gCounter); | 79 // GrPrintf("~GrAtlas %p [%d %d] %d\n", this, fPlot.fX, fPlot.fY, gCounter); |
80 #endif | 80 #endif |
81 } | 81 } |
82 | 82 |
83 bool GrAtlas::RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas) { | 83 bool GrAtlas::RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas) { |
84 // GrAtlas** is used so that a pointer to the head element can be passed in
and | 84 // GrAtlas** is used so that a pointer to the head element can be passed in
and |
85 // modified when the first element is deleted | 85 // modified when the first element is deleted |
86 GrAtlas** atlasRef = startAtlas; | 86 GrAtlas** atlasRef = startAtlas; |
87 GrAtlas* atlas = *startAtlas; | 87 GrAtlas* atlas = *startAtlas; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 newAtlas->fNext = *atlas; | 243 newAtlas->fNext = *atlas; |
244 *atlas = newAtlas; | 244 *atlas = newAtlas; |
245 | 245 |
246 return newAtlas; | 246 return newAtlas; |
247 } | 247 } |
248 | 248 |
249 void GrAtlasMgr::freePlot(GrMaskFormat format, int x, int y) { | 249 void GrAtlasMgr::freePlot(GrMaskFormat format, int x, int y) { |
250 SkASSERT(fPlotMgr->isBusy(x, y)); | 250 SkASSERT(fPlotMgr->isBusy(x, y)); |
251 fPlotMgr->freePlot(x, y); | 251 fPlotMgr->freePlot(x, y); |
252 } | 252 } |
OLD | NEW |