Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "GrBatchTarget.h" | 9 #include "GrBatchTarget.h" |
| 10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 222 |
| 223 /////////////////////////////////////////////////////////////////////////////// | 223 /////////////////////////////////////////////////////////////////////////////// |
| 224 | 224 |
| 225 GrBatchAtlas::GrBatchAtlas(GrTexture* texture, int numPlotsX, int numPlotsY) | 225 GrBatchAtlas::GrBatchAtlas(GrTexture* texture, int numPlotsX, int numPlotsY) |
| 226 : fTexture(texture) | 226 : fTexture(texture) |
| 227 , fNumPlotsX(numPlotsX) | 227 , fNumPlotsX(numPlotsX) |
| 228 , fNumPlotsY(numPlotsY) | 228 , fNumPlotsY(numPlotsY) |
| 229 , fPlotWidth(texture->width() / numPlotsX) | 229 , fPlotWidth(texture->width() / numPlotsX) |
| 230 , fPlotHeight(texture->height() / numPlotsY) | 230 , fPlotHeight(texture->height() / numPlotsY) |
| 231 , fAtlasGeneration(kInvalidAtlasGeneration + 1) { | 231 , fAtlasGeneration(kInvalidAtlasGeneration + 1) { |
| 232 SkASSERT(fNumPlotsX * fNumPlotsY <= BulkTokenReffer::kMaxPlots); | |
| 232 SkASSERT(fPlotWidth * fNumPlotsX == texture->width()); | 233 SkASSERT(fPlotWidth * fNumPlotsX == texture->width()); |
| 233 SkASSERT(fPlotHeight * fNumPlotsY == texture->height()); | 234 SkASSERT(fPlotHeight * fNumPlotsY == texture->height()); |
| 234 | 235 |
| 235 // We currently do not support compressed atlases... | 236 // We currently do not support compressed atlases... |
| 236 SkASSERT(!GrPixelConfigIsCompressed(texture->desc().fConfig)); | 237 SkASSERT(!GrPixelConfigIsCompressed(texture->desc().fConfig)); |
| 237 | 238 |
| 238 // set up allocated plots | 239 // set up allocated plots |
| 239 fBPP = GrBytesPerPixel(texture->desc().fConfig); | 240 fBPP = GrBytesPerPixel(texture->desc().fConfig); |
| 240 fPlotArray = SkNEW_ARRAY(SkAutoTUnref<BatchPlot>, (fNumPlotsX * fNumPlotsY)) ; | 241 fPlotArray = SkNEW_ARRAY(SkAutoTUnref<BatchPlot>, (fNumPlotsX * fNumPlotsY)) ; |
| 241 | 242 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 newPlot->setLastUploadToken(batchTarget->currentToken()); | 353 newPlot->setLastUploadToken(batchTarget->currentToken()); |
| 353 SkAutoTUnref<GrPlotUploader> uploader(SkNEW_ARGS(GrPlotUploader, (newPlot))) ; | 354 SkAutoTUnref<GrPlotUploader> uploader(SkNEW_ARGS(GrPlotUploader, (newPlot))) ; |
| 354 batchTarget->upload(uploader); | 355 batchTarget->upload(uploader); |
| 355 *id = newPlot->id(); | 356 *id = newPlot->id(); |
| 356 plot->unref(); | 357 plot->unref(); |
| 357 fAtlasGeneration++; | 358 fAtlasGeneration++; |
| 358 return true; | 359 return true; |
| 359 } | 360 } |
| 360 | 361 |
| 361 bool GrBatchAtlas::hasID(AtlasID id) { | 362 bool GrBatchAtlas::hasID(AtlasID id) { |
| 362 int index = this->getIndexFromID(id); | 363 int index = this->GetIndexFromID(id); |
| 363 SkASSERT(index < fNumPlotsX * fNumPlotsY); | 364 SkASSERT(index < fNumPlotsX * fNumPlotsY); |
| 364 return fPlotArray[index]->genID() == this->getGenerationFromID(id); | 365 return fPlotArray[index]->genID() == this->GetGenerationFromID(id); |
| 365 } | 366 } |
| 366 | 367 |
| 367 void GrBatchAtlas::setLastRefToken(AtlasID id, BatchToken batchToken) { | 368 void GrBatchAtlas::setLastRefToken(AtlasID id, BatchToken batchToken) { |
| 368 SkASSERT(this->hasID(id)); | 369 SkASSERT(this->hasID(id)); |
| 369 int index = this->getIndexFromID(id); | 370 int index = this->GetIndexFromID(id); |
| 370 this->makeMRU(fPlotArray[index]); | 371 this->makeMRU(fPlotArray[index]); |
|
bsalomon
2015/04/01 20:21:31
Call setLastRefTokenInternal() here?
| |
| 371 fPlotArray[index]->setLastRefToken(batchToken); | 372 fPlotArray[index]->setLastRefToken(batchToken); |
| 372 } | 373 } |
| 374 | |
| 375 void GrBatchAtlas::setLastRefTokenInternal(int index, BatchToken batchToken) { | |
|
bsalomon
2015/04/01 20:21:31
tiny nit, I think we more often say "internalSetLa
| |
| 376 SkASSERT(index < fNumPlotsX * fNumPlotsY); | |
| 377 this->makeMRU(fPlotArray[index]); | |
| 378 fPlotArray[index]->setLastRefToken(batchToken); | |
| 379 } | |
| 380 | |
| 381 void GrBatchAtlas::setLastRefTokenBulk(const BulkTokenReffer& reffer) { | |
| 382 int plotsToUpdateCount = reffer.fPlotsToUpdate.count(); | |
| 383 for (int i = 0; i < plotsToUpdateCount; i++) { | |
| 384 BatchPlot* plot = fPlotArray[reffer.fPlotsToUpdate[i]]; | |
| 385 this->makeMRU(plot); | |
| 386 plot->setLastRefToken(reffer.fBatchToken); | |
| 387 } | |
| 388 } | |
| OLD | NEW |