From: mtklein Date: Wed, 12 Aug 2015 20:51:27 +0000 (-0700) Subject: Revert of Normalize SkXfermode_opts.h argument order as d,s[,aa]. (patchset #1 id... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~1292 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0010945335b497ee08ef12e1ce862ff2fefb8e01;p=platform%2Fupstream%2FlibSkiaSharp.git Revert of Normalize SkXfermode_opts.h argument order as d,s[,aa]. (patchset #1 id:1 of https://codereview.chromium.org/1289903002/ ) Reason for revert: ? Original issue's description: > Normalize SkXfermode_opts.h argument order as d,s[,aa]. > > At head they're s,d[,aa] in SkXfermode_opts.h but Sk4px::Map* expect d,s[,aa] > so we ended up having to write weird little lambda shims to match impedance. > > There's no reason for these to disagree, and d,s[,aa] is the One True Order > (because no matter what you're doing in graphics, there's always a dst). > > Should be no perf or image diff, though I'm suspicious it might help MSVC code generation. > > BUG=skia:4117 > > Committed: https://skia.googlesource.com/skia/+/6028a8476504022fe40b6870b1460b5e4a80969f TBR=djsollen@google.com,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:4117 Review URL: https://codereview.chromium.org/1284363002 --- diff --git a/src/opts/SkXfermode_opts.h b/src/opts/SkXfermode_opts.h index c11f6c0..e5ca257 100644 --- a/src/opts/SkXfermode_opts.h +++ b/src/opts/SkXfermode_opts.h @@ -15,7 +15,7 @@ namespace /* TODO: SK_OPTS_NS */ { // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit fixed point. -#define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px d, Sk4px s) +#define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d) XFERMODE(Clear) { return Sk4px::DupPMColor(0); } XFERMODE(Src) { return s; } @@ -23,13 +23,13 @@ XFERMODE(Dst) { return d; } XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); } XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); } XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); } -XFERMODE(DstIn) { return SrcIn (s,d); } -XFERMODE(DstOut) { return SrcOut (s,d); } -XFERMODE(DstOver) { return SrcOver(s,d); } +XFERMODE(DstIn) { return SrcIn (d,s); } +XFERMODE(DstOut) { return SrcOut (d,s); } +XFERMODE(DstOver) { return SrcOver(d,s); } // [ S * Da + (1 - Sa) * D] XFERMODE(SrcATop) { return (s * d.alphas() + d * s.alphas().inv()).div255(); } -XFERMODE(DstATop) { return SrcATop(s,d); } +XFERMODE(DstATop) { return SrcATop(d,s); } //[ S * (1 - Da) + (1 - Sa) * D ] XFERMODE(Xor) { return (s * d.alphas().inv() + d * s.alphas().inv()).div255(); } // [S + D ] @@ -79,7 +79,7 @@ XFERMODE(HardLight) { auto colors = (both + isLite.thenElse(lite, dark)).div255(); return alphas.zeroColors() + colors.zeroAlphas(); } -XFERMODE(Overlay) { return HardLight(s,d); } +XFERMODE(Overlay) { return HardLight(d,s); } XFERMODE(Darken) { auto sa = s.alphas(), @@ -110,7 +110,7 @@ XFERMODE(Lighten) { #undef XFERMODE // Some xfermodes use math like divide or sqrt that's best done in floats 1 pixel at a time. -#define XFERMODE(Name) static SkPMFloat SK_VECTORCALL Name(SkPMFloat d, SkPMFloat s) +#define XFERMODE(Name) static SkPMFloat SK_VECTORCALL Name(SkPMFloat s, SkPMFloat d) XFERMODE(ColorDodge) { auto sa = s.alphas(), @@ -174,14 +174,14 @@ XFERMODE(SoftLight) { // A reasonable fallback mode for doing AA is to simply apply the transfermode first, // then linearly interpolate the AA. template -static Sk4px SK_VECTORCALL xfer_aa(Sk4px d, Sk4px s, Sk4px aa) { - Sk4px bw = Mode(d, s); +static Sk4px SK_VECTORCALL xfer_aa(Sk4px s, Sk4px d, Sk4px aa) { + Sk4px bw = Mode(s, d); return (bw * aa + d * aa.inv()).div255(); } // For some transfermodes we specialize AA, either for correctness or performance. #define XFERMODE_AA(Name) \ - template <> Sk4px SK_VECTORCALL xfer_aa(Sk4px d, Sk4px s, Sk4px aa) + template <> Sk4px SK_VECTORCALL xfer_aa(Sk4px s, Sk4px d, Sk4px aa) // Plus' clamp needs to happen after AA. skia:3852 XFERMODE_AA(Plus) { // [ clamp( (1-AA)D + (AA)(S+D) ) == clamp(D + AA*S) ] @@ -202,17 +202,27 @@ public: void xfer32(SkPMColor dst[], const SkPMColor src[], int n, const SkAlpha aa[]) const override { if (NULL == aa) { - Sk4px::MapDstSrc(n, dst, src, fProc4); + Sk4px::MapDstSrc(n, dst, src, [&](const Sk4px& dst4, const Sk4px& src4) { + return fProc4(src4, dst4); + }); } else { - Sk4px::MapDstSrcAlpha(n, dst, src, aa, fAAProc4); + Sk4px::MapDstSrcAlpha(n, dst, src, aa, + [&](const Sk4px& dst4, const Sk4px& src4, const Sk4px& alpha) { + return fAAProc4(src4, dst4, alpha); + }); } } void xfer16(uint16_t dst[], const SkPMColor src[], int n, const SkAlpha aa[]) const override { if (NULL == aa) { - Sk4px::MapDstSrc(n, dst, src, fProc4); + Sk4px::MapDstSrc(n, dst, src, [&](const Sk4px& dst4, const Sk4px& src4) { + return fProc4(src4, dst4); + }); } else { - Sk4px::MapDstSrcAlpha(n, dst, src, aa, fAAProc4); + Sk4px::MapDstSrcAlpha(n, dst, src, aa, + [&](const Sk4px& dst4, const Sk4px& src4, const Sk4px& alpha) { + return fAAProc4(src4, dst4, alpha); + }); } } @@ -247,13 +257,13 @@ public: private: inline SkPMColor xfer32(SkPMColor dst, SkPMColor src) const { - return fProcF(SkPMFloat(dst), SkPMFloat(src)).round(); + return fProcF(SkPMFloat(src), SkPMFloat(dst)).round(); } inline SkPMColor xfer32(SkPMColor dst, SkPMColor src, SkAlpha aa) const { SkPMFloat s(src), d(dst), - b(fProcF(d,s)); + b(fProcF(s,d)); // We do aa in full float precision before going back down to bytes, because we can! SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255); b = b*a + d*(Sk4f(1)-a);