OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkXfermode.h" | 9 #include "SkXfermode.h" |
10 #include "SkXfermode_opts_SSE2.h" | 10 #include "SkXfermode_opts_SSE2.h" |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 #ifdef SK_DEBUG | 1229 #ifdef SK_DEBUG |
1230 (void)pm.round(); | 1230 (void)pm.round(); |
1231 #endif | 1231 #endif |
1232 return pm; | 1232 return pm; |
1233 } | 1233 } |
1234 | 1234 |
1235 // kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc] | 1235 // kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc] |
1236 struct SrcATop4f { | 1236 struct SrcATop4f { |
1237 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1237 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1238 const Sk4f inv255(gInv255); | 1238 const Sk4f inv255(gInv255); |
1239 return check_as_pmfloat(dst + (src * Sk4f(dst.a()) - dst * Sk4f(src.a())
) * inv255); | 1239 Sk4f s4 = src; |
| 1240 Sk4f d4 = dst; |
| 1241 return check_as_pmfloat(d4 + (s4 * Sk4f(dst.a()) - d4 * Sk4f(src.a())) *
inv255); |
1240 } | 1242 } |
1241 static const bool kFoldCoverageIntoSrcAlpha = true; | 1243 static const bool kFoldCoverageIntoSrcAlpha = true; |
1242 static const SkXfermode::Mode kMode = SkXfermode::kSrcATop_Mode; | 1244 static const SkXfermode::Mode kMode = SkXfermode::kSrcATop_Mode; |
1243 }; | 1245 }; |
1244 | 1246 |
1245 // kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)] | 1247 // kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)] |
1246 struct DstATop4f { | 1248 struct DstATop4f { |
1247 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1249 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1248 const Sk4f inv255(gInv255); | 1250 const Sk4f inv255(gInv255); |
1249 return check_as_pmfloat(src + (dst * Sk4f(src.a()) - src * Sk4f(dst.a())
) * inv255); | 1251 Sk4f s4 = src; |
| 1252 Sk4f d4 = dst; |
| 1253 return check_as_pmfloat(s4 + (d4 * Sk4f(src.a()) - s4 * Sk4f(dst.a())) *
inv255); |
1250 } | 1254 } |
1251 static const bool kFoldCoverageIntoSrcAlpha = false; | 1255 static const bool kFoldCoverageIntoSrcAlpha = false; |
1252 static const SkXfermode::Mode kMode = SkXfermode::kDstATop_Mode; | 1256 static const SkXfermode::Mode kMode = SkXfermode::kDstATop_Mode; |
1253 }; | 1257 }; |
1254 | 1258 |
1255 // kXor_Mode [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] | 1259 // kXor_Mode [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] |
1256 struct Xor4f { | 1260 struct Xor4f { |
1257 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1261 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1258 const Sk4f inv255(gInv255); | 1262 const Sk4f inv255(gInv255); |
1259 return check_as_pmfloat(src + dst - (src * Sk4f(dst.a()) + dst * Sk4f(sr
c.a())) * inv255); | 1263 Sk4f s4 = src; |
| 1264 Sk4f d4 = dst; |
| 1265 return check_as_pmfloat(s4 + d4 - (s4 * Sk4f(dst.a()) + d4 * Sk4f(src.a(
))) * inv255); |
1260 } | 1266 } |
1261 static const bool kFoldCoverageIntoSrcAlpha = true; | 1267 static const bool kFoldCoverageIntoSrcAlpha = true; |
1262 static const SkXfermode::Mode kMode = SkXfermode::kXor_Mode; | 1268 static const SkXfermode::Mode kMode = SkXfermode::kXor_Mode; |
1263 }; | 1269 }; |
1264 | 1270 |
1265 // kPlus_Mode [Sa + Da, Sc + Dc] | 1271 // kPlus_Mode [Sa + Da, Sc + Dc] |
1266 struct Plus4f { | 1272 struct Plus4f { |
1267 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1273 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1268 return check_as_pmfloat(clamp_255(src + dst)); | 1274 Sk4f s4 = src; |
| 1275 Sk4f d4 = dst; |
| 1276 return check_as_pmfloat(clamp_255(s4 + d4)); |
1269 } | 1277 } |
1270 static const bool kFoldCoverageIntoSrcAlpha = true; | 1278 static const bool kFoldCoverageIntoSrcAlpha = true; |
1271 static const SkXfermode::Mode kMode = SkXfermode::kPlus_Mode; | 1279 static const SkXfermode::Mode kMode = SkXfermode::kPlus_Mode; |
1272 }; | 1280 }; |
1273 | 1281 |
1274 // kModulate_Mode [Sa * Da, Sc * Dc] | 1282 // kModulate_Mode [Sa * Da, Sc * Dc] |
1275 struct Modulate4f { | 1283 struct Modulate4f { |
1276 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1284 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1277 const Sk4f inv255(gInv255); | 1285 const Sk4f inv255(gInv255); |
1278 return check_as_pmfloat(src * dst * inv255); | 1286 Sk4f s4 = src; |
| 1287 Sk4f d4 = dst; |
| 1288 return check_as_pmfloat(s4 * d4 * inv255); |
1279 } | 1289 } |
1280 static const bool kFoldCoverageIntoSrcAlpha = false; | 1290 static const bool kFoldCoverageIntoSrcAlpha = false; |
1281 static const SkXfermode::Mode kMode = SkXfermode::kModulate_Mode; | 1291 static const SkXfermode::Mode kMode = SkXfermode::kModulate_Mode; |
1282 }; | 1292 }; |
1283 | 1293 |
1284 // kScreen_Mode [S + D - S * D] | 1294 // kScreen_Mode [S + D - S * D] |
1285 struct Screen4f { | 1295 struct Screen4f { |
1286 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1296 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1287 const Sk4f inv255(gInv255); | 1297 const Sk4f inv255(gInv255); |
1288 return check_as_pmfloat(src + dst - src * dst * inv255); | 1298 Sk4f s4 = src; |
| 1299 Sk4f d4 = dst; |
| 1300 return check_as_pmfloat(s4 + d4 - s4 * d4 * inv255); |
1289 } | 1301 } |
1290 static const bool kFoldCoverageIntoSrcAlpha = true; | 1302 static const bool kFoldCoverageIntoSrcAlpha = true; |
1291 static const SkXfermode::Mode kMode = SkXfermode::kScreen_Mode; | 1303 static const SkXfermode::Mode kMode = SkXfermode::kScreen_Mode; |
1292 }; | 1304 }; |
1293 | 1305 |
1294 struct Multiply4f { | 1306 struct Multiply4f { |
1295 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { | 1307 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { |
1296 const Sk4f inv255(gInv255); | 1308 const Sk4f inv255(gInv255); |
1297 Sk4f sa = Sk4f(src.a()); | 1309 Sk4f sa = Sk4f(src.a()); |
1298 Sk4f da = Sk4f(dst.a()); | 1310 Sk4f da = Sk4f(dst.a()); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 } else { | 1785 } else { |
1774 proc16 = rec.fProc16_General; | 1786 proc16 = rec.fProc16_General; |
1775 } | 1787 } |
1776 } | 1788 } |
1777 return proc16; | 1789 return proc16; |
1778 } | 1790 } |
1779 | 1791 |
1780 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1792 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1781 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1793 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1782 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1794 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |