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

Side by Side Diff: src/codec/SkSwizzler.cpp

Issue 1656383002: NEON optimizations for gray -> RGBA (or BGRA) conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comments Created 4 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 | « bench/SwizzleBench.cpp ('k') | src/core/SkOpts.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkOpts.h" 10 #include "SkOpts.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { 263 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
264 264
265 src += offset; 265 src += offset;
266 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 266 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
267 for (int x = 0; x < dstWidth; x++) { 267 for (int x = 0; x < dstWidth; x++) {
268 dst[x] = SkPackARGB32NoCheck(0xFF, *src, *src, *src); 268 dst[x] = SkPackARGB32NoCheck(0xFF, *src, *src, *src);
269 src += deltaSrc; 269 src += deltaSrc;
270 } 270 }
271 } 271 }
272 272
273 static void fast_swizzle_gray_to_n32(
274 void* dst, const uint8_t* src, int width, int bpp, int deltaSrc, int off set,
275 const SkPMColor ctable[]) {
276
277 // This function must not be called if we are sampling. If we are not
278 // sampling, deltaSrc should equal bpp.
279 SkASSERT(deltaSrc == bpp);
280
281 // Note that there is no need to distinguish between RGB and BGR.
282 // Each color channel will get the same value.
283 SkOpts::gray_to_RGB1((uint32_t*) dst, src + offset, width);
284 }
285
273 static void swizzle_gray_to_565( 286 static void swizzle_gray_to_565(
274 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, 287 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
275 int bytesPerPixel, int deltaSrc, int offset, const SkPMColor ctable[]) { 288 int bytesPerPixel, int deltaSrc, int offset, const SkPMColor ctable[]) {
276 289
277 src += offset; 290 src += offset;
278 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow; 291 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
279 for (int x = 0; x < dstWidth; x++) { 292 for (int x = 0; x < dstWidth; x++) {
280 dst[x] = SkPack888ToRGB16(src[0], src[0], src[0]); 293 dst[x] = SkPack888ToRGB16(src[0], src[0], src[0]);
281 src += deltaSrc; 294 src += deltaSrc;
282 } 295 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 fastProc = &copy; 645 fastProc = &copy;
633 break; 646 break;
634 default: 647 default:
635 break; 648 break;
636 } 649 }
637 break; 650 break;
638 case kGray: 651 case kGray:
639 switch (dstInfo.colorType()) { 652 switch (dstInfo.colorType()) {
640 case kN32_SkColorType: 653 case kN32_SkColorType:
641 proc = &swizzle_gray_to_n32; 654 proc = &swizzle_gray_to_n32;
655 fastProc = &fast_swizzle_gray_to_n32;
642 break; 656 break;
643 case kGray_8_SkColorType: 657 case kGray_8_SkColorType:
644 proc = &sample1; 658 proc = &sample1;
645 fastProc = &copy; 659 fastProc = &copy;
646 break; 660 break;
647 case kRGB_565_SkColorType: 661 case kRGB_565_SkColorType:
648 proc = &swizzle_gray_to_565; 662 proc = &swizzle_gray_to_565;
649 break; 663 break;
650 default: 664 default:
651 break; 665 break;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 828 }
815 829
816 return fAllocatedWidth; 830 return fAllocatedWidth;
817 } 831 }
818 832
819 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { 833 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) {
820 SkASSERT(nullptr != dst && nullptr != src); 834 SkASSERT(nullptr != dst && nullptr != src);
821 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS rcBPP, 835 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS rcBPP,
822 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable); 836 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable);
823 } 837 }
OLDNEW
« no previous file with comments | « bench/SwizzleBench.cpp ('k') | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698