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

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

Issue 847363002: skia: blend32_16_row for neon version (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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/opts/SkBlitRow_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
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBlitRow.h" 10 #include "SkBlitRow.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 63 virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
64 const int16_t* runs) SK_OVERRIDE; 64 const int16_t* runs) SK_OVERRIDE;
65 void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 65 void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE;
66 void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 66 void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
67 virtual void blitMask(const SkMask&, 67 virtual void blitMask(const SkMask&,
68 const SkIRect&) SK_OVERRIDE; 68 const SkIRect&) SK_OVERRIDE;
69 const SkBitmap* justAnOpaqueColor(uint32_t*) SK_OVERRIDE; 69 const SkBitmap* justAnOpaqueColor(uint32_t*) SK_OVERRIDE;
70 70
71 protected: 71 protected:
72 SkPMColor fSrcColor32; 72 SkPMColor fSrcColor32;
73 SkPMColor fSrcColors32[8];
73 uint32_t fExpandedRaw16; 74 uint32_t fExpandedRaw16;
74 unsigned fScale; 75 unsigned fScale;
75 uint16_t fColor16; // already scaled by fScale 76 uint16_t fColor16; // already scaled by fScale
76 uint16_t fRawColor16; // unscaled 77 uint16_t fRawColor16; // unscaled
77 uint16_t fRawDither16; // unscaled 78 uint16_t fRawDither16; // unscaled
78 SkBool8 fDoDither; 79 SkBool8 fDoDither;
79 80
81 SkBlitRow::ColorProc16 fColorProc16;
82
80 // illegal 83 // illegal
81 SkRGB16_Blitter& operator=(const SkRGB16_Blitter&); 84 SkRGB16_Blitter& operator=(const SkRGB16_Blitter&);
82 85
83 typedef SkRasterBlitter INHERITED; 86 typedef SkRasterBlitter INHERITED;
84 }; 87 };
85 88
86 class SkRGB16_Opaque_Blitter : public SkRGB16_Blitter { 89 class SkRGB16_Opaque_Blitter : public SkRGB16_Blitter {
87 public: 90 public:
88 SkRGB16_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint); 91 SkRGB16_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint);
89 void blitH(int x, int y, int width) SK_OVERRIDE; 92 void blitH(int x, int y, int width) SK_OVERRIDE;
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 523 }
521 } 524 }
522 525
523 /////////////////////////////////////////////////////////////////////////////// 526 ///////////////////////////////////////////////////////////////////////////////
524 527
525 SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint) 528 SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint)
526 : INHERITED(device) { 529 : INHERITED(device) {
527 SkColor color = paint.getColor(); 530 SkColor color = paint.getColor();
528 531
529 fSrcColor32 = SkPreMultiplyColor(color); 532 fSrcColor32 = SkPreMultiplyColor(color);
533
534 for (int count = 0; count < 8; count++) {
djsollen 2015/01/14 14:57:54 We shouldn't need to do this here. You can just d
mlee 2015/01/15 08:12:36 On 2015/01/14 14:57:54, djsollen wrote: Hi, djsol
mlee 2015/01/21 10:17:32 On 2015/01/14 14:57:54, djsollen wrote: Done in pa
535 fSrcColors32[count] = fSrcColor32;
536 }
537
530 fScale = SkAlpha255To256(SkColorGetA(color)); 538 fScale = SkAlpha255To256(SkColorGetA(color));
531 539
532 int r = SkColorGetR(color); 540 int r = SkColorGetR(color);
533 int g = SkColorGetG(color); 541 int g = SkColorGetG(color);
534 int b = SkColorGetB(color); 542 int b = SkColorGetB(color);
535 543
536 fRawColor16 = fRawDither16 = SkPack888ToRGB16(r, g, b); 544 fRawColor16 = fRawDither16 = SkPack888ToRGB16(r, g, b);
537 // if we're dithered, use fRawDither16 to hold that. 545 // if we're dithered, use fRawDither16 to hold that.
538 if ((fDoDither = paint.isDither()) != false) { 546 if ((fDoDither = paint.isDither()) != false) {
539 fRawDither16 = SkDitherPack888ToRGB16(r, g, b); 547 fRawDither16 = SkDitherPack888ToRGB16(r, g, b);
540 } 548 }
541 549
542 fExpandedRaw16 = SkExpand_rgb_16(fRawColor16); 550 fExpandedRaw16 = SkExpand_rgb_16(fRawColor16);
543 551
544 fColor16 = SkPackRGB16( SkAlphaMul(r, fScale) >> (8 - SK_R16_BITS), 552 fColor16 = SkPackRGB16( SkAlphaMul(r, fScale) >> (8 - SK_R16_BITS),
545 SkAlphaMul(g, fScale) >> (8 - SK_G16_BITS), 553 SkAlphaMul(g, fScale) >> (8 - SK_G16_BITS),
546 SkAlphaMul(b, fScale) >> (8 - SK_B16_BITS)); 554 SkAlphaMul(b, fScale) >> (8 - SK_B16_BITS));
555
556 // compute SkBlitRow::Procs
557 unsigned flags = 0;
558
559 // TODO: respect fDoDither
560 flags |= SkBlitRow::kSrcPixelAlpha_Flag;
561
562 fColorProc16 = SkBlitRow::PlatformColorFactory565(flags);
547 } 563 }
548 564
549 const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) { 565 const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) {
550 if (!fDoDither && 256 == fScale) { 566 if (!fDoDither && 256 == fScale) {
551 *value = fRawColor16; 567 *value = fRawColor16;
552 return &fDevice; 568 return &fDevice;
553 } 569 }
554 return NULL; 570 return NULL;
555 } 571 }
556 572
557 static uint32_t pmcolor_to_expand16(SkPMColor c) {
558 unsigned r = SkGetPackedR32(c);
559 unsigned g = SkGetPackedG32(c);
560 unsigned b = SkGetPackedB32(c);
561 return (g << 24) | (r << 13) | (b << 2);
562 }
563
564 static inline void blend32_16_row(SkPMColor src, uint16_t dst[], int count) {
565 SkASSERT(count > 0);
566 uint32_t src_expand = pmcolor_to_expand16(src);
567 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3;
568 do {
569 uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale;
570 *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5);
571 dst += 1;
572 } while (--count != 0);
573 }
574
575 void SkRGB16_Blitter::blitH(int x, int y, int width) { 573 void SkRGB16_Blitter::blitH(int x, int y, int width) {
576 SkASSERT(width > 0); 574 SkASSERT(width > 0);
577 SkASSERT(x + width <= fDevice.width()); 575 SkASSERT(x + width <= fDevice.width());
578 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 576 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
579 577
580 // TODO: respect fDoDither 578 fColorProc16(device, fSrcColors32, width, x, y);
581 blend32_16_row(fSrcColor32, device, width);
582 } 579 }
583 580
584 void SkRGB16_Blitter::blitAntiH(int x, int y, 581 void SkRGB16_Blitter::blitAntiH(int x, int y,
585 const SkAlpha* SK_RESTRICT antialias, 582 const SkAlpha* SK_RESTRICT antialias,
586 const int16_t* SK_RESTRICT runs) { 583 const int16_t* SK_RESTRICT runs) {
587 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 584 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
588 uint32_t srcExpanded = fExpandedRaw16; 585 uint32_t srcExpanded = fExpandedRaw16;
589 unsigned scale = fScale; 586 unsigned scale = fScale;
590 587
591 // TODO: respect fDoDither 588 // TODO: respect fDoDither
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; 671 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5;
675 *device = SkCompact_rgb_16((src32 + dst32) >> 5); 672 *device = SkCompact_rgb_16((src32 + dst32) >> 5);
676 device = (uint16_t*)((char*)device + deviceRB); 673 device = (uint16_t*)((char*)device + deviceRB);
677 } while (--height != 0); 674 } while (--height != 0);
678 } 675 }
679 676
680 void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) { 677 void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) {
681 SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height()); 678 SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height());
682 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 679 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
683 size_t deviceRB = fDevice.rowBytes(); 680 size_t deviceRB = fDevice.rowBytes();
684 SkPMColor src32 = fSrcColor32;
685 681
686 while (--height >= 0) { 682 while (--height >= 0) {
687 blend32_16_row(src32, device, width); 683 fColorProc16(device, fSrcColors32, width, x, y);
688 device = (uint16_t*)((char*)device + deviceRB); 684 device = (uint16_t*)((char*)device + deviceRB);
689 } 685 }
690 } 686 }
691 687
692 /////////////////////////////////////////////////////////////////////////////// 688 ///////////////////////////////////////////////////////////////////////////////
693 689
694 SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkBitmap& device, 690 SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkBitmap& device,
695 const SkPaint& paint, 691 const SkPaint& paint,
696 SkShader::Context* shaderCont ext) 692 SkShader::Context* shaderCont ext)
697 : SkRGB16_Shader_Blitter(device, paint, shaderContext) { 693 : SkRGB16_Shader_Blitter(device, paint, shaderContext) {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 #endif 1055 #endif
1060 } else if (0xFF == SkColorGetA(color)) { 1056 } else if (0xFF == SkColorGetA(color)) {
1061 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); 1057 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint);
1062 } else { 1058 } else {
1063 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); 1059 blitter = allocator->createT<SkRGB16_Blitter>(device, paint);
1064 } 1060 }
1065 } 1061 }
1066 1062
1067 return blitter; 1063 return blitter;
1068 } 1064 }
OLDNEW
« no previous file with comments | « src/core/SkBlitRow_D16.cpp ('k') | src/opts/SkBlitRow_opts_arm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698