Chromium Code Reviews| Index: src/gpu/gl/GrGLGpu.cpp |
| diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
| index dc3ea0c3d782afd8afdd6e6172e395b08d87f180..d55980c254b654f73c12d718c29b58786ee9512a 100644 |
| --- a/src/gpu/gl/GrGLGpu.cpp |
| +++ b/src/gpu/gl/GrGLGpu.cpp |
| @@ -2396,19 +2396,32 @@ static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) { |
| return gWrapModes[tm]; |
| } |
| -const GrGLenum* GrGLGpu::GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps) { |
| - if (caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) { |
| - if (caps.textureRedSupport()) { |
| - static const GrGLenum gRedSmear[] = { GR_GL_RED, GR_GL_RED, GR_GL_RED, GR_GL_RED }; |
| - return gRedSmear; |
| - } else { |
| - static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA, |
| - GR_GL_ALPHA, GR_GL_ALPHA }; |
| - return gAlphaSmear; |
| - } |
| - } else { |
| - static const GrGLenum gStraight[] = { GR_GL_RED, GR_GL_GREEN, GR_GL_BLUE, GR_GL_ALPHA }; |
| - return gStraight; |
| +static GrGLenum get_component_enum_from_char(char component) { |
| + switch (component) { |
| + case 'r': |
| + return GR_GL_RED; |
| + case 'g': |
| + return GR_GL_GREEN; |
| + case 'b': |
| + return GR_GL_BLUE; |
| + case 'a': |
| + return GR_GL_ALPHA; |
| + default: |
| + SkFAIL("Unsupported component"); |
| + return 0; |
| + } |
| +} |
| + |
| +void GrGLGpu::GetTexParamSwizzle(GrPixelConfig config, |
|
bsalomon
2015/11/03 14:45:51
can this be a static function rather than a member
egdaniel
2015/11/03 15:23:56
Done.
|
| + const GrGLSLCaps& caps, |
| + GrGLenum* glSwizzle) { |
| + const char* swizzle = "rgba"; |
| + if (!caps.mustSwizzleInShader()) { |
| + swizzle = caps.getSwizzleMap(config); |
| + } |
| + |
| + for (int i = 0; i < 4; ++i) { |
| + glSwizzle[i] = get_component_enum_from_char(swizzle[i]); |
| } |
| } |
| @@ -2477,9 +2490,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur |
| newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); |
| newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); |
| - memcpy(newTexParams.fSwizzleRGBA, |
| - GetTexParamSwizzle(texture->config(), this->glCaps()), |
| - sizeof(newTexParams.fSwizzleRGBA)); |
| + GetTexParamSwizzle(texture->config(), *this->glCaps().glslCaps(), newTexParams.fSwizzleRGBA); |
| if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { |
| this->setTextureUnit(unitIdx); |
| GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, newTexParams.fMagFilter)); |
| @@ -2496,7 +2507,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur |
| this->setTextureUnit(unitIdx); |
| GL_CALL(TexParameteri(target, GR_GL_TEXTURE_WRAP_T, newTexParams.fWrapT)); |
| } |
| - if (this->glCaps().textureSwizzleSupport() && |
| + if (!this->glCaps().glslCaps()->mustSwizzleInShader() && |
| (setAll || memcmp(newTexParams.fSwizzleRGBA, |
| oldTexParams.fSwizzleRGBA, |
| sizeof(newTexParams.fSwizzleRGBA)))) { |