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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SkASSERT(0 != idDesc.fInfo.fID); | 51 SkASSERT(0 != idDesc.fInfo.fID); |
52 fTexParams.invalidate(); | 52 fTexParams.invalidate(); |
53 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; | 53 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; |
54 fInfo = idDesc.fInfo; | 54 fInfo = idDesc.fInfo; |
55 fTextureIDLifecycle = idDesc.fLifeCycle; | 55 fTextureIDLifecycle = idDesc.fLifeCycle; |
56 } | 56 } |
57 | 57 |
58 void GrGLTexture::onRelease() { | 58 void GrGLTexture::onRelease() { |
59 if (fInfo.fID) { | 59 if (fInfo.fID) { |
60 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { | 60 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { |
61 if (this->desc().fTextureStorageAllocator.fDeallocateTextureStorage)
{ | 61 GL_CALL(DeleteTextures(1, &fInfo.fID)); |
62 this->desc().fTextureStorageAllocator.fDeallocateTextureStorage( | |
63 this->desc().fTextureStorageAllocator.fCtx, | |
64 reinterpret_cast<GrBackendObject>(&fInfo)); | |
65 } else { | |
66 GL_CALL(DeleteTextures(1, &fInfo.fID)); | |
67 } | |
68 } | 62 } |
69 fInfo.fID = 0; | 63 fInfo.fID = 0; |
70 } | 64 } |
71 INHERITED::onRelease(); | 65 INHERITED::onRelease(); |
72 } | 66 } |
73 | 67 |
74 void GrGLTexture::onAbandon() { | 68 void GrGLTexture::onAbandon() { |
75 fInfo.fTarget = 0; | 69 fInfo.fTarget = 0; |
76 fInfo.fID = 0; | 70 fInfo.fID = 0; |
77 INHERITED::onAbandon(); | 71 INHERITED::onAbandon(); |
78 } | 72 } |
79 | 73 |
80 GrBackendObject GrGLTexture::getTextureHandle() const { | 74 GrBackendObject GrGLTexture::getTextureHandle() const { |
81 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 75 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
82 return static_cast<GrBackendObject>(this->textureID()); | 76 return static_cast<GrBackendObject>(this->textureID()); |
83 #else | 77 #else |
84 return reinterpret_cast<GrBackendObject>(&fInfo); | 78 return reinterpret_cast<GrBackendObject>(&fInfo); |
85 #endif | 79 #endif |
86 } | 80 } |
87 | 81 |
88 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 82 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
89 const SkString& dumpName) const { | 83 const SkString& dumpName) const { |
90 SkString texture_id; | 84 SkString texture_id; |
91 texture_id.appendU32(this->textureID()); | 85 texture_id.appendU32(this->textureID()); |
92 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", | 86 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", |
93 texture_id.c_str()); | 87 texture_id.c_str()); |
94 } | 88 } |
OLD | NEW |