OLD | NEW |
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // illegal | 165 // illegal |
166 SkRGB16_Shader_Xfermode_Blitter& operator=(const SkRGB16_Shader_Xfermode_Bli
tter&); | 166 SkRGB16_Shader_Xfermode_Blitter& operator=(const SkRGB16_Shader_Xfermode_Bli
tter&); |
167 | 167 |
168 typedef SkShaderBlitter INHERITED; | 168 typedef SkShaderBlitter INHERITED; |
169 }; | 169 }; |
170 | 170 |
171 /////////////////////////////////////////////////////////////////////////////// | 171 /////////////////////////////////////////////////////////////////////////////// |
172 #ifdef USE_BLACK_BLITTER | 172 #ifdef USE_BLACK_BLITTER |
173 SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPai
nt& paint) | 173 SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPai
nt& paint) |
174 : INHERITED(device, paint) { | 174 : INHERITED(device, paint) { |
175 SkASSERT(paint.getShader() == NULL); | 175 SkASSERT(paint.getShader() == nullptr); |
176 SkASSERT(paint.getColorFilter() == NULL); | 176 SkASSERT(paint.getColorFilter() == nullptr); |
177 SkASSERT(paint.getXfermode() == NULL); | 177 SkASSERT(paint.getXfermode() == nullptr); |
178 SkASSERT(paint.getColor() == SK_ColorBLACK); | 178 SkASSERT(paint.getColor() == SK_ColorBLACK); |
179 } | 179 } |
180 | 180 |
181 #if 1 | 181 #if 1 |
182 #define black_8_pixels(mask, dst) \ | 182 #define black_8_pixels(mask, dst) \ |
183 do { \ | 183 do { \ |
184 if (mask & 0x80) dst[0] = 0; \ | 184 if (mask & 0x80) dst[0] = 0; \ |
185 if (mask & 0x40) dst[1] = 0; \ | 185 if (mask & 0x40) dst[1] = 0; \ |
186 if (mask & 0x20) dst[2] = 0; \ | 186 if (mask & 0x20) dst[2] = 0; \ |
187 if (mask & 0x10) dst[3] = 0; \ | 187 if (mask & 0x10) dst[3] = 0; \ |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 | 562 |
563 fColorProc16 = SkBlitRow::ColorFactory16(flags); | 563 fColorProc16 = SkBlitRow::ColorFactory16(flags); |
564 } | 564 } |
565 | 565 |
566 const SkPixmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) { | 566 const SkPixmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) { |
567 if (!fDoDither && 256 == fScale) { | 567 if (!fDoDither && 256 == fScale) { |
568 *value = fRawColor16; | 568 *value = fRawColor16; |
569 return &fDevice; | 569 return &fDevice; |
570 } | 570 } |
571 return NULL; | 571 return nullptr; |
572 } | 572 } |
573 | 573 |
574 void SkRGB16_Blitter::blitH(int x, int y, int width) { | 574 void SkRGB16_Blitter::blitH(int x, int y, int width) { |
575 SkASSERT(width > 0); | 575 SkASSERT(width > 0); |
576 SkASSERT(x + width <= fDevice.width()); | 576 SkASSERT(x + width <= fDevice.width()); |
577 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); | 577 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); |
578 | 578 |
579 fColorProc16(device, fSrcColor32, width, x, y); | 579 fColorProc16(device, fSrcColor32, width, x, y); |
580 } | 580 } |
581 | 581 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
818 /////////////////////////////////////////////////////////////////////////////// | 818 /////////////////////////////////////////////////////////////////////////////// |
819 | 819 |
820 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device, | 820 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device, |
821 const SkPaint& paint, | 821 const SkPaint& paint, |
822 SkShader::Context* shaderContext) | 822 SkShader::Context* shaderContext) |
823 : INHERITED(device, paint, shaderContext) | 823 : INHERITED(device, paint, shaderContext) |
824 { | 824 { |
825 SkASSERT(paint.getXfermode() == NULL); | 825 SkASSERT(paint.getXfermode() == nullptr); |
826 | 826 |
827 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor)); | 827 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor)); |
828 | 828 |
829 // compute SkBlitRow::Procs | 829 // compute SkBlitRow::Procs |
830 unsigned flags = 0; | 830 unsigned flags = 0; |
831 | 831 |
832 uint32_t shaderFlags = fShaderFlags; | 832 uint32_t shaderFlags = fShaderFlags; |
833 // shaders take care of global alpha, so we never set it in SkBlitRow | 833 // shaders take care of global alpha, so we never set it in SkBlitRow |
834 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { | 834 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { |
835 flags |= SkBlitRow::kSrcPixelAlpha_Flag; | 835 flags |= SkBlitRow::kSrcPixelAlpha_Flag; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 sk_free(fBuffer); | 963 sk_free(fBuffer); |
964 } | 964 } |
965 | 965 |
966 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) { | 966 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) { |
967 SkASSERT(x + width <= fDevice.width()); | 967 SkASSERT(x + width <= fDevice.width()); |
968 | 968 |
969 uint16_t* device = fDevice.writable_addr16(x, y); | 969 uint16_t* device = fDevice.writable_addr16(x, y); |
970 SkPMColor* span = fBuffer; | 970 SkPMColor* span = fBuffer; |
971 | 971 |
972 fShaderContext->shadeSpan(x, y, span, width); | 972 fShaderContext->shadeSpan(x, y, span, width); |
973 fXfermode->xfer16(device, span, width, NULL); | 973 fXfermode->xfer16(device, span, width, nullptr); |
974 } | 974 } |
975 | 975 |
976 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y, | 976 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y, |
977 const SkAlpha* SK_RESTRICT antialias, | 977 const SkAlpha* SK_RESTRICT antialias, |
978 const int16_t* SK_RESTRICT runs) { | 978 const int16_t* SK_RESTRICT runs) { |
979 SkShader::Context* shaderContext = fShaderContext; | 979 SkShader::Context* shaderContext = fShaderContext; |
980 SkXfermode* mode = fXfermode; | 980 SkXfermode* mode = fXfermode; |
981 SkPMColor* SK_RESTRICT span = fBuffer; | 981 SkPMColor* SK_RESTRICT span = fBuffer; |
982 uint8_t* SK_RESTRICT aaExpand = fAAExpand; | 982 uint8_t* SK_RESTRICT aaExpand = fAAExpand; |
983 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); | 983 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); |
(...skipping 15 matching lines...) Expand all Loading... |
999 int nonZeroCount = count + count_nonzero_span(runs + count, | 999 int nonZeroCount = count + count_nonzero_span(runs + count, |
1000 antialias + count); | 1000 antialias + count); |
1001 | 1001 |
1002 SkASSERT(nonZeroCount <= fDevice.width()); // don't overrun fBuffer | 1002 SkASSERT(nonZeroCount <= fDevice.width()); // don't overrun fBuffer |
1003 shaderContext->shadeSpan(x, y, span, nonZeroCount); | 1003 shaderContext->shadeSpan(x, y, span, nonZeroCount); |
1004 | 1004 |
1005 x += nonZeroCount; | 1005 x += nonZeroCount; |
1006 SkPMColor* localSpan = span; | 1006 SkPMColor* localSpan = span; |
1007 for (;;) { | 1007 for (;;) { |
1008 if (aa == 0xFF) { | 1008 if (aa == 0xFF) { |
1009 mode->xfer16(device, localSpan, count, NULL); | 1009 mode->xfer16(device, localSpan, count, nullptr); |
1010 } else { | 1010 } else { |
1011 SkASSERT(aa); | 1011 SkASSERT(aa); |
1012 memset(aaExpand, aa, count); | 1012 memset(aaExpand, aa, count); |
1013 mode->xfer16(device, localSpan, count, aaExpand); | 1013 mode->xfer16(device, localSpan, count, aaExpand); |
1014 } | 1014 } |
1015 device += count; | 1015 device += count; |
1016 runs += count; | 1016 runs += count; |
1017 antialias += count; | 1017 antialias += count; |
1018 nonZeroCount -= count; | 1018 nonZeroCount -= count; |
1019 if (nonZeroCount == 0) { | 1019 if (nonZeroCount == 0) { |
1020 break; | 1020 break; |
1021 } | 1021 } |
1022 localSpan += count; | 1022 localSpan += count; |
1023 SkASSERT(nonZeroCount > 0); | 1023 SkASSERT(nonZeroCount > 0); |
1024 count = *runs; | 1024 count = *runs; |
1025 SkASSERT(count > 0); | 1025 SkASSERT(count > 0); |
1026 aa = *antialias; | 1026 aa = *antialias; |
1027 } | 1027 } |
1028 } | 1028 } |
1029 } | 1029 } |
1030 | 1030 |
1031 /////////////////////////////////////////////////////////////////////////////// | 1031 /////////////////////////////////////////////////////////////////////////////// |
1032 | 1032 |
1033 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint, | 1033 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint, |
1034 SkShader::Context* shaderContext, | 1034 SkShader::Context* shaderContext, |
1035 SkTBlitterAllocator* allocator) { | 1035 SkTBlitterAllocator* allocator) { |
1036 SkASSERT(allocator != NULL); | 1036 SkASSERT(allocator != nullptr); |
1037 | 1037 |
1038 SkBlitter* blitter; | 1038 SkBlitter* blitter; |
1039 SkShader* shader = paint.getShader(); | 1039 SkShader* shader = paint.getShader(); |
1040 SkXfermode* mode = paint.getXfermode(); | 1040 SkXfermode* mode = paint.getXfermode(); |
1041 | 1041 |
1042 // we require a shader if there is an xfermode, handled by our caller | 1042 // we require a shader if there is an xfermode, handled by our caller |
1043 SkASSERT(NULL == mode || shader); | 1043 SkASSERT(nullptr == mode || shader); |
1044 | 1044 |
1045 if (shader) { | 1045 if (shader) { |
1046 SkASSERT(shaderContext != NULL); | 1046 SkASSERT(shaderContext != nullptr); |
1047 if (mode) { | 1047 if (mode) { |
1048 blitter = allocator->createT<SkRGB16_Shader_Xfermode_Blitter>(device
, paint, | 1048 blitter = allocator->createT<SkRGB16_Shader_Xfermode_Blitter>(device
, paint, |
1049 shader
Context); | 1049 shader
Context); |
1050 } else if (shaderContext->canCallShadeSpan16()) { | 1050 } else if (shaderContext->canCallShadeSpan16()) { |
1051 blitter = allocator->createT<SkRGB16_Shader16_Blitter>(device, paint
, shaderContext); | 1051 blitter = allocator->createT<SkRGB16_Shader16_Blitter>(device, paint
, shaderContext); |
1052 } else { | 1052 } else { |
1053 blitter = allocator->createT<SkRGB16_Shader_Blitter>(device, paint,
shaderContext); | 1053 blitter = allocator->createT<SkRGB16_Shader_Blitter>(device, paint,
shaderContext); |
1054 } | 1054 } |
1055 } else { | 1055 } else { |
1056 // no shader, no xfermode, (and we always ignore colorfilter) | 1056 // no shader, no xfermode, (and we always ignore colorfilter) |
1057 SkColor color = paint.getColor(); | 1057 SkColor color = paint.getColor(); |
1058 if (0 == SkColorGetA(color)) { | 1058 if (0 == SkColorGetA(color)) { |
1059 blitter = allocator->createT<SkNullBlitter>(); | 1059 blitter = allocator->createT<SkNullBlitter>(); |
1060 #ifdef USE_BLACK_BLITTER | 1060 #ifdef USE_BLACK_BLITTER |
1061 } else if (SK_ColorBLACK == color) { | 1061 } else if (SK_ColorBLACK == color) { |
1062 blitter = allocator->createT<SkRGB16_Black_Blitter>(device, paint); | 1062 blitter = allocator->createT<SkRGB16_Black_Blitter>(device, paint); |
1063 #endif | 1063 #endif |
1064 } else if (0xFF == SkColorGetA(color)) { | 1064 } else if (0xFF == SkColorGetA(color)) { |
1065 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); | 1065 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); |
1066 } else { | 1066 } else { |
1067 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); | 1067 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); |
1068 } | 1068 } |
1069 } | 1069 } |
1070 | 1070 |
1071 return blitter; | 1071 return blitter; |
1072 } | 1072 } |
OLD | NEW |