| 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" |
| 11 | 11 |
| 12 #define GPUGL static_cast<GrGLGpu*>(this->getGpu()) | 12 #define GPUGL static_cast<GrGLGpu*>(this->getGpu()) |
| 13 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) | 13 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) |
| 14 | 14 |
| 15 inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrG
LGpu* gpu) { |
| 16 if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) { |
| 17 SkASSERT(gpu->glCaps().glslCaps()->externalTextureSupport()); |
| 18 return kSamplerExternal_GrSLType; |
| 19 } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) { |
| 20 SkASSERT(gpu->glCaps().rectangleTextureSupport()); |
| 21 return kSampler2DRect_GrSLType; |
| 22 } else { |
| 23 SkASSERT(idDesc.fInfo.fTarget == GR_GL_TEXTURE_2D); |
| 24 return kSampler2D_GrSLType; |
| 25 } |
| 26 } |
| 27 |
| 15 // Because this class is virtually derived from GrSurface we must explicitly cal
l its constructor. | 28 // Because this class is virtually derived from GrSurface we must explicitly cal
l its constructor. |
| 16 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
idDesc) | 29 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
idDesc) |
| 17 : GrSurface(gpu, idDesc.fLifeCycle, desc) | 30 : GrSurface(gpu, idDesc.fLifeCycle, desc) |
| 18 , INHERITED(gpu, idDesc.fLifeCycle, desc, false) { | 31 , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), false)
{ |
| 19 this->init(desc, idDesc); | 32 this->init(desc, idDesc); |
| 20 this->registerWithCache(); | 33 this->registerWithCache(); |
| 21 } | 34 } |
| 22 | 35 |
| 23 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
idDesc, | 36 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
idDesc, |
| 24 bool wasMipMapDataProvided) | 37 bool wasMipMapDataProvided) |
| 25 : GrSurface(gpu, idDesc.fLifeCycle, desc) | 38 : GrSurface(gpu, idDesc.fLifeCycle, desc) |
| 26 , INHERITED(gpu, idDesc.fLifeCycle, desc, wasMipMapDataProvided) { | 39 , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), wasMipM
apDataProvided) { |
| 27 this->init(desc, idDesc); | 40 this->init(desc, idDesc); |
| 28 this->registerWithCache(); | 41 this->registerWithCache(); |
| 29 } | 42 } |
| 30 | 43 |
| 31 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
idDesc, Derived) | 44 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
idDesc, Derived) |
| 32 : GrSurface(gpu, idDesc.fLifeCycle, desc) | 45 : GrSurface(gpu, idDesc.fLifeCycle, desc) |
| 33 , INHERITED(gpu, idDesc.fLifeCycle, desc, false) { | 46 , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), false)
{ |
| 34 this->init(desc, idDesc); | 47 this->init(desc, idDesc); |
| 35 } | 48 } |
| 36 | 49 |
| 37 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { | 50 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { |
| 38 SkASSERT(0 != idDesc.fInfo.fID); | 51 SkASSERT(0 != idDesc.fInfo.fID); |
| 39 fTexParams.invalidate(); | 52 fTexParams.invalidate(); |
| 40 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; | 53 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; |
| 41 fInfo = idDesc.fInfo; | 54 fInfo = idDesc.fInfo; |
| 42 fTextureIDLifecycle = idDesc.fLifeCycle; | 55 fTextureIDLifecycle = idDesc.fLifeCycle; |
| 43 } | 56 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 #endif | 85 #endif |
| 73 } | 86 } |
| 74 | 87 |
| 75 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 88 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 76 const SkString& dumpName) const { | 89 const SkString& dumpName) const { |
| 77 SkString texture_id; | 90 SkString texture_id; |
| 78 texture_id.appendU32(this->textureID()); | 91 texture_id.appendU32(this->textureID()); |
| 79 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", | 92 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", |
| 80 texture_id.c_str()); | 93 texture_id.c_str()); |
| 81 } | 94 } |
| OLD | NEW |