| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 GrContext* context = this->getContext(); | 60 GrContext* context = this->getContext(); |
| 61 if (NULL == context) { | 61 if (NULL == context) { |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 context->writeTexturePixels(this, | 64 context->writeTexturePixels(this, |
| 65 left, top, width, height, | 65 left, top, width, height, |
| 66 config, buffer, rowBytes, | 66 config, buffer, rowBytes, |
| 67 pixelOpsFlags); | 67 pixelOpsFlags); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void GrTexture::releaseRenderTarget() { | |
| 71 if (NULL != fRenderTarget) { | |
| 72 GrAssert(fRenderTarget->asTexture() == this); | |
| 73 GrAssert(fDesc.fFlags & kRenderTarget_GrTextureFlagBit); | |
| 74 | |
| 75 fRenderTarget->onTextureReleaseRenderTarget(); | |
| 76 fRenderTarget->unref(); | |
| 77 fRenderTarget = NULL; | |
| 78 | |
| 79 fDesc.fFlags = fDesc.fFlags & | |
| 80 ~(kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit); | |
| 81 fDesc.fSampleCnt = 0; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 void GrTexture::onRelease() { | 70 void GrTexture::onRelease() { |
| 86 GrAssert(!this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit)); | 71 GrAssert(!this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit)); |
| 87 this->releaseRenderTarget(); | |
| 88 | |
| 89 INHERITED::onRelease(); | 72 INHERITED::onRelease(); |
| 90 } | 73 } |
| 91 | 74 |
| 92 void GrTexture::onAbandon() { | 75 void GrTexture::onAbandon() { |
| 93 if (NULL != fRenderTarget) { | 76 if (NULL != fRenderTarget.get()) { |
| 94 fRenderTarget->abandon(); | 77 fRenderTarget->abandon(); |
| 95 } | 78 } |
| 96 | |
| 97 INHERITED::onAbandon(); | 79 INHERITED::onAbandon(); |
| 98 } | 80 } |
| 99 | 81 |
| 100 void GrTexture::validateDesc() const { | 82 void GrTexture::validateDesc() const { |
| 101 if (NULL != this->asRenderTarget()) { | 83 if (NULL != this->asRenderTarget()) { |
| 102 // This texture has a render target | 84 // This texture has a render target |
| 103 GrAssert(0 != (fDesc.fFlags & kRenderTarget_GrTextureFlagBit)); | 85 GrAssert(0 != (fDesc.fFlags & kRenderTarget_GrTextureFlagBit)); |
| 104 | 86 |
| 105 if (NULL != this->asRenderTarget()->getStencilBuffer()) { | 87 if (NULL != this->asRenderTarget()->getStencilBuffer()) { |
| 106 GrAssert(0 != (fDesc.fFlags & kNoStencil_GrTextureFlagBit)); | 88 GrAssert(0 != (fDesc.fFlags & kNoStencil_GrTextureFlagBit)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return GrResourceKey(cacheID, texture_resource_type(), 0); | 176 return GrResourceKey(cacheID, texture_resource_type(), 0); |
| 195 } | 177 } |
| 196 | 178 |
| 197 bool GrTexture::NeedsResizing(const GrResourceKey& key) { | 179 bool GrTexture::NeedsResizing(const GrResourceKey& key) { |
| 198 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 180 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
| 199 } | 181 } |
| 200 | 182 |
| 201 bool GrTexture::NeedsFiltering(const GrResourceKey& key) { | 183 bool GrTexture::NeedsFiltering(const GrResourceKey& key) { |
| 202 return SkToBool(key.getResourceFlags() & kFilter_TextureFlag); | 184 return SkToBool(key.getResourceFlags() & kFilter_TextureFlag); |
| 203 } | 185 } |
| OLD | NEW |