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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 GrContext* context = this->getContext(); | 95 GrContext* context = this->getContext(); |
96 if (NULL == context) { | 96 if (NULL == context) { |
97 return; | 97 return; |
98 } | 98 } |
99 context->writeTexturePixels(this, | 99 context->writeTexturePixels(this, |
100 left, top, width, height, | 100 left, top, width, height, |
101 config, buffer, rowBytes, | 101 config, buffer, rowBytes, |
102 pixelOpsFlags); | 102 pixelOpsFlags); |
103 } | 103 } |
104 | 104 |
| 105 void GrTexture::abandonReleaseCommon() { |
| 106 // In debug builds the resource cache tracks removed/exclusive textures and
has an unref'ed ptr. |
| 107 // After abandon() or release() the resource cache will be unreachable (getC
ontext() == NULL). |
| 108 // So we readd the texture to the cache here so that it is removed from the
exclusive list and |
| 109 // there is no longer an unref'ed ptr to the texture in the cache. |
| 110 if (this->impl()->isSetFlag((GrTextureFlags)GrTextureImpl::kReturnToCache_Fl
agBit)) { |
| 111 SkASSERT(!this->wasDestroyed()); |
| 112 this->ref(); // restores the ref the resource cache gave up when it mar
ked this exclusive. |
| 113 this->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_F
lagBit); |
| 114 this->getContext()->addExistingTextureToCache(this); |
| 115 } |
| 116 } |
| 117 |
105 void GrTexture::onRelease() { | 118 void GrTexture::onRelease() { |
| 119 this->abandonReleaseCommon(); |
106 SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToC
ache_FlagBit)); | 120 SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToC
ache_FlagBit)); |
107 INHERITED::onRelease(); | 121 INHERITED::onRelease(); |
108 } | 122 } |
109 | 123 |
110 void GrTexture::onAbandon() { | 124 void GrTexture::onAbandon() { |
| 125 this->abandonReleaseCommon(); |
111 if (NULL != fRenderTarget.get()) { | 126 if (NULL != fRenderTarget.get()) { |
112 fRenderTarget->abandon(); | 127 fRenderTarget->abandon(); |
113 } | 128 } |
114 INHERITED::onAbandon(); | 129 INHERITED::onAbandon(); |
115 } | 130 } |
116 | 131 |
117 void GrTexture::validateDesc() const { | 132 void GrTexture::validateDesc() const { |
118 if (NULL != this->asRenderTarget()) { | 133 if (NULL != this->asRenderTarget()) { |
119 // This texture has a render target | 134 // This texture has a render target |
120 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrTextureFlagBit)); | 135 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrTextureFlagBit)); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 return GrResourceKey(cacheID, texture_resource_type(), 0); | 235 return GrResourceKey(cacheID, texture_resource_type(), 0); |
221 } | 236 } |
222 | 237 |
223 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { | 238 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { |
224 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 239 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
225 } | 240 } |
226 | 241 |
227 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { | 242 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { |
228 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); | 243 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
229 } | 244 } |
OLD | NEW |