| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrAtlas.h" | 8 #include "GrAtlas.h" |
| 9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
| 10 #include "GrLayerCache.h" | 10 #include "GrLayerCache.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // plausibly atlas-able). See if a plot can be purged and try again. | 211 // plausibly atlas-able). See if a plot can be purged and try again. |
| 212 if (!this->purgePlot()) { | 212 if (!this->purgePlot()) { |
| 213 break; // We weren't able to purge any plots | 213 break; // We weren't able to purge any plots |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 // The texture wouldn't fit in the cache - give it it's own texture. | 218 // The texture wouldn't fit in the cache - give it it's own texture. |
| 219 // This path always uses a new scratch texture and (thus) doesn't cache anyt
hing. | 219 // This path always uses a new scratch texture and (thus) doesn't cache anyt
hing. |
| 220 // This can yield a lot of re-rendering | 220 // This can yield a lot of re-rendering |
| 221 SkAutoTUnref<GrTexture> tex(fContext->lockAndRefScratchTexture(desc, | 221 SkAutoTUnref<GrTexture> tex( |
| 222 GrContext::kApprox_Scrat
chTexMatch)); | 222 fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); |
| 223 | 223 |
| 224 layer->setTexture(tex, GrIRect16::MakeWH(SkToS16(desc.fWidth), SkToS16(desc.
fHeight))); | 224 layer->setTexture(tex, GrIRect16::MakeWH(SkToS16(desc.fWidth), SkToS16(desc.
fHeight))); |
| 225 layer->setLocked(true); | 225 layer->setLocked(true); |
| 226 return true; | 226 return true; |
| 227 } | 227 } |
| 228 | 228 |
| 229 void GrLayerCache::unlock(GrCachedLayer* layer) { | 229 void GrLayerCache::unlock(GrCachedLayer* layer) { |
| 230 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);) | 230 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);) |
| 231 | 231 |
| 232 if (NULL == layer || !layer->locked()) { | 232 if (NULL == layer || !layer->locked()) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 fileName.append("\\"); | 458 fileName.append("\\"); |
| 459 fileName.appendU32(layer->fKey.pictureID()); | 459 fileName.appendU32(layer->fKey.pictureID()); |
| 460 fileName.append("-"); | 460 fileName.append("-"); |
| 461 fileName.appendU32(layer->fKey.start()); | 461 fileName.appendU32(layer->fKey.start()); |
| 462 fileName.append(".png"); | 462 fileName.append(".png"); |
| 463 | 463 |
| 464 layer->texture()->surfacePriv().savePixels(fileName.c_str()); | 464 layer->texture()->surfacePriv().savePixels(fileName.c_str()); |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 #endif | 467 #endif |
| OLD | NEW |