| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * This method allows us to interrupt the normal deletion process and place | 25 * This method allows us to interrupt the normal deletion process and place |
| 26 * textures back in the texture cache when their ref count goes to zero. | 26 * textures back in the texture cache when their ref count goes to zero. |
| 27 */ | 27 */ |
| 28 void GrTexture::internal_dispose() const { | 28 void GrTexture::internal_dispose() const { |
| 29 if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_F
lagBit) && | 29 if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_F
lagBit) && |
| 30 NULL != this->INHERITED::getContext()) { | 30 NULL != this->INHERITED::getContext()) { |
| 31 GrTexture* nonConstThis = const_cast<GrTexture *>(this); | 31 GrTexture* nonConstThis = const_cast<GrTexture *>(this); |
| 32 this->fRefCnt = 1; // restore ref count to initial setting | 32 this->ref(); // restore ref count to initial setting |
| 33 | 33 |
| 34 nonConstThis->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnT
oCache_FlagBit); | 34 nonConstThis->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnT
oCache_FlagBit); |
| 35 nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonCons
tThis); | 35 nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonCons
tThis); |
| 36 | 36 |
| 37 // Note: "this" texture might be freed inside addExistingTextureToCache | 37 // Note: "this" texture might be freed inside addExistingTextureToCache |
| 38 // if it is purged. | 38 // if it is purged. |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 SkASSERT(0 == this->getDeferredRefCount()); | |
| 43 this->INHERITED::internal_dispose(); | 42 this->INHERITED::internal_dispose(); |
| 44 } | 43 } |
| 45 | 44 |
| 46 void GrTextureImpl::dirtyMipMaps(bool mipMapsDirty) { | 45 void GrTextureImpl::dirtyMipMaps(bool mipMapsDirty) { |
| 47 if (mipMapsDirty) { | 46 if (mipMapsDirty) { |
| 48 if (kValid_MipMapsStatus == fMipMapsStatus) { | 47 if (kValid_MipMapsStatus == fMipMapsStatus) { |
| 49 fMipMapsStatus = kAllocated_MipMapsStatus; | 48 fMipMapsStatus = kAllocated_MipMapsStatus; |
| 50 } | 49 } |
| 51 } else { | 50 } else { |
| 52 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; | 51 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return GrResourceKey(cacheID, texture_resource_type(), 0); | 220 return GrResourceKey(cacheID, texture_resource_type(), 0); |
| 222 } | 221 } |
| 223 | 222 |
| 224 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { | 223 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { |
| 225 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 224 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
| 226 } | 225 } |
| 227 | 226 |
| 228 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { | 227 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { |
| 229 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); | 228 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
| 230 } | 229 } |
| OLD | NEW |