| 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 "GrBatchFlushState.h" | 9 #include "GrBatchFlushState.h" |
| 10 #include "GrRectanizer.h" | 10 #include "GrRectanizer.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 // If this plot has been used in a draw that is currently being prepared by
a batch, then we | 214 // If this plot has been used in a draw that is currently being prepared by
a batch, then we |
| 215 // have to fail. This gives the batch a chance to enqueue the draw, and call
back into this | 215 // have to fail. This gives the batch a chance to enqueue the draw, and call
back into this |
| 216 // function. When that draw is enqueued, the draw token advances, and the su
bsequent call will | 216 // function. When that draw is enqueued, the draw token advances, and the su
bsequent call will |
| 217 // continue past this branch and prepare an inline upload that will occur af
ter the enqueued | 217 // continue past this branch and prepare an inline upload that will occur af
ter the enqueued |
| 218 // draw which references the plot's pre-upload content. | 218 // draw which references the plot's pre-upload content. |
| 219 if (plot->lastUseToken() == target->nextDrawToken()) { | 219 if (plot->lastUseToken() == target->nextDrawToken()) { |
| 220 return false; | 220 return false; |
| 221 } | 221 } |
| 222 | 222 |
| 223 SkASSERT(!plot->unique()); // The GrPlotUpdater should have a ref too | |
| 224 | |
| 225 this->processEviction(plot->id()); | 223 this->processEviction(plot->id()); |
| 226 fPlotList.remove(plot); | 224 fPlotList.remove(plot); |
| 227 SkAutoTUnref<BatchPlot>& newPlot = fPlotArray[plot->index()]; | 225 SkAutoTUnref<BatchPlot>& newPlot = fPlotArray[plot->index()]; |
| 228 newPlot.reset(plot->clone()); | 226 newPlot.reset(plot->clone()); |
| 229 | 227 |
| 230 fPlotList.addToHead(newPlot.get()); | 228 fPlotList.addToHead(newPlot.get()); |
| 231 SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == newPlot->bpp()); | 229 SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == newPlot->bpp()); |
| 232 SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc); | 230 SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc); |
| 233 SkASSERT(verify); | 231 SkASSERT(verify); |
| 234 | 232 |
| 235 // Note that this plot will be uploaded inline with the draws whereas the | 233 // Note that this plot will be uploaded inline with the draws whereas the |
| 236 // one it displaced most likely was uploaded asap. | 234 // one it displaced most likely was uploaded asap. |
| 237 // With c+14 we could move sk_sp into lamba to only ref once. | 235 // With c+14 we could move sk_sp into lamba to only ref once. |
| 238 sk_sp<BatchPlot> plotsp(SkRef(newPlot.get())); | 236 sk_sp<BatchPlot> plotsp(SkRef(newPlot.get())); |
| 239 GrTexture* texture = fTexture; | 237 GrTexture* texture = fTexture; |
| 240 GrBatchDrawToken lastUploadToken = target->addInlineUpload( | 238 GrBatchDrawToken lastUploadToken = target->addInlineUpload( |
| 241 [plotsp, texture] (GrDrawBatch::WritePixelsFn& writePixels) { | 239 [plotsp, texture] (GrDrawBatch::WritePixelsFn& writePixels) { |
| 242 plotsp->uploadToTexture(writePixels, texture); | 240 plotsp->uploadToTexture(writePixels, texture); |
| 243 } | 241 } |
| 244 ); | 242 ); |
| 245 newPlot->setLastUploadToken(lastUploadToken); | 243 newPlot->setLastUploadToken(lastUploadToken); |
| 246 | 244 |
| 247 *id = newPlot->id(); | 245 *id = newPlot->id(); |
| 248 | 246 |
| 249 fAtlasGeneration++; | 247 fAtlasGeneration++; |
| 250 return true; | 248 return true; |
| 251 } | 249 } |
| OLD | NEW |