Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1431433003: Move shader compiling to ProgramBuilder and various ShaderBuilder cleanups. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index a0809c1d7a447ab03b609bbe58f68fee7fc0788e..38beaf718a75bb74fa931af0b244a61868d85c15 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2396,6 +2396,22 @@ static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
return gWrapModes[tm];
}
+const GrGLenum* GrGLGpu::GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps) {
+ if (caps.glslCaps()->textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) {
+ if (caps.glslCaps()->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;
+ }
+}
+
void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) {
SkASSERT(texture);
@@ -2462,7 +2478,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,
- GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps()),
+ GetTexParamSwizzle(texture->config(), this->glCaps()),
sizeof(newTexParams.fSwizzleRGBA));
if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) {
this->setTextureUnit(unitIdx);
@@ -2480,7 +2496,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()->textureSwizzleSupport() &&
(setAll || memcmp(newTexParams.fSwizzleRGBA,
oldTexParams.fSwizzleRGBA,
sizeof(newTexParams.fSwizzleRGBA)))) {
@@ -2636,7 +2652,7 @@ bool GrGLGpu::configToGLFormats(GrPixelConfig config,
*internalFormat = GR_GL_PALETTE8_RGBA8;
break;
case kAlpha_8_GrPixelConfig:
- if (this->glCaps().textureRedSupport()) {
+ if (this->glCaps().glslCaps()->textureRedSupport()) {
*internalFormat = GR_GL_RED;
*externalFormat = GR_GL_RED;
if (getSizedInternalFormat) {
@@ -2687,7 +2703,7 @@ bool GrGLGpu::configToGLFormats(GrPixelConfig config,
break;
case kAlpha_half_GrPixelConfig:
- if (this->glCaps().textureRedSupport()) {
+ if (this->glCaps().glslCaps()->textureRedSupport()) {
if (getSizedInternalFormat) {
*internalFormat = GR_GL_R16F;
} else {

Powered by Google App Engine
This is Rietveld 408576698