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

Unified Diff: src/effects/SkArithmeticMode.cpp

Issue 16034013: Remove unpremul/remul from SkArithmeticMode, both raster and GPU, since the SVG spec actually defin… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Put unpremultiply code behind if (false). Created 7 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkArithmeticMode.cpp
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index e9dc7824bca5a1fd96c9578042bf5bc6c1393fc5..4ebce110ea5d918a486465441ad3ae0ab688c512 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -95,44 +95,55 @@ void SkArithmeticMode_scalar::xfer32(SkPMColor dst[], const SkPMColor src[],
if ((NULL == aaCoverage) || aaCoverage[i]) {
SkPMColor sc = src[i];
SkPMColor dc = dst[i];
- int sa = SkGetPackedA32(sc);
- int da = SkGetPackedA32(dc);
-
- int srcNeedsUnpremul = needsUnpremul(sa);
- int dstNeedsUnpremul = needsUnpremul(da);
int a, r, g, b;
- if (!srcNeedsUnpremul && !dstNeedsUnpremul) {
- a = arith(k1, k2, k3, k4, sa, da);
+ if (false) {
+ int sa = SkGetPackedA32(sc);
+ int da = SkGetPackedA32(dc);
+
+ int srcNeedsUnpremul = needsUnpremul(sa);
+ int dstNeedsUnpremul = needsUnpremul(da);
+
+ if (!srcNeedsUnpremul && !dstNeedsUnpremul) {
+ a = arith(k1, k2, k3, k4, sa, da);
+ r = arith(k1, k2, k3, k4, SkGetPackedR32(sc), SkGetPackedR32(dc));
+ g = arith(k1, k2, k3, k4, SkGetPackedG32(sc), SkGetPackedG32(dc));
+ b = arith(k1, k2, k3, k4, SkGetPackedB32(sc), SkGetPackedB32(dc));
+ } else {
+ int sr = SkGetPackedR32(sc);
+ int sg = SkGetPackedG32(sc);
+ int sb = SkGetPackedB32(sc);
+ if (srcNeedsUnpremul) {
+ SkUnPreMultiply::Scale scale = SkUnPreMultiply::GetScale(sa);
+ sr = SkUnPreMultiply::ApplyScale(scale, sr);
+ sg = SkUnPreMultiply::ApplyScale(scale, sg);
+ sb = SkUnPreMultiply::ApplyScale(scale, sb);
+ }
+
+ int dr = SkGetPackedR32(dc);
+ int dg = SkGetPackedG32(dc);
+ int db = SkGetPackedB32(dc);
+ if (dstNeedsUnpremul) {
+ SkUnPreMultiply::Scale scale = SkUnPreMultiply::GetScale(da);
+ dr = SkUnPreMultiply::ApplyScale(scale, dr);
+ dg = SkUnPreMultiply::ApplyScale(scale, dg);
+ db = SkUnPreMultiply::ApplyScale(scale, db);
+ }
+
+ a = arith(k1, k2, k3, k4, sa, da);
+ r = arith(k1, k2, k3, k4, sr, dr);
+ g = arith(k1, k2, k3, k4, sg, dg);
+ b = arith(k1, k2, k3, k4, sb, db);
+ }
+ } else {
+ a = arith(k1, k2, k3, k4, SkGetPackedA32(sc), SkGetPackedA32(dc));
r = arith(k1, k2, k3, k4, SkGetPackedR32(sc), SkGetPackedR32(dc));
+ r = SkMin32(r, a);
g = arith(k1, k2, k3, k4, SkGetPackedG32(sc), SkGetPackedG32(dc));
+ g = SkMin32(g, a);
b = arith(k1, k2, k3, k4, SkGetPackedB32(sc), SkGetPackedB32(dc));
- } else {
- int sr = SkGetPackedR32(sc);
- int sg = SkGetPackedG32(sc);
- int sb = SkGetPackedB32(sc);
- if (srcNeedsUnpremul) {
- SkUnPreMultiply::Scale scale = SkUnPreMultiply::GetScale(sa);
- sr = SkUnPreMultiply::ApplyScale(scale, sr);
- sg = SkUnPreMultiply::ApplyScale(scale, sg);
- sb = SkUnPreMultiply::ApplyScale(scale, sb);
- }
-
- int dr = SkGetPackedR32(dc);
- int dg = SkGetPackedG32(dc);
- int db = SkGetPackedB32(dc);
- if (dstNeedsUnpremul) {
- SkUnPreMultiply::Scale scale = SkUnPreMultiply::GetScale(da);
- dr = SkUnPreMultiply::ApplyScale(scale, dr);
- dg = SkUnPreMultiply::ApplyScale(scale, dg);
- db = SkUnPreMultiply::ApplyScale(scale, db);
- }
-
- a = arith(k1, k2, k3, k4, sa, da);
- r = arith(k1, k2, k3, k4, sr, dr);
- g = arith(k1, k2, k3, k4, sg, dg);
- b = arith(k1, k2, k3, k4, sb, db);
+ b = SkMin32(b, a);
}
// apply antialias coverage if necessary
@@ -145,7 +156,7 @@ void SkArithmeticMode_scalar::xfer32(SkPMColor dst[], const SkPMColor src[],
}
// turn the result back into premul
- if (0xFF != a) {
+ if (false /* 0xFF != a */) {
int scale = a + (a >> 7);
r = SkAlphaMul(r, scale);
g = SkAlphaMul(g, scale);
@@ -361,15 +372,23 @@ void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\tconst vec4 src = %s;\n", GrGLSLOnesVecf(4));
} else {
builder->fsCodeAppendf("\t\tvec4 src = %s;\n", inputColor);
- builder->fsCodeAppendf("\t\tsrc.rgb = clamp(src.rgb / src.a, 0.0, 1.0);\n");
+ if (false) {
+ builder->fsCodeAppendf("\t\tsrc.rgb = clamp(src.rgb / src.a, 0.0, 1.0);\n");
+ }
}
builder->fsCodeAppendf("\t\tvec4 dst = %s;\n", dstColor);
- builder->fsCodeAppendf("\t\tdst.rgb = clamp(dst.rgb / dst.a, 0.0, 1.0);\n");
+ if (false) {
+ builder->fsCodeAppendf("\t\tdst.rgb = clamp(dst.rgb / dst.a, 0.0, 1.0);\n");
+ }
builder->fsCodeAppendf("\t\t%s = %s.x * src * dst + %s.y * src + %s.z * dst + %s.w;\n", outputColor, kUni, kUni, kUni, kUni);
builder->fsCodeAppendf("\t\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outputColor);
- builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
+ if (false) {
+ builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
+ } else {
+ builder->fsCodeAppendf("\t\t%s.rgb = min(%s.rgb, %s.a);\n", outputColor, outputColor, outputColor);
+ }
}
void GrGLArithmeticEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698