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
This commit is contained in:
bsalomon@google.com 2012-10-04 13:26:32 +00:00
Родитель c7e4a5a02a
Коммит 73d5b2f620
1 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -66,7 +66,10 @@ void append_swizzle(SkString* outAppend,
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 @@ GrCustomStage::StageKey GrGLShaderBuilder::KeyForTextureAccess(const GrTextureAc
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;
}