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

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

Issue 2097883002: revise row blits to keep intermediate precision so that color is preserved when blended against its… (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: guard more changes with SK_SUPPORT_LEGACY_BROKEN_LERP Created 4 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/SkBlitRow_D16.cpp ('k') | src/core/SkBlitter_A8.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBlitRow.h" 8 #include "SkBlitRow.h"
9 #include "SkBlitMask.h" 9 #include "SkBlitMask.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkOpts.h" 11 #include "SkOpts.h"
12 #include "SkUtils.h" 12 #include "SkUtils.h"
13 13
14 #define UNROLL 14 #define UNROLL
15 15
16 static void S32_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst, 16 static void S32_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst,
17 const SkPMColor* SK_RESTRICT src, 17 const SkPMColor* SK_RESTRICT src,
18 int count, U8CPU alpha) { 18 int count, U8CPU alpha) {
19 SkASSERT(255 == alpha); 19 SkASSERT(255 == alpha);
20 memcpy(dst, src, count * 4); 20 memcpy(dst, src, count * 4);
21 } 21 }
22 22
23 static void S32_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst, 23 static void S32_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst,
24 const SkPMColor* SK_RESTRICT src, 24 const SkPMColor* SK_RESTRICT src,
25 int count, U8CPU alpha) { 25 int count, U8CPU alpha) {
26 SkASSERT(alpha <= 255); 26 SkASSERT(alpha <= 255);
27 if (count > 0) { 27 if (count > 0) {
28 unsigned src_scale = SkAlpha255To256(alpha); 28 unsigned src_scale = SkAlpha255To256(alpha);
29 unsigned dst_scale = 256 - src_scale;
30 29
31 #ifdef UNROLL 30 #ifdef UNROLL
32 if (count & 1) { 31 if (count & 1) {
33 *dst = SkAlphaMulQ(*(src++), src_scale) + SkAlphaMulQ(*dst, dst_scal e); 32 *dst = SkPMLerp(*src, *dst, src_scale);
33 src += 1;
34 dst += 1; 34 dst += 1;
35 count -= 1; 35 count -= 1;
36 } 36 }
37 37
38 const SkPMColor* SK_RESTRICT srcEnd = src + count; 38 const SkPMColor* SK_RESTRICT srcEnd = src + count;
39 while (src != srcEnd) { 39 while (src != srcEnd) {
40 *dst = SkAlphaMulQ(*(src++), src_scale) + SkAlphaMulQ(*dst, dst_scal e); 40 *dst = SkPMLerp(*src, *dst, src_scale);
41 src += 1;
41 dst += 1; 42 dst += 1;
42 *dst = SkAlphaMulQ(*(src++), src_scale) + SkAlphaMulQ(*dst, dst_scal e); 43 *dst = SkPMLerp(*src, *dst, src_scale);
44 src += 1;
43 dst += 1; 45 dst += 1;
44 } 46 }
45 #else 47 #else
46 do { 48 do {
47 *dst = SkAlphaMulQ(*src, src_scale) + SkAlphaMulQ(*dst, dst_scale); 49 *dst = SkPMLerp(*src, *dst, src_scale);
48 src += 1; 50 src += 1;
49 dst += 1; 51 dst += 1;
50 } while (--count > 0); 52 } while (--count > 0);
51 #endif 53 #endif
52 } 54 }
53 } 55 }
54 56
55 static void S32A_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst, 57 static void S32A_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst,
56 const SkPMColor* SK_RESTRICT src, 58 const SkPMColor* SK_RESTRICT src,
57 int count, U8CPU alpha) { 59 int count, U8CPU alpha) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return proc; 110 return proc;
109 } 111 }
110 112
111 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC olor color) { 113 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC olor color) {
112 switch (SkGetPackedA32(color)) { 114 switch (SkGetPackedA32(color)) {
113 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; 115 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return;
114 case 255: sk_memset32(dst, color, count); return; 116 case 255: sk_memset32(dst, color, count); return;
115 } 117 }
116 return SkOpts::blit_row_color32(dst, src, count, color); 118 return SkOpts::blit_row_color32(dst, src, count, color);
117 } 119 }
OLDNEW
« no previous file with comments | « src/core/SkBlitRow_D16.cpp ('k') | src/core/SkBlitter_A8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698