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 if (desc().fTextureStorageAllocator) { |
| 41 desc().fTextureStorageAllocator->deallocateTextureStorage( |
| 42 reinterpret_cast<GrBackendObject>(&fInfo)); |
| 43 } |
40 GL_CALL(DeleteTextures(1, &fInfo.fID)); | 44 GL_CALL(DeleteTextures(1, &fInfo.fID)); |
41 } | 45 } |
42 fInfo.fID = 0; | 46 fInfo.fID = 0; |
43 } | 47 } |
44 INHERITED::onRelease(); | 48 INHERITED::onRelease(); |
45 } | 49 } |
46 | 50 |
47 void GrGLTexture::onAbandon() { | 51 void GrGLTexture::onAbandon() { |
48 fInfo.fTarget = 0; | 52 fInfo.fTarget = 0; |
49 fInfo.fID = 0; | 53 fInfo.fID = 0; |
50 INHERITED::onAbandon(); | 54 INHERITED::onAbandon(); |
51 } | 55 } |
52 | 56 |
53 GrBackendObject GrGLTexture::getTextureHandle() const { | 57 GrBackendObject GrGLTexture::getTextureHandle() const { |
54 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 58 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
55 return static_cast<GrBackendObject>(this->textureID()); | 59 return static_cast<GrBackendObject>(this->textureID()); |
56 #else | 60 #else |
57 return reinterpret_cast<GrBackendObject>(&fInfo); | 61 return reinterpret_cast<GrBackendObject>(&fInfo); |
58 #endif | 62 #endif |
59 } | 63 } |
60 | 64 |
61 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 65 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
62 const SkString& dumpName) const { | 66 const SkString& dumpName) const { |
63 SkString texture_id; | 67 SkString texture_id; |
64 texture_id.appendU32(this->textureID()); | 68 texture_id.appendU32(this->textureID()); |
65 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", | 69 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", |
66 texture_id.c_str()); | 70 texture_id.c_str()); |
67 } | 71 } |
OLD | NEW |