| 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" |
| 11 #include "GrSurfacePriv.h" |
| 11 | 12 |
| 12 DECLARE_SKMESSAGEBUS_MESSAGE(GrPictureDeletedMessage); | 13 DECLARE_SKMESSAGEBUS_MESSAGE(GrPictureDeletedMessage); |
| 13 | 14 |
| 14 #ifdef SK_DEBUG | 15 #ifdef SK_DEBUG |
| 15 void GrCachedLayer::validate(const GrTexture* backingTexture) const { | 16 void GrCachedLayer::validate(const GrTexture* backingTexture) const { |
| 16 SkASSERT(SK_InvalidGenID != fKey.pictureID()); | 17 SkASSERT(SK_InvalidGenID != fKey.pictureID()); |
| 17 SkASSERT(fKey.start() >= 0); | 18 SkASSERT(fKey.start() >= 0); |
| 18 | 19 |
| 19 if (fTexture) { | 20 if (fTexture) { |
| 20 // If the layer is in some texture then it must occupy some rectangle | 21 // If the layer is in some texture then it must occupy some rectangle |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 428 |
| 428 void GrLayerCache::processDeletedPictures() { | 429 void GrLayerCache::processDeletedPictures() { |
| 429 SkTDArray<GrPictureDeletedMessage> deletedPictures; | 430 SkTDArray<GrPictureDeletedMessage> deletedPictures; |
| 430 fPictDeletionInbox.poll(&deletedPictures); | 431 fPictDeletionInbox.poll(&deletedPictures); |
| 431 | 432 |
| 432 for (int i = 0; i < deletedPictures.count(); i++) { | 433 for (int i = 0; i < deletedPictures.count(); i++) { |
| 433 this->purge(deletedPictures[i].pictureID); | 434 this->purge(deletedPictures[i].pictureID); |
| 434 } | 435 } |
| 435 } | 436 } |
| 436 | 437 |
| 438 #ifdef SK_DEVELOPER |
| 439 void GrLayerCache::writeLayersToDisk(const SkString& dirName) { |
| 440 |
| 441 GrTexture* atlasTexture = fAtlas->getTexture(); |
| 442 if (NULL != atlasTexture) { |
| 443 SkString fileName(dirName); |
| 444 fileName.append("\\atlas.png"); |
| 445 |
| 446 atlasTexture->surfacePriv().savePixels(fileName.c_str()); |
| 447 } |
| 448 |
| 449 SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key>::Iter iter(&fLayerHash); |
| 450 for (; !iter.done(); ++iter) { |
| 451 GrCachedLayer* layer = &(*iter); |
| 452 |
| 453 if (layer->isAtlased() || !layer->texture()) { |
| 454 continue; |
| 455 } |
| 456 |
| 457 SkString fileName(dirName); |
| 458 fileName.append("\\"); |
| 459 fileName.appendU32(layer->fKey.pictureID()); |
| 460 fileName.append("-"); |
| 461 fileName.appendU32(layer->fKey.start()); |
| 462 fileName.append(".png"); |
| 463 |
| 464 layer->texture()->surfacePriv().savePixels(fileName.c_str()); |
| 465 } |
| 466 } |
| 467 #endif |
| OLD | NEW |