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

Side by Side Diff: src/opts/SkBlitMask_opts.h

Issue 1278253003: Sk4px blit mask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: note overflow Created 5 years, 4 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/SkBlitMask_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 SkBlitMask_opts_DEFINED
9 #define SkBlitMask_opts_DEFINED
10
11 #include "Sk4px.h"
12
13 namespace SK_OPTS_NS {
14
15 static void blit_mask_d32_a8(SkPMColor* dst, size_t dstRB,
16 const SkAlpha* mask, size_t maskRB,
17 SkColor color, int w, int h) {
18 auto s = Sk4px::DupPMColor(SkPreMultiplyColor(color));
19
20 auto fn = [&](const Sk4px& d, const Sk4px& aa) {
21 // = (s + d(1-sa))aa + d(1-aa)
22 // = s*aa + d(1-sa*aa)
23 auto left = s.approxMulDiv255(aa),
24 right = d.approxMulDiv255(left.alphas().inv());
25 return left + right; // This does not overflow (exhaustively checked).
26 };
27
28 while (h --> 0) {
29 Sk4px::MapDstAlpha(w, dst, mask, fn);
30 dst += dstRB / sizeof(*dst);
31 mask += maskRB / sizeof(*mask);
32 }
33 }
34
35 } // SK_OPTS_NS
36
37 #endif//SkBlitMask_opts_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkOpts.cpp ('k') | src/opts/SkBlitMask_opts_arm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698