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