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

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

Issue 892623002: Add SSE optimization of Color32A_D565 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | src/opts/SkBlitRow_opts_SSE4.h » ('j') | src/opts/SkBlitRow_opts_SSE4.cpp » ('J')
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 "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkDither.h" 10 #include "SkDither.h"
11 #include "SkMathPriv.h" 11 #include "SkMathPriv.h"
12 #include "SkUtils.h"
12 13
13 /////////////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////////////
14 15
15 static void S32_D565_Opaque(uint16_t* SK_RESTRICT dst, 16 static void S32_D565_Opaque(uint16_t* SK_RESTRICT dst,
16 const SkPMColor* SK_RESTRICT src, int count, 17 const SkPMColor* SK_RESTRICT src, int count,
17 U8CPU alpha, int /*x*/, int /*y*/) { 18 U8CPU alpha, int /*x*/, int /*y*/) {
18 SkASSERT(255 == alpha); 19 SkASSERT(255 == alpha);
19 20
20 if (count > 0) { 21 if (count > 0) {
21 do { 22 do {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 /////////////////////////////////////////////////////////////////////////////// 206 ///////////////////////////////////////////////////////////////////////////////
206 207
207 static uint32_t pmcolor_to_expand16(SkPMColor c) { 208 static uint32_t pmcolor_to_expand16(SkPMColor c) {
208 unsigned r = SkGetPackedR32(c); 209 unsigned r = SkGetPackedR32(c);
209 unsigned g = SkGetPackedG32(c); 210 unsigned g = SkGetPackedG32(c);
210 unsigned b = SkGetPackedB32(c); 211 unsigned b = SkGetPackedB32(c);
211 return (g << 24) | (r << 13) | (b << 2); 212 return (g << 24) | (r << 13) | (b << 2);
212 } 213 }
213 214
215 static void Color32_D565(uint16_t dst[], SkPMColor src, int count, int x, int y) {
mtklein 2015/01/30 18:17:36 The edits to this file seem unambiguously good and
henrik.smiding 2015/02/10 15:11:51 Done.
216 SkASSERT(count > 0);
217 sk_memset16(dst, SkPixel32ToPixel16_ToU16(src), count);
218 }
219
214 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y ) { 220 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y ) {
215 SkASSERT(count > 0); 221 SkASSERT(count > 0);
216 uint32_t src_expand = pmcolor_to_expand16(src); 222 uint32_t src_expand = pmcolor_to_expand16(src);
217 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3; 223 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3;
218 do { 224 do {
219 uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale; 225 uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale;
220 *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5); 226 *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5);
221 dst += 1; 227 dst += 1;
222 } while (--count != 0); 228 } while (--count != 0);
223 } 229 }
(...skipping 29 matching lines...) Expand all
253 return proc; 259 return proc;
254 } 260 }
255 261
256 static const SkBlitRow::ColorProc16 gDefault_565_ColorProcs[] = { 262 static const SkBlitRow::ColorProc16 gDefault_565_ColorProcs[] = {
257 #if 0 263 #if 0
258 Color32_D565, 264 Color32_D565,
259 Color32A_D565, 265 Color32A_D565,
260 Color32_D565_Dither, 266 Color32_D565_Dither,
261 Color32A_D565_Dither 267 Color32A_D565_Dither
262 #else 268 #else
263 // TODO: stop cheating and fill in the above specializations! 269 // TODO: stop cheating and fill dither from the above specializations! Use s k_dither_memset16?
270 Color32_D565,
264 Color32A_D565, 271 Color32A_D565,
265 Color32A_D565, 272 Color32_D565,
266 Color32A_D565,
267 Color32A_D565, 273 Color32A_D565,
268 #endif 274 #endif
269 }; 275 };
270 276
271 SkBlitRow::ColorProc16 SkBlitRow::ColorFactory16(unsigned flags) { 277 SkBlitRow::ColorProc16 SkBlitRow::ColorFactory16(unsigned flags) {
272 SkASSERT((flags & ~kFlags16_Mask) == 0); 278 SkASSERT((flags & ~kFlags16_Mask) == 0);
273 // just so we don't crash 279 // just so we don't crash
274 flags &= kFlags16_Mask; 280 flags &= kFlags16_Mask;
275 // we ignore kGlobalAlpha_Flag, so shift down 281 // we ignore kGlobalAlpha_Flag, so shift down
276 flags >>= 1; 282 flags >>= 1;
277 283
278 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs)); 284 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs));
279 285
280 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags); 286 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags);
281 if (NULL == proc) { 287 if (NULL == proc) {
282 proc = gDefault_565_ColorProcs[flags]; 288 proc = gDefault_565_ColorProcs[flags];
283 } 289 }
284 return proc; 290 return proc;
285 } 291 }
OLDNEW
« no previous file with comments | « no previous file | src/opts/SkBlitRow_opts_SSE4.h » ('j') | src/opts/SkBlitRow_opts_SSE4.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698