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

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

Issue 1820313002: Port S32A_opaque blit row to SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fmt Created 4 years, 9 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
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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #else 45 #else
46 do { 46 do {
47 *dst = SkAlphaMulQ(*src, src_scale) + SkAlphaMulQ(*dst, dst_scale); 47 *dst = SkAlphaMulQ(*src, src_scale) + SkAlphaMulQ(*dst, dst_scale);
48 src += 1; 48 src += 1;
49 dst += 1; 49 dst += 1;
50 } while (--count > 0); 50 } while (--count > 0);
51 #endif 51 #endif
52 } 52 }
53 } 53 }
54 54
55 static void S32A_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst,
56 const SkPMColor* SK_RESTRICT src,
57 int count, U8CPU alpha) {
58 SkASSERT(255 == alpha);
59 if (count > 0) {
60 #ifdef UNROLL
61 if (count & 1) {
62 *dst = SkPMSrcOver(*(src++), *dst);
63 dst += 1;
64 count -= 1;
65 }
66
67 const SkPMColor* SK_RESTRICT srcEnd = src + count;
68 while (src != srcEnd) {
69 *dst = SkPMSrcOver(*(src++), *dst);
70 dst += 1;
71 *dst = SkPMSrcOver(*(src++), *dst);
72 dst += 1;
73 }
74 #else
75 do {
76 *dst = SkPMSrcOver(*src, *dst);
77 src += 1;
78 dst += 1;
79 } while (--count > 0);
80 #endif
81 }
82 }
83
84 static void S32A_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst, 55 static void S32A_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst,
85 const SkPMColor* SK_RESTRICT src, 56 const SkPMColor* SK_RESTRICT src,
86 int count, U8CPU alpha) { 57 int count, U8CPU alpha) {
87 SkASSERT(alpha <= 255); 58 SkASSERT(alpha <= 255);
88 if (count > 0) { 59 if (count > 0) {
89 #ifdef UNROLL 60 #ifdef UNROLL
90 if (count & 1) { 61 if (count & 1) {
91 *dst = SkBlendARGB32(*(src++), *dst, alpha); 62 *dst = SkBlendARGB32(*(src++), *dst, alpha);
92 dst += 1; 63 dst += 1;
93 count -= 1; 64 count -= 1;
(...skipping 14 matching lines...) Expand all
108 } while (--count > 0); 79 } while (--count > 0);
109 #endif 80 #endif
110 } 81 }
111 } 82 }
112 83
113 /////////////////////////////////////////////////////////////////////////////// 84 ///////////////////////////////////////////////////////////////////////////////
114 85
115 static const SkBlitRow::Proc32 gDefault_Procs32[] = { 86 static const SkBlitRow::Proc32 gDefault_Procs32[] = {
116 S32_Opaque_BlitRow32, 87 S32_Opaque_BlitRow32,
117 S32_Blend_BlitRow32, 88 S32_Blend_BlitRow32,
118 S32A_Opaque_BlitRow32, 89 nullptr,
119 S32A_Blend_BlitRow32 90 S32A_Blend_BlitRow32
120 }; 91 };
121 92
122 SkBlitRow::Proc32 SkBlitRow::Factory32(unsigned flags) { 93 SkBlitRow::Proc32 SkBlitRow::Factory32(unsigned flags) {
123 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_Procs32)); 94 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_Procs32));
124 // just so we don't crash 95 // just so we don't crash
125 flags &= kFlags32_Mask; 96 flags &= kFlags32_Mask;
126 97
98 if (flags == 2) {
99 // S32A_Opaque_BlitRow32 has been ported to SkOpts, but not the others y et.
100 return SkOpts::blit_row_s32a_opaque;
101 }
102
127 SkBlitRow::Proc32 proc = PlatformProcs32(flags); 103 SkBlitRow::Proc32 proc = PlatformProcs32(flags);
128 if (nullptr == proc) { 104 if (nullptr == proc) {
129 proc = gDefault_Procs32[flags]; 105 proc = gDefault_Procs32[flags];
130 } 106 }
131 SkASSERT(proc); 107 SkASSERT(proc);
132 return proc; 108 return proc;
133 } 109 }
134 110
135 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC olor color) { 111 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC olor color) {
136 switch (SkGetPackedA32(color)) { 112 switch (SkGetPackedA32(color)) {
137 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; 113 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return;
138 case 255: sk_memset32(dst, color, count); return; 114 case 255: sk_memset32(dst, color, count); return;
139 } 115 }
140 return SkOpts::blit_row_color32(dst, src, count, color); 116 return SkOpts::blit_row_color32(dst, src, count, color);
141 } 117 }
OLDNEW
« no previous file with comments | « gyp/opts.gypi ('k') | src/core/SkOpts.h » ('j') | src/opts/SkOpts_sse41.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698