| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrGLTexture.h" | 8 #include "GrGLTexture.h" |
| 9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "SkTraceMemoryDump.h" | 10 #include "SkTraceMemoryDump.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 SkASSERT(0 != idDesc.fInfo.fID); | 30 SkASSERT(0 != idDesc.fInfo.fID); |
| 31 fTexParams.invalidate(); | 31 fTexParams.invalidate(); |
| 32 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; | 32 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; |
| 33 fInfo = idDesc.fInfo; | 33 fInfo = idDesc.fInfo; |
| 34 fTextureIDLifecycle = idDesc.fLifeCycle; | 34 fTextureIDLifecycle = idDesc.fLifeCycle; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void GrGLTexture::onRelease() { | 37 void GrGLTexture::onRelease() { |
| 38 if (fInfo.fID) { | 38 if (fInfo.fID) { |
| 39 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { | 39 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { |
| 40 GL_CALL(DeleteTextures(1, &fInfo.fID)); | 40 if (this->desc().fTextureStorageAllocator.fDeallocateTextureStorage)
{ |
| 41 this->desc().fTextureStorageAllocator.fDeallocateTextureStorage( |
| 42 this->desc().fTextureStorageAllocator.fCtx, |
| 43 reinterpret_cast<GrBackendObject>(&fInfo)); |
| 44 } else { |
| 45 GL_CALL(DeleteTextures(1, &fInfo.fID)); |
| 46 } |
| 41 } | 47 } |
| 42 fInfo.fID = 0; | 48 fInfo.fID = 0; |
| 43 } | 49 } |
| 44 INHERITED::onRelease(); | 50 INHERITED::onRelease(); |
| 45 } | 51 } |
| 46 | 52 |
| 47 void GrGLTexture::onAbandon() { | 53 void GrGLTexture::onAbandon() { |
| 48 fInfo.fTarget = 0; | 54 fInfo.fTarget = 0; |
| 49 fInfo.fID = 0; | 55 fInfo.fID = 0; |
| 50 INHERITED::onAbandon(); | 56 INHERITED::onAbandon(); |
| 51 } | 57 } |
| 52 | 58 |
| 53 GrBackendObject GrGLTexture::getTextureHandle() const { | 59 GrBackendObject GrGLTexture::getTextureHandle() const { |
| 54 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 60 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
| 55 return static_cast<GrBackendObject>(this->textureID()); | 61 return static_cast<GrBackendObject>(this->textureID()); |
| 56 #else | 62 #else |
| 57 return reinterpret_cast<GrBackendObject>(&fInfo); | 63 return reinterpret_cast<GrBackendObject>(&fInfo); |
| 58 #endif | 64 #endif |
| 59 } | 65 } |
| 60 | 66 |
| 61 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 67 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 62 const SkString& dumpName) const { | 68 const SkString& dumpName) const { |
| 63 SkString texture_id; | 69 SkString texture_id; |
| 64 texture_id.appendU32(this->textureID()); | 70 texture_id.appendU32(this->textureID()); |
| 65 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", | 71 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", |
| 66 texture_id.c_str()); | 72 texture_id.c_str()); |
| 67 } | 73 } |
| OLD | NEW |