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

Unified Diff: src/opts/SkBlitRow_opts.h

Issue 1314863006: Port SkBlitRow::Color32 to SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « src/core/SkOpts.cpp ('k') | src/opts/SkBlitRow_opts_arm.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkBlitRow_opts.h
diff --git a/src/opts/SkBlitRow_opts.h b/src/opts/SkBlitRow_opts.h
new file mode 100644
index 0000000000000000000000000000000000000000..f000f30fd09bd40448cb1a80af10c0b767da8c8c
--- /dev/null
+++ b/src/opts/SkBlitRow_opts.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBlitRow_opts_DEFINED
+#define SkBlitRow_opts_DEFINED
+
+#include "Sk4px.h"
+
+namespace SK_OPTS_NS {
+
+// Color32 uses the blend_256_round_alt algorithm from tests/BlendTest.cpp.
+// It's not quite perfect, but it's never wrong in the interesting edge cases,
+// and it's quite a bit faster than blend_perfect.
+//
+// blend_256_round_alt is our currently blessed algorithm. Please use it or an analogous one.
+static void blit_row_color32(SkPMColor* dst, const SkPMColor* src, int count, SkPMColor color) {
+ unsigned invA = 255 - SkGetPackedA32(color);
+ invA += invA >> 7;
+ SkASSERT(invA < 256); // We've should have already handled alpha == 0 externally.
+
+ Sk16h colorHighAndRound = Sk4px::DupPMColor(color).widenHi() + Sk16h(128);
+ Sk16b invA_16x(invA);
+
+ Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px {
+ return (src4 * invA_16x).addNarrowHi(colorHighAndRound);
+ });
+}
+
+} // SK_OPTS_NS
+
+#endif//SkBlitRow_opts_DEFINED
« no previous file with comments | « src/core/SkOpts.cpp ('k') | src/opts/SkBlitRow_opts_arm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698