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 "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 3206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3217 } | 3217 } |
3218 if (this->glCaps().textureSwizzleSupport() && | 3218 if (this->glCaps().textureSwizzleSupport() && |
3219 (setAll || memcmp(newTexParams.fSwizzleRGBA, | 3219 (setAll || memcmp(newTexParams.fSwizzleRGBA, |
3220 oldTexParams.fSwizzleRGBA, | 3220 oldTexParams.fSwizzleRGBA, |
3221 sizeof(newTexParams.fSwizzleRGBA)))) { | 3221 sizeof(newTexParams.fSwizzleRGBA)))) { |
3222 this->setTextureSwizzle(unitIdx, target, newTexParams.fSwizzleRGBA); | 3222 this->setTextureSwizzle(unitIdx, target, newTexParams.fSwizzleRGBA); |
3223 } | 3223 } |
3224 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); | 3224 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); |
3225 } | 3225 } |
3226 | 3226 |
3227 void GrGLGpu::bindTexelBuffer(int unitIdx, intptr_t offsetInBytes, GrPixelConfig
texelConfig, | 3227 void GrGLGpu::bindTexelBuffer(int unitIdx, GrPixelConfig texelConfig, GrGLBuffer
* buffer) { |
3228 GrGLBuffer* buffer) { | |
3229 SkASSERT(this->glCaps().canUseConfigWithTexelBuffer(texelConfig)); | 3228 SkASSERT(this->glCaps().canUseConfigWithTexelBuffer(texelConfig)); |
3230 SkASSERT(unitIdx >= 0 && unitIdx < fHWBufferTextures.count()); | 3229 SkASSERT(unitIdx >= 0 && unitIdx < fHWBufferTextures.count()); |
3231 SkASSERT(offsetInBytes >= 0 && offsetInBytes < (intptr_t) buffer->glSizeInBy
tes()); | |
3232 | 3230 |
3233 BufferTexture& buffTex = fHWBufferTextures[unitIdx]; | 3231 BufferTexture& buffTex = fHWBufferTextures[unitIdx]; |
3234 | 3232 |
3235 if (!buffTex.fKnownBound) { | 3233 if (!buffTex.fKnownBound) { |
3236 if (!buffTex.fTextureID) { | 3234 if (!buffTex.fTextureID) { |
3237 GL_CALL(GenTextures(1, &buffTex.fTextureID)); | 3235 GL_CALL(GenTextures(1, &buffTex.fTextureID)); |
3238 if (!buffTex.fTextureID) { | 3236 if (!buffTex.fTextureID) { |
3239 return; | 3237 return; |
3240 } | 3238 } |
3241 } | 3239 } |
3242 | 3240 |
3243 this->setTextureUnit(unitIdx); | 3241 this->setTextureUnit(unitIdx); |
3244 GL_CALL(BindTexture(GR_GL_TEXTURE_BUFFER, buffTex.fTextureID)); | 3242 GL_CALL(BindTexture(GR_GL_TEXTURE_BUFFER, buffTex.fTextureID)); |
3245 | 3243 |
3246 buffTex.fKnownBound = true; | 3244 buffTex.fKnownBound = true; |
3247 } | 3245 } |
3248 | 3246 |
3249 if (buffer->getUniqueID() != buffTex.fAttachedBufferUniqueID || | 3247 if (buffer->getUniqueID() != buffTex.fAttachedBufferUniqueID || |
3250 buffTex.fOffsetInBytes != offsetInBytes || | 3248 buffTex.fTexelConfig != texelConfig) { |
3251 buffTex.fTexelConfig != texelConfig || | |
3252 buffTex.fAttachedSizeInBytes != buffer->glSizeInBytes() - offsetInBytes)
{ | |
3253 | |
3254 size_t attachmentSizeInBytes = buffer->glSizeInBytes() - offsetInBytes; | |
3255 | 3249 |
3256 this->setTextureUnit(unitIdx); | 3250 this->setTextureUnit(unitIdx); |
3257 GL_CALL(TexBufferRange(GR_GL_TEXTURE_BUFFER, | 3251 GL_CALL(TexBuffer(GR_GL_TEXTURE_BUFFER, |
3258 this->glCaps().configSizedInternalFormat(texelCon
fig), | 3252 this->glCaps().configSizedInternalFormat(texelConfig), |
3259 buffer->bufferID(), | 3253 buffer->bufferID())); |
3260 offsetInBytes, | |
3261 attachmentSizeInBytes)); | |
3262 | 3254 |
3263 buffTex.fOffsetInBytes = offsetInBytes; | |
3264 buffTex.fTexelConfig = texelConfig; | 3255 buffTex.fTexelConfig = texelConfig; |
3265 buffTex.fAttachedSizeInBytes = attachmentSizeInBytes; | |
3266 buffTex.fAttachedBufferUniqueID = buffer->getUniqueID(); | 3256 buffTex.fAttachedBufferUniqueID = buffer->getUniqueID(); |
3267 | 3257 |
3268 if (this->glCaps().textureSwizzleSupport() && | 3258 if (this->glCaps().textureSwizzleSupport() && |
3269 this->glCaps().configSwizzle(texelConfig) != buffTex.fSwizzle) { | 3259 this->glCaps().configSwizzle(texelConfig) != buffTex.fSwizzle) { |
3270 GrGLenum glSwizzle[4]; | 3260 GrGLenum glSwizzle[4]; |
3271 get_tex_param_swizzle(texelConfig, this->glCaps(), glSwizzle); | 3261 get_tex_param_swizzle(texelConfig, this->glCaps(), glSwizzle); |
3272 this->setTextureSwizzle(unitIdx, GR_GL_TEXTURE_BUFFER, glSwizzle); | 3262 this->setTextureSwizzle(unitIdx, GR_GL_TEXTURE_BUFFER, glSwizzle); |
3273 buffTex.fSwizzle = this->glCaps().configSwizzle(texelConfig); | 3263 buffTex.fSwizzle = this->glCaps().configSwizzle(texelConfig); |
3274 } | 3264 } |
3275 | 3265 |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4245 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4235 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4246 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4236 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4247 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4237 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4248 copyParams->fWidth = texture->width(); | 4238 copyParams->fWidth = texture->width(); |
4249 copyParams->fHeight = texture->height(); | 4239 copyParams->fHeight = texture->height(); |
4250 return true; | 4240 return true; |
4251 } | 4241 } |
4252 } | 4242 } |
4253 return false; | 4243 return false; |
4254 } | 4244 } |
OLD | NEW |