OLD | NEW |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 public: | 115 public: |
116 SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint, | 116 SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint, |
117 SkShader::Context* shaderContext); | 117 SkShader::Context* shaderContext); |
118 virtual ~SkRGB16_Shader_Blitter(); | 118 virtual ~SkRGB16_Shader_Blitter(); |
119 void blitH(int x, int y, int width) SK_OVERRIDE; | 119 void blitH(int x, int y, int width) SK_OVERRIDE; |
120 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, | 120 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, |
121 const int16_t* runs) SK_OVERRIDE; | 121 const int16_t* runs) SK_OVERRIDE; |
122 void blitRect(int x, int y, int width, int height) SK_OVERRIDE; | 122 void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
123 | 123 |
124 protected: | 124 protected: |
125 SkPMColor* fBuffer; | 125 SkPMColor* fBuffer; |
126 SkBlitRow::Proc fOpaqueProc; | 126 SkBlitRow::Proc16 fOpaqueProc; |
127 SkBlitRow::Proc fAlphaProc; | 127 SkBlitRow::Proc16 fAlphaProc; |
128 | 128 |
129 private: | 129 private: |
130 // illegal | 130 // illegal |
131 SkRGB16_Shader_Blitter& operator=(const SkRGB16_Shader_Blitter&); | 131 SkRGB16_Shader_Blitter& operator=(const SkRGB16_Shader_Blitter&); |
132 | 132 |
133 typedef SkShaderBlitter INHERITED; | 133 typedef SkShaderBlitter INHERITED; |
134 }; | 134 }; |
135 | 135 |
136 // used only if the shader can perform shadSpan16 | 136 // used only if the shader can perform shadSpan16 |
137 class SkRGB16_Shader16_Blitter : public SkRGB16_Shader_Blitter { | 137 class SkRGB16_Shader16_Blitter : public SkRGB16_Shader_Blitter { |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 uint32_t shaderFlags = fShaderFlags; | 829 uint32_t shaderFlags = fShaderFlags; |
830 // shaders take care of global alpha, so we never set it in SkBlitRow | 830 // shaders take care of global alpha, so we never set it in SkBlitRow |
831 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { | 831 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { |
832 flags |= SkBlitRow::kSrcPixelAlpha_Flag; | 832 flags |= SkBlitRow::kSrcPixelAlpha_Flag; |
833 } | 833 } |
834 // don't dither if the shader is really 16bit | 834 // don't dither if the shader is really 16bit |
835 if (paint.isDither() && !(shaderFlags & SkShader::kIntrinsicly16_Flag)) { | 835 if (paint.isDither() && !(shaderFlags & SkShader::kIntrinsicly16_Flag)) { |
836 flags |= SkBlitRow::kDither_Flag; | 836 flags |= SkBlitRow::kDither_Flag; |
837 } | 837 } |
838 // used when we know our global alpha is 0xFF | 838 // used when we know our global alpha is 0xFF |
839 fOpaqueProc = SkBlitRow::Factory(flags, kRGB_565_SkColorType); | 839 fOpaqueProc = SkBlitRow::Factory16(flags); |
840 // used when we know our global alpha is < 0xFF | 840 // used when we know our global alpha is < 0xFF |
841 fAlphaProc = SkBlitRow::Factory(flags | SkBlitRow::kGlobalAlpha_Flag, | 841 fAlphaProc = SkBlitRow::Factory16(flags | SkBlitRow::kGlobalAlpha_Flag); |
842 kRGB_565_SkColorType); | |
843 } | 842 } |
844 | 843 |
845 SkRGB16_Shader_Blitter::~SkRGB16_Shader_Blitter() { | 844 SkRGB16_Shader_Blitter::~SkRGB16_Shader_Blitter() { |
846 sk_free(fBuffer); | 845 sk_free(fBuffer); |
847 } | 846 } |
848 | 847 |
849 void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) { | 848 void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) { |
850 SkASSERT(x + width <= fDevice.width()); | 849 SkASSERT(x + width <= fDevice.width()); |
851 | 850 |
852 fShaderContext->shadeSpan(x, y, fBuffer, width); | 851 fShaderContext->shadeSpan(x, y, fBuffer, width); |
853 // shaders take care of global alpha, so we pass 0xFF (should be ignored) | 852 // shaders take care of global alpha, so we pass 0xFF (should be ignored) |
854 fOpaqueProc(fDevice.getAddr16(x, y), fBuffer, width, 0xFF, x, y); | 853 fOpaqueProc(fDevice.getAddr16(x, y), fBuffer, width, 0xFF, x, y); |
855 } | 854 } |
856 | 855 |
857 void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) { | 856 void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) { |
858 SkShader::Context* shaderContext = fShaderContext; | 857 SkShader::Context* shaderContext = fShaderContext; |
859 SkBlitRow::Proc proc = fOpaqueProc; | 858 SkBlitRow::Proc16 proc = fOpaqueProc; |
860 SkPMColor* buffer = fBuffer; | 859 SkPMColor* buffer = fBuffer; |
861 uint16_t* dst = fDevice.getAddr16(x, y); | 860 uint16_t* dst = fDevice.getAddr16(x, y); |
862 size_t dstRB = fDevice.rowBytes(); | 861 size_t dstRB = fDevice.rowBytes(); |
863 | 862 |
864 if (fShaderFlags & SkShader::kConstInY32_Flag) { | 863 if (fShaderFlags & SkShader::kConstInY32_Flag) { |
865 shaderContext->shadeSpan(x, y, buffer, width); | 864 shaderContext->shadeSpan(x, y, buffer, width); |
866 do { | 865 do { |
867 proc(dst, buffer, width, 0xFF, x, y); | 866 proc(dst, buffer, width, 0xFF, x, y); |
868 y += 1; | 867 y += 1; |
869 dst = (uint16_t*)((char*)dst + dstRB); | 868 dst = (uint16_t*)((char*)dst + dstRB); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 continue; | 912 continue; |
914 } | 913 } |
915 | 914 |
916 int nonZeroCount = count + count_nonzero_span(runs + count, antialias +
count); | 915 int nonZeroCount = count + count_nonzero_span(runs + count, antialias +
count); |
917 | 916 |
918 SkASSERT(nonZeroCount <= fDevice.width()); // don't overrun fBuffer | 917 SkASSERT(nonZeroCount <= fDevice.width()); // don't overrun fBuffer |
919 shaderContext->shadeSpan(x, y, span, nonZeroCount); | 918 shaderContext->shadeSpan(x, y, span, nonZeroCount); |
920 | 919 |
921 SkPMColor* localSpan = span; | 920 SkPMColor* localSpan = span; |
922 for (;;) { | 921 for (;;) { |
923 SkBlitRow::Proc proc = (aa == 0xFF) ? fOpaqueProc : fAlphaProc; | 922 SkBlitRow::Proc16 proc = (aa == 0xFF) ? fOpaqueProc : fAlphaProc; |
924 proc(device, localSpan, count, aa, x, y); | 923 proc(device, localSpan, count, aa, x, y); |
925 | 924 |
926 x += count; | 925 x += count; |
927 device += count; | 926 device += count; |
928 runs += count; | 927 runs += count; |
929 antialias += count; | 928 antialias += count; |
930 nonZeroCount -= count; | 929 nonZeroCount -= count; |
931 if (nonZeroCount == 0) { | 930 if (nonZeroCount == 0) { |
932 break; | 931 break; |
933 } | 932 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 #endif | 1059 #endif |
1061 } else if (0xFF == SkColorGetA(color)) { | 1060 } else if (0xFF == SkColorGetA(color)) { |
1062 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); | 1061 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); |
1063 } else { | 1062 } else { |
1064 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); | 1063 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); |
1065 } | 1064 } |
1066 } | 1065 } |
1067 | 1066 |
1068 return blitter; | 1067 return blitter; |
1069 } | 1068 } |
OLD | NEW |