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

Side by Side Diff: src/gpu/GrAtlas.cpp

Issue 24047005: Have multiple plotmgrs, one for each mask format. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrAtlas.h ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 return true; 159 return true;
160 } 160 }
161 161
162 /////////////////////////////////////////////////////////////////////////////// 162 ///////////////////////////////////////////////////////////////////////////////
163 163
164 GrAtlasMgr::GrAtlasMgr(GrGpu* gpu) { 164 GrAtlasMgr::GrAtlasMgr(GrGpu* gpu) {
165 fGpu = gpu; 165 fGpu = gpu;
166 gpu->ref(); 166 gpu->ref();
167 Gr_bzero(fTexture, sizeof(fTexture)); 167 Gr_bzero(fTexture, sizeof(fTexture));
168 fPlotMgr = SkNEW_ARGS(GrPlotMgr, (GR_PLOT_WIDTH, GR_PLOT_HEIGHT)); 168 for (int i = 0; i < kCount_GrMaskFormats; ++i) {
169 fPlotMgr[i] = SkNEW_ARGS(GrPlotMgr, (GR_PLOT_WIDTH, GR_PLOT_HEIGHT));
170 }
169 } 171 }
170 172
171 GrAtlasMgr::~GrAtlasMgr() { 173 GrAtlasMgr::~GrAtlasMgr() {
172 for (size_t i = 0; i < GR_ARRAY_COUNT(fTexture); i++) { 174 for (size_t i = 0; i < GR_ARRAY_COUNT(fTexture); i++) {
173 SkSafeUnref(fTexture[i]); 175 SkSafeUnref(fTexture[i]);
174 } 176 }
175 delete fPlotMgr; 177 for (int i = 0; i < kCount_GrMaskFormats; ++i) {
178 delete fPlotMgr[i];
179 }
176 180
177 fGpu->unref(); 181 fGpu->unref();
178 #if FONT_CACHE_STATS 182 #if FONT_CACHE_STATS
179 GrPrintf("Num uploads: %d\n", g_UploadCount); 183 GrPrintf("Num uploads: %d\n", g_UploadCount);
180 #endif 184 #endif
181 } 185 }
182 186
183 static GrPixelConfig maskformat2pixelconfig(GrMaskFormat format) { 187 static GrPixelConfig maskformat2pixelconfig(GrMaskFormat format) {
184 switch (format) { 188 switch (format) {
185 case kA8_GrMaskFormat: 189 case kA8_GrMaskFormat:
(...skipping 20 matching lines...) Expand all
206 if (atlasIter->addSubImage(width, height, image, loc)) { 210 if (atlasIter->addSubImage(width, height, image, loc)) {
207 return atlasIter; 211 return atlasIter;
208 } 212 }
209 atlasIter = atlasIter->fNext; 213 atlasIter = atlasIter->fNext;
210 } 214 }
211 215
212 // If the above fails, then either we have no starting atlas, or the current 216 // If the above fails, then either we have no starting atlas, or the current
213 // atlas list is full. Either way we need to allocate a new atlas 217 // atlas list is full. Either way we need to allocate a new atlas
214 218
215 GrIPoint16 plot; 219 GrIPoint16 plot;
216 if (!fPlotMgr->newPlot(&plot)) { 220 if (!fPlotMgr[format]->newPlot(&plot)) {
217 return NULL; 221 return NULL;
218 } 222 }
219 223
220 SkASSERT(0 == kA8_GrMaskFormat); 224 SkASSERT(0 == kA8_GrMaskFormat);
221 SkASSERT(1 == kA565_GrMaskFormat); 225 SkASSERT(1 == kA565_GrMaskFormat);
222 if (NULL == fTexture[format]) { 226 if (NULL == fTexture[format]) {
223 // TODO: Update this to use the cache rather than directly creating a te xture. 227 // TODO: Update this to use the cache rather than directly creating a te xture.
224 GrTextureDesc desc; 228 GrTextureDesc desc;
225 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; 229 desc.fFlags = kDynamicUpdate_GrTextureFlagBit;
226 desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; 230 desc.fWidth = GR_ATLAS_TEXTURE_WIDTH;
(...skipping 13 matching lines...) Expand all
240 } 244 }
241 245
242 // new atlas, put at head 246 // new atlas, put at head
243 newAtlas->fNext = *atlas; 247 newAtlas->fNext = *atlas;
244 *atlas = newAtlas; 248 *atlas = newAtlas;
245 249
246 return newAtlas; 250 return newAtlas;
247 } 251 }
248 252
249 void GrAtlasMgr::freePlot(GrMaskFormat format, int x, int y) { 253 void GrAtlasMgr::freePlot(GrMaskFormat format, int x, int y) {
250 SkASSERT(fPlotMgr->isBusy(x, y)); 254 SkASSERT(fPlotMgr[format]->isBusy(x, y));
251 fPlotMgr->freePlot(x, y); 255 fPlotMgr[format]->freePlot(x, y);
252 } 256 }
OLDNEW
« no previous file with comments | « src/gpu/GrAtlas.h ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698