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

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

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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/SkBlitter_PM4f.cpp ('k') | src/core/SkBlitter_Sprite.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkCoreBlitters.h" 9 #include "SkCoreBlitters.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 typedef SkShaderBlitter INHERITED; 154 typedef SkShaderBlitter INHERITED;
155 }; 155 };
156 156
157 /////////////////////////////////////////////////////////////////////////////// 157 ///////////////////////////////////////////////////////////////////////////////
158 #ifdef USE_BLACK_BLITTER 158 #ifdef USE_BLACK_BLITTER
159 SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPai nt& paint) 159 SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPai nt& paint)
160 : INHERITED(device, paint) { 160 : INHERITED(device, paint) {
161 SkASSERT(paint.getShader() == nullptr); 161 SkASSERT(paint.getShader() == nullptr);
162 SkASSERT(paint.getColorFilter() == nullptr); 162 SkASSERT(paint.getColorFilter() == nullptr);
163 SkASSERT(paint.getXfermode() == nullptr); 163 SkASSERT(paint.isSrcOver());
164 SkASSERT(paint.getColor() == SK_ColorBLACK); 164 SkASSERT(paint.getColor() == SK_ColorBLACK);
165 } 165 }
166 166
167 #if 1 167 #if 1
168 #define black_8_pixels(mask, dst) \ 168 #define black_8_pixels(mask, dst) \
169 do { \ 169 do { \
170 if (mask & 0x80) dst[0] = 0; \ 170 if (mask & 0x80) dst[0] = 0; \
171 if (mask & 0x40) dst[1] = 0; \ 171 if (mask & 0x40) dst[1] = 0; \
172 if (mask & 0x20) dst[2] = 0; \ 172 if (mask & 0x20) dst[2] = 0; \
173 if (mask & 0x10) dst[3] = 0; \ 173 if (mask & 0x10) dst[3] = 0; \
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 } 676 }
677 } 677 }
678 678
679 /////////////////////////////////////////////////////////////////////////////// 679 ///////////////////////////////////////////////////////////////////////////////
680 680
681 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device, 681 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device,
682 const SkPaint& paint, 682 const SkPaint& paint,
683 SkShader::Context* shaderContext) 683 SkShader::Context* shaderContext)
684 : INHERITED(device, paint, shaderContext) 684 : INHERITED(device, paint, shaderContext)
685 { 685 {
686 SkASSERT(paint.getXfermode() == nullptr); 686 SkASSERT(paint.isSrcOver());
687 687
688 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor)); 688 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
689 689
690 // compute SkBlitRow::Procs 690 // compute SkBlitRow::Procs
691 unsigned flags = 0; 691 unsigned flags = 0;
692 692
693 uint32_t shaderFlags = fShaderFlags; 693 uint32_t shaderFlags = fShaderFlags;
694 // shaders take care of global alpha, so we never set it in SkBlitRow 694 // shaders take care of global alpha, so we never set it in SkBlitRow
695 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { 695 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) {
696 flags |= SkBlitRow::kSrcPixelAlpha_Flag; 696 flags |= SkBlitRow::kSrcPixelAlpha_Flag;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 802 }
803 } 803 }
804 804
805 /////////////////////////////////////////////////////////////////////// 805 ///////////////////////////////////////////////////////////////////////
806 806
807 SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter( 807 SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(
808 const SkPixmap& device, const SkPaint& paint, 808 const SkPixmap& device, const SkPaint& paint,
809 SkShader::Context* shaderContext) 809 SkShader::Context* shaderContext)
810 : INHERITED(device, paint, shaderContext) 810 : INHERITED(device, paint, shaderContext)
811 { 811 {
812 fXfermode = paint.getXfermode(); 812 fXfermode = SkXfermode::Peek(paint.getBlendMode());
813 SkASSERT(fXfermode); 813 SkASSERT(fXfermode);
814 fXfermode->ref();
815 814
816 int width = device.width(); 815 int width = device.width();
817 fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * siz eof(SkPMColor)); 816 fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * siz eof(SkPMColor));
818 fAAExpand = (uint8_t*)(fBuffer + width); 817 fAAExpand = (uint8_t*)(fBuffer + width);
819 } 818 }
820 819
821 SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter() { 820 SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter() {
822 fXfermode->unref();
823 sk_free(fBuffer); 821 sk_free(fBuffer);
824 } 822 }
825 823
826 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) { 824 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) {
827 SkASSERT(x + width <= fDevice.width()); 825 SkASSERT(x + width <= fDevice.width());
828 826
829 uint16_t* device = fDevice.writable_addr16(x, y); 827 uint16_t* device = fDevice.writable_addr16(x, y);
830 SkPMColor* span = fBuffer; 828 SkPMColor* span = fBuffer;
831 829
832 fShaderContext->shadeSpan(x, y, span, width); 830 fShaderContext->shadeSpan(x, y, span, width);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 888
891 /////////////////////////////////////////////////////////////////////////////// 889 ///////////////////////////////////////////////////////////////////////////////
892 890
893 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint, 891 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
894 SkShader::Context* shaderContext, 892 SkShader::Context* shaderContext,
895 SkTBlitterAllocator* allocator) { 893 SkTBlitterAllocator* allocator) {
896 SkASSERT(allocator != nullptr); 894 SkASSERT(allocator != nullptr);
897 895
898 SkBlitter* blitter; 896 SkBlitter* blitter;
899 SkShader* shader = paint.getShader(); 897 SkShader* shader = paint.getShader();
900 SkXfermode* mode = paint.getXfermode(); 898 bool is_srcover = paint.isSrcOver();
901 899
902 // we require a shader if there is an xfermode, handled by our caller 900 // we require a shader if there is an xfermode, handled by our caller
903 SkASSERT(nullptr == mode || shader); 901 SkASSERT(is_srcover || shader);
904 902
905 if (shader) { 903 if (shader) {
906 SkASSERT(shaderContext != nullptr); 904 SkASSERT(shaderContext != nullptr);
907 if (mode) { 905 if (!is_srcover) {
908 blitter = allocator->createT<SkRGB16_Shader_Xfermode_Blitter>(device , paint, 906 blitter = allocator->createT<SkRGB16_Shader_Xfermode_Blitter>(device , paint,
909 shader Context); 907 shader Context);
910 } else { 908 } else {
911 blitter = allocator->createT<SkRGB16_Shader_Blitter>(device, paint, shaderContext); 909 blitter = allocator->createT<SkRGB16_Shader_Blitter>(device, paint, shaderContext);
912 } 910 }
913 } else { 911 } else {
914 // no shader, no xfermode, (and we always ignore colorfilter) 912 // no shader, no xfermode, (and we always ignore colorfilter)
915 SkColor color = paint.getColor(); 913 SkColor color = paint.getColor();
916 if (0 == SkColorGetA(color)) { 914 if (0 == SkColorGetA(color)) {
917 blitter = allocator->createT<SkNullBlitter>(); 915 blitter = allocator->createT<SkNullBlitter>();
918 #ifdef USE_BLACK_BLITTER 916 #ifdef USE_BLACK_BLITTER
919 } else if (SK_ColorBLACK == color) { 917 } else if (SK_ColorBLACK == color) {
920 blitter = allocator->createT<SkRGB16_Black_Blitter>(device, paint); 918 blitter = allocator->createT<SkRGB16_Black_Blitter>(device, paint);
921 #endif 919 #endif
922 } else if (0xFF == SkColorGetA(color)) { 920 } else if (0xFF == SkColorGetA(color)) {
923 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); 921 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint);
924 } else { 922 } else {
925 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); 923 blitter = allocator->createT<SkRGB16_Blitter>(device, paint);
926 } 924 }
927 } 925 }
928 926
929 return blitter; 927 return blitter;
930 } 928 }
OLDNEW
« no previous file with comments | « src/core/SkBlitter_PM4f.cpp ('k') | src/core/SkBlitter_Sprite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698