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

Side by Side Diff: src/core/SkXfermode.cpp

Issue 1061603002: Code's more readable when SkPMFloat is an Sk4f. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix neon Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Sk4f s4 = src; 1239 return check_as_pmfloat(dst + (src * Sk4f(dst.a()) - dst * Sk4f(src.a()) ) * inv255);
1240 Sk4f d4 = dst;
1241 return check_as_pmfloat(d4 + (s4 * Sk4f(dst.a()) - d4 * Sk4f(src.a())) * inv255);
1242 } 1240 }
1243 static const bool kFoldCoverageIntoSrcAlpha = true; 1241 static const bool kFoldCoverageIntoSrcAlpha = true;
1244 static const SkXfermode::Mode kMode = SkXfermode::kSrcATop_Mode; 1242 static const SkXfermode::Mode kMode = SkXfermode::kSrcATop_Mode;
1245 }; 1243 };
1246 1244
1247 // kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)] 1245 // kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)]
1248 struct DstATop4f { 1246 struct DstATop4f {
1249 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { 1247 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
1250 const Sk4f inv255(gInv255); 1248 const Sk4f inv255(gInv255);
1251 Sk4f s4 = src; 1249 return check_as_pmfloat(src + (dst * Sk4f(src.a()) - src * Sk4f(dst.a()) ) * inv255);
1252 Sk4f d4 = dst;
1253 return check_as_pmfloat(s4 + (d4 * Sk4f(src.a()) - s4 * Sk4f(dst.a())) * inv255);
1254 } 1250 }
1255 static const bool kFoldCoverageIntoSrcAlpha = false; 1251 static const bool kFoldCoverageIntoSrcAlpha = false;
1256 static const SkXfermode::Mode kMode = SkXfermode::kDstATop_Mode; 1252 static const SkXfermode::Mode kMode = SkXfermode::kDstATop_Mode;
1257 }; 1253 };
1258 1254
1259 // kXor_Mode [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] 1255 // kXor_Mode [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
1260 struct Xor4f { 1256 struct Xor4f {
1261 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { 1257 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
1262 const Sk4f inv255(gInv255); 1258 const Sk4f inv255(gInv255);
1263 Sk4f s4 = src; 1259 return check_as_pmfloat(src + dst - (src * Sk4f(dst.a()) + dst * Sk4f(sr c.a())) * inv255);
1264 Sk4f d4 = dst;
1265 return check_as_pmfloat(s4 + d4 - (s4 * Sk4f(dst.a()) + d4 * Sk4f(src.a( ))) * inv255);
1266 } 1260 }
1267 static const bool kFoldCoverageIntoSrcAlpha = true; 1261 static const bool kFoldCoverageIntoSrcAlpha = true;
1268 static const SkXfermode::Mode kMode = SkXfermode::kXor_Mode; 1262 static const SkXfermode::Mode kMode = SkXfermode::kXor_Mode;
1269 }; 1263 };
1270 1264
1271 // kPlus_Mode [Sa + Da, Sc + Dc] 1265 // kPlus_Mode [Sa + Da, Sc + Dc]
1272 struct Plus4f { 1266 struct Plus4f {
1273 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { 1267 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
1274 Sk4f s4 = src; 1268 return check_as_pmfloat(clamp_255(src + dst));
1275 Sk4f d4 = dst;
1276 return check_as_pmfloat(clamp_255(s4 + d4));
1277 } 1269 }
1278 static const bool kFoldCoverageIntoSrcAlpha = true; 1270 static const bool kFoldCoverageIntoSrcAlpha = true;
1279 static const SkXfermode::Mode kMode = SkXfermode::kPlus_Mode; 1271 static const SkXfermode::Mode kMode = SkXfermode::kPlus_Mode;
1280 }; 1272 };
1281 1273
1282 // kModulate_Mode [Sa * Da, Sc * Dc] 1274 // kModulate_Mode [Sa * Da, Sc * Dc]
1283 struct Modulate4f { 1275 struct Modulate4f {
1284 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { 1276 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
1285 const Sk4f inv255(gInv255); 1277 const Sk4f inv255(gInv255);
1286 Sk4f s4 = src; 1278 return check_as_pmfloat(src * dst * inv255);
1287 Sk4f d4 = dst;
1288 return check_as_pmfloat(s4 * d4 * inv255);
1289 } 1279 }
1290 static const bool kFoldCoverageIntoSrcAlpha = false; 1280 static const bool kFoldCoverageIntoSrcAlpha = false;
1291 static const SkXfermode::Mode kMode = SkXfermode::kModulate_Mode; 1281 static const SkXfermode::Mode kMode = SkXfermode::kModulate_Mode;
1292 }; 1282 };
1293 1283
1294 // kScreen_Mode [S + D - S * D] 1284 // kScreen_Mode [S + D - S * D]
1295 struct Screen4f { 1285 struct Screen4f {
1296 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { 1286 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
1297 const Sk4f inv255(gInv255); 1287 const Sk4f inv255(gInv255);
1298 Sk4f s4 = src; 1288 return check_as_pmfloat(src + dst - src * dst * inv255);
1299 Sk4f d4 = dst;
1300 return check_as_pmfloat(s4 + d4 - s4 * d4 * inv255);
1301 } 1289 }
1302 static const bool kFoldCoverageIntoSrcAlpha = true; 1290 static const bool kFoldCoverageIntoSrcAlpha = true;
1303 static const SkXfermode::Mode kMode = SkXfermode::kScreen_Mode; 1291 static const SkXfermode::Mode kMode = SkXfermode::kScreen_Mode;
1304 }; 1292 };
1305 1293
1306 struct Multiply4f { 1294 struct Multiply4f {
1307 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) { 1295 static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
1308 const Sk4f inv255(gInv255); 1296 const Sk4f inv255(gInv255);
1309 Sk4f sa = Sk4f(src.a()); 1297 Sk4f sa = Sk4f(src.a());
1310 Sk4f da = Sk4f(dst.a()); 1298 Sk4f da = Sk4f(dst.a());
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 } else { 1773 } else {
1786 proc16 = rec.fProc16_General; 1774 proc16 = rec.fProc16_General;
1787 } 1775 }
1788 } 1776 }
1789 return proc16; 1777 return proc16;
1790 } 1778 }
1791 1779
1792 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1780 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1793 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1781 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1794 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1782 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698