diff options
author | 2012-04-06 18:06:10 +0000 | |
---|---|---|
committer | 2012-04-06 18:06:10 +0000 | |
commit | 6995068c5ade6e179d2af82caddb0c1cd6f433b6 (patch) | |
tree | 661091dc664281379e0b3ad5bd7132cc81560bf5 /src/gpu/gl/GrGpuGL.cpp | |
parent | 022976554c32b9b1561774553d6c1868c62d9dcf (diff) |
Initial version of R8 support
http://codereview.appspot.com/5967067/
git-svn-id: http://skia.googlecode.com/svn/trunk@3622 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGpuGL.cpp')
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 8214b6ea53..8481b74ab4 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -1947,12 +1947,20 @@ unsigned gr_to_gl_filter(GrSamplerState::Filter filter) { } } -const GrGLenum* get_swizzle(GrPixelConfig config, - const GrSamplerState& sampler) { +// get_swizzle is only called from this .cpp so it is OK to inline it here +inline const GrGLenum* get_swizzle(GrPixelConfig config, + const GrSamplerState& sampler, + const GrGLCaps& glCaps) { if (GrPixelConfigIsAlphaOnly(config)) { - static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA, - GR_GL_ALPHA, GR_GL_ALPHA }; - return gAlphaSmear; + if (glCaps.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 if (sampler.swapsRAndB()) { static const GrGLenum gRedBlueSwap[] = { GR_GL_BLUE, GR_GL_GREEN, GR_GL_RED, GR_GL_ALPHA }; @@ -2032,7 +2040,7 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { newTexParams.fWrapS = wraps[sampler.getWrapX()]; newTexParams.fWrapT = wraps[sampler.getWrapY()]; memcpy(newTexParams.fSwizzleRGBA, - get_swizzle(nextTexture->config(), sampler), + get_swizzle(nextTexture->config(), sampler, this->glCaps()), sizeof(newTexParams.fSwizzleRGBA)); if (setAll || newTexParams.fFilter != oldTexParams.fFilter) { setTextureUnit(s); @@ -2274,14 +2282,25 @@ bool GrGpuGL::configToGLFormats(GrPixelConfig config, } break; case kAlpha_8_GrPixelConfig: - *internalFormat = GR_GL_ALPHA; - *externalFormat = GR_GL_ALPHA; - if (getSizedInternalFormat) { - *internalFormat = GR_GL_ALPHA8; + if (this->glCaps().textureRedSupport()) { + *internalFormat = GR_GL_RED; + *externalFormat = GR_GL_RED; + if (getSizedInternalFormat) { + *internalFormat = GR_GL_R8; + } else { + *internalFormat = GR_GL_RED; + } + *externalType = GR_GL_UNSIGNED_BYTE; } else { *internalFormat = GR_GL_ALPHA; + *externalFormat = GR_GL_ALPHA; + if (getSizedInternalFormat) { + *internalFormat = GR_GL_ALPHA8; + } else { + *internalFormat = GR_GL_ALPHA; + } + *externalType = GR_GL_UNSIGNED_BYTE; } - *externalType = GR_GL_UNSIGNED_BYTE; break; default: return false; |