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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatchFlushState.h » ('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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "GrBatchAtlas.h" 8 #include "GrBatchAtlas.h"
9 #include "GrBatchFlushState.h" 9 #include "GrBatchFlushState.h"
10 #include "GrRectanizer.h" 10 #include "GrRectanizer.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 , fAtlasGeneration(kInvalidAtlasGeneration + 1) { 212 , fAtlasGeneration(kInvalidAtlasGeneration + 1) {
213 213
214 int plotWidth = texture->width() / numPlotsX; 214 int plotWidth = texture->width() / numPlotsX;
215 int plotHeight = texture->height() / numPlotsY; 215 int plotHeight = texture->height() / numPlotsY;
216 SkASSERT(numPlotsX * numPlotsY <= BulkUseTokenUpdater::kMaxPlots); 216 SkASSERT(numPlotsX * numPlotsY <= BulkUseTokenUpdater::kMaxPlots);
217 SkASSERT(plotWidth * numPlotsX == texture->width()); 217 SkASSERT(plotWidth * numPlotsX == texture->width());
218 SkASSERT(plotHeight * numPlotsY == texture->height()); 218 SkASSERT(plotHeight * numPlotsY == texture->height());
219 219
220 SkDEBUGCODE(fNumPlots = numPlotsX * numPlotsY;) 220 SkDEBUGCODE(fNumPlots = numPlotsX * numPlotsY;)
221 221
222 fTexture->setFromRawPixels(true);
223 fTexture->setException(true);
224
222 // We currently do not support compressed atlases... 225 // We currently do not support compressed atlases...
223 SkASSERT(!GrPixelConfigIsCompressed(texture->desc().fConfig)); 226 SkASSERT(!GrPixelConfigIsCompressed(texture->desc().fConfig));
224 227
225 // set up allocated plots 228 // set up allocated plots
226 fPlotArray = new SkAutoTUnref<BatchPlot>[numPlotsX * numPlotsY]; 229 fPlotArray = new SkAutoTUnref<BatchPlot>[numPlotsX * numPlotsY];
227 230
228 SkAutoTUnref<BatchPlot>* currPlot = fPlotArray; 231 SkAutoTUnref<BatchPlot>* currPlot = fPlotArray;
229 for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) { 232 for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) {
230 for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) { 233 for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) {
231 uint32_t index = r * numPlotsX + c; 234 uint32_t index = r * numPlotsX + c;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 fAtlasGeneration++; 308 fAtlasGeneration++;
306 return true; 309 return true;
307 } 310 }
308 311
309 // The least recently used plot hasn't been flushed to the gpu yet, however, if we have flushed 312 // The least recently used plot hasn't been flushed to the gpu yet, however, if we have flushed
310 // it to the batch target than we can reuse it. Our last use token is guara nteed to be less 313 // it to the batch target than we can reuse it. Our last use token is guara nteed to be less
311 // than or equal to the current token. If its 'less than' the current token , than we can spin 314 // than or equal to the current token. If its 'less than' the current token , than we can spin
312 // off the plot (ie let the batch target manage it) and create a new plot in its place in our 315 // off the plot (ie let the batch target manage it) and create a new plot in its place in our
313 // array. If it is equal to the currentToken, then the caller has to flush draws to the batch 316 // array. If it is equal to the currentToken, then the caller has to flush draws to the batch
314 // target so we can spin off the plot 317 // target so we can spin off the plot
315 if (plot->lastUseToken() == batchTarget->currentToken()) { 318 if (plot->lastUseToken() == batchTarget->currentToken1()) {
316 return false; 319 return false;
317 } 320 }
318 321
319 SkASSERT(plot->lastUseToken() < batchTarget->currentToken()); 322 SkASSERT(plot->lastUseToken() < batchTarget->currentToken1());
320 SkASSERT(!batchTarget->hasTokenBeenFlushed(batchTarget->currentToken())); 323 SkASSERT(!batchTarget->hasTokenBeenFlushed(batchTarget->currentToken1()));
321 324
322 SkASSERT(!plot->unique()); // The GrPlotUpdater should have a ref too 325 SkASSERT(!plot->unique()); // The GrPlotUpdater should have a ref too
323 326
324 this->processEviction(plot->id()); 327 this->processEviction(plot->id());
325 fPlotList.remove(plot); 328 fPlotList.remove(plot);
326 SkAutoTUnref<BatchPlot>& newPlot = fPlotArray[plot->index()]; 329 SkAutoTUnref<BatchPlot>& newPlot = fPlotArray[plot->index()];
327 newPlot.reset(plot->clone()); 330 newPlot.reset(plot->clone());
328 331
329 fPlotList.addToHead(newPlot.get()); 332 fPlotList.addToHead(newPlot.get());
330 SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == newPlot->bpp()); 333 SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == newPlot->bpp());
331 SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc); 334 SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc);
332 SkASSERT(verify); 335 SkASSERT(verify);
333 336
334 // Note that this plot will be uploaded inline with the draws whereas the 337 // Note that this plot will be uploaded inline with the draws whereas the
335 // one it displaced most likely was uploaded asap. 338 // one it displaced most likely was uploaded asap.
336 newPlot->setLastUploadToken(batchTarget->currentToken()); 339 newPlot->setLastUploadToken(batchTarget->currentToken1());
337 SkAutoTUnref<GrPlotUploader> uploader(new GrPlotUploader(newPlot, fTexture)) ; 340 SkAutoTUnref<GrPlotUploader> uploader(new GrPlotUploader(newPlot, fTexture)) ;
338 batchTarget->upload(uploader); 341 batchTarget->upload(uploader);
339 *id = newPlot->id(); 342 *id = newPlot->id();
340 343
341 fAtlasGeneration++; 344 fAtlasGeneration++;
342 return true; 345 return true;
343 } 346 }
344 347
345 bool GrBatchAtlas::hasID(AtlasID id) { 348 bool GrBatchAtlas::hasID(AtlasID id) {
346 uint32_t index = GetIndexFromID(id); 349 uint32_t index = GetIndexFromID(id);
(...skipping 11 matching lines...) Expand all
358 361
359 void GrBatchAtlas::setLastUseTokenBulk(const BulkUseTokenUpdater& updater, 362 void GrBatchAtlas::setLastUseTokenBulk(const BulkUseTokenUpdater& updater,
360 GrBatchToken batchToken) { 363 GrBatchToken batchToken) {
361 int count = updater.fPlotsToUpdate.count(); 364 int count = updater.fPlotsToUpdate.count();
362 for (int i = 0; i < count; i++) { 365 for (int i = 0; i < count; i++) {
363 BatchPlot* plot = fPlotArray[updater.fPlotsToUpdate[i]]; 366 BatchPlot* plot = fPlotArray[updater.fPlotsToUpdate[i]];
364 this->makeMRU(plot); 367 this->makeMRU(plot);
365 plot->setLastUseToken(batchToken); 368 plot->setLastUseToken(batchToken);
366 } 369 }
367 } 370 }
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatchFlushState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698