OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrResourceCache.h" | 10 #include "GrResourceCache.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 #endif | 364 #endif |
365 resource->cacheAccess().setTimestamp(this->getNextTimestamp()); | 365 resource->cacheAccess().setTimestamp(this->getNextTimestamp()); |
366 SkDEBUGCODE(fNewlyPurgeableResourceForValidation = nullptr); | 366 SkDEBUGCODE(fNewlyPurgeableResourceForValidation = nullptr); |
367 } | 367 } |
368 | 368 |
369 if (!SkToBool(ResourceAccess::kAllCntsReachedZero_RefNotificationFlag & flag
s)) { | 369 if (!SkToBool(ResourceAccess::kAllCntsReachedZero_RefNotificationFlag & flag
s)) { |
370 SkASSERT(!resource->isPurgeable()); | 370 SkASSERT(!resource->isPurgeable()); |
371 return; | 371 return; |
372 } | 372 } |
373 | 373 |
| 374 if (resource->type1() == GrGpuResource::kSurface) { |
| 375 GrRenderTarget* rt = resource->arrgh(); |
| 376 |
| 377 // TODO: add an assert here that the DT's RT is already closed && discar
ded! |
| 378 // closed means: official DT ptr is NULL and bit set |
| 379 // All the counts have reached 0! |
| 380 if (rt && rt->getLastDrawTarget()) { |
| 381 SkASSERT(rt->getLastDrawTarget()->isClosed() || rt->getLastDrawTarge
t()->isEmpty3()); |
| 382 } |
| 383 |
| 384 if (rt) { |
| 385 rt->setLastDrawTarget(NULL); |
| 386 } |
| 387 |
| 388 if (resource->getUniqueKey().isValid()) { |
| 389 SkASSERT(resource->fromRawPixels2() || resource->fException2); |
| 390 } else { |
| 391 SkASSERT(resource->exception() || !resource->fromRawPixels2()); |
| 392 resource->setException(false); |
| 393 resource->setFromRawPixels(false); |
| 394 resource->fException2 = false; |
| 395 } |
| 396 } |
| 397 |
374 SkASSERT(resource->isPurgeable()); | 398 SkASSERT(resource->isPurgeable()); |
375 this->removeFromNonpurgeableArray(resource); | 399 this->removeFromNonpurgeableArray(resource); |
376 fPurgeableQueue.insert(resource); | 400 fPurgeableQueue.insert(resource); |
377 | 401 |
378 if (!resource->resourcePriv().isBudgeted()) { | 402 if (!resource->resourcePriv().isBudgeted()) { |
379 // Check whether this resource could still be used as a scratch resource
. | 403 // Check whether this resource could still be used as a scratch resource
. |
380 if (!resource->cacheAccess().isExternal() && | 404 if (!resource->cacheAccess().isExternal() && |
381 resource->resourcePriv().getScratchKey().isValid()) { | 405 resource->resourcePriv().getScratchKey().isValid()) { |
382 // We won't purge an existing resource to make room for this one. | 406 // We won't purge an existing resource to make room for this one. |
383 if (fBudgetedCount < fMaxCount && | 407 if (fBudgetedCount < fMaxCount && |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 return true; | 757 return true; |
734 } | 758 } |
735 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index]
== resource) { | 759 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index]
== resource) { |
736 return true; | 760 return true; |
737 } | 761 } |
738 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca
che."); | 762 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca
che."); |
739 return false; | 763 return false; |
740 } | 764 } |
741 | 765 |
742 #endif | 766 #endif |
OLD | NEW |