/** * This method allows us to interrupt the normal deletion process and place * textures back in the texture cache when their ref count goes to zero. */ void GrTexture::internal_dispose() const { if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit) && this->INHERITED::getContext()) { GrTexture* nonConstThis = const_cast<GrTexture *>(this); this->ref(); // restore ref count to initial setting nonConstThis->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit); nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonConstThis); // Note: "this" texture might be freed inside addExistingTextureToCache // if it is purged. return; } this->INHERITED::internal_dispose(); }