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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/core/SkOpts.cpp ('k') | src/opts/SkBlitRow_opts_arm.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkBlitRow_opts_DEFINED
9 #define SkBlitRow_opts_DEFINED
10
11 #include "Sk4px.h"
12
13 namespace SK_OPTS_NS {
14
15 // Color32 uses the blend_256_round_alt algorithm from tests/BlendTest.cpp.
16 // It's not quite perfect, but it's never wrong in the interesting edge cases,
17 // and it's quite a bit faster than blend_perfect.
18 //
19 // blend_256_round_alt is our currently blessed algorithm. Please use it or an analogous one.
20 static void blit_row_color32(SkPMColor* dst, const SkPMColor* src, int count, Sk PMColor color) {
21 unsigned invA = 255 - SkGetPackedA32(color);
22 invA += invA >> 7;
23 SkASSERT(invA < 256); // We've should have already handled alpha == 0 exter nally.
24
25 Sk16h colorHighAndRound = Sk4px::DupPMColor(color).widenHi() + Sk16h(128);
26 Sk16b invA_16x(invA);
27
28 Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px {
29 return (src4 * invA_16x).addNarrowHi(colorHighAndRound);
30 });
31 }
32
33 } // SK_OPTS_NS
34
35 #endif//SkBlitRow_opts_DEFINED
OLDNEW
« 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