Omit shader swizzle if it is rgba.
R=robertphilips@google.com
Review URL: https://codereview.appspot.com/6585082
git-svn-id: http://skia.googlecode.com/svn/trunk@5804 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index 43bd1b4..473c7b4 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -66,7 +66,10 @@
mangledSwizzle[i] ='\0';
swizzle = mangledSwizzle;
}
- outAppend->appendf(".%s", swizzle);
+ // For shader prettiness we omit the swizzle rather than appending ".rgba".
+ if (memcmp(swizzle, "rgba", 4)) {
+ outAppend->appendf(".%s", swizzle);
+ }
}
}
@@ -157,14 +160,17 @@
if (!caps.textureSwizzleSupport() && swizzle_requires_alpha_remapping(caps, access)) {
key = 1;
}
- #if GR_DEBUG
- // Assert that key is set iff the swizzle will be modified.
- SkString origString(access.getSwizzle());
- origString.prepend(".");
- SkString modifiedString;
- append_swizzle(&modifiedString, access, caps);
- GrAssert(SkToBool(key) == (modifiedString != origString));
- #endif
+#if GR_DEBUG
+ // Assert that key is set iff the swizzle will be modified.
+ SkString origString(access.getSwizzle());
+ origString.prepend(".");
+ SkString modifiedString;
+ append_swizzle(&modifiedString, access, caps);
+ if (!modifiedString.size()) {
+ modifiedString = ".rgba";
+ }
+ GrAssert(SkToBool(key) == (modifiedString != origString));
+#endif
return key;
}