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 "GrDrawContext.h" |
9 #include "GrGpu.h" | 10 #include "GrGpu.h" |
10 #include "GrLayerCache.h" | 11 #include "GrLayerCache.h" |
11 #include "GrSurfacePriv.h" | 12 #include "GrSurfacePriv.h" |
12 | 13 |
13 #ifdef SK_DEBUG | 14 #ifdef SK_DEBUG |
14 void GrCachedLayer::validate(const GrTexture* backingTexture) const { | 15 void GrCachedLayer::validate(const GrTexture* backingTexture) const { |
15 SkASSERT(SK_InvalidGenID != fKey.pictureID()); | 16 SkASSERT(SK_InvalidGenID != fKey.pictureID()); |
16 | 17 |
17 if (fTexture) { | 18 if (fTexture) { |
18 // If the layer is in some texture then it must occupy some rectangle | 19 // If the layer is in some texture then it must occupy some rectangle |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 for (plot = fAtlas->iterInit(&iter, GrAtlas::kLRUFirst_IterOrder); | 459 for (plot = fAtlas->iterInit(&iter, GrAtlas::kLRUFirst_IterOrder); |
459 plot; | 460 plot; |
460 plot = iter.prev()) { | 461 plot = iter.prev()) { |
461 SkASSERT(0 == fPlotLocks[plot->id()]); | 462 SkASSERT(0 == fPlotLocks[plot->id()]); |
462 | 463 |
463 this->purgePlot(plot); | 464 this->purgePlot(plot); |
464 } | 465 } |
465 | 466 |
466 SkASSERT(0 == fPictureHash.count()); | 467 SkASSERT(0 == fPictureHash.count()); |
467 | 468 |
468 fContext->discardRenderTarget(fAtlas->getTexture()->asRenderTarget()); | 469 GrDrawContext* drawContext = fContext->drawContext(); |
| 470 |
| 471 if (drawContext) { |
| 472 drawContext->discard(fAtlas->getTexture()->asRenderTarget()); |
| 473 } |
469 } | 474 } |
470 #endif | 475 #endif |
471 | 476 |
472 void GrLayerCache::processDeletedPictures() { | 477 void GrLayerCache::processDeletedPictures() { |
473 SkTArray<SkPicture::DeletionMessage> deletedPictures; | 478 SkTArray<SkPicture::DeletionMessage> deletedPictures; |
474 fPictDeletionInbox.poll(&deletedPictures); | 479 fPictDeletionInbox.poll(&deletedPictures); |
475 | 480 |
476 for (int i = 0; i < deletedPictures.count(); i++) { | 481 for (int i = 0; i < deletedPictures.count(); i++) { |
477 this->purge(deletedPictures[i].fUniqueID); | 482 this->purge(deletedPictures[i].fUniqueID); |
478 } | 483 } |
(...skipping 24 matching lines...) Expand all Loading... |
503 fileName.appendf("\\%d", layer->fKey.pictureID()); | 508 fileName.appendf("\\%d", layer->fKey.pictureID()); |
504 for (int i = 0; i < layer->fKey.keySize(); ++i) { | 509 for (int i = 0; i < layer->fKey.keySize(); ++i) { |
505 fileName.appendf("-%d", layer->fKey.key()[i]); | 510 fileName.appendf("-%d", layer->fKey.key()[i]); |
506 } | 511 } |
507 fileName.appendf(".png"); | 512 fileName.appendf(".png"); |
508 | 513 |
509 layer->texture()->surfacePriv().savePixels(fileName.c_str()); | 514 layer->texture()->surfacePriv().savePixels(fileName.c_str()); |
510 } | 515 } |
511 } | 516 } |
512 #endif | 517 #endif |
OLD | NEW |