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 "SkBlitter.h" | 8 #include "SkBlitter.h" |
9 #include "SkAntiRun.h" | 9 #include "SkAntiRun.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkMask.h" | 14 #include "SkMask.h" |
15 #include "SkMaskFilter.h" | 15 #include "SkMaskFilter.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 #include "SkTLazy.h" | 17 #include "SkTLazy.h" |
18 #include "SkUtils.h" | 18 #include "SkUtils.h" |
19 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
20 #include "SkXfermodeInterpretation.h" | 20 #include "SkXfermodeInterpretation.h" |
21 | 21 |
22 // define this for testing srgb blits | 22 // define this for testing srgb blits |
23 //#define SK_SUPPORT_SRGB_RASTER | 23 //#define SK_SUPPORT_SRGB_RASTER |
24 | 24 |
25 #ifdef SK_SUPPORT_SRGB_RASTER | 25 #ifdef SK_SUPPORT_SRGB_RASTER |
26 #define ALLOW_SRGB true | 26 #define ALLOW_SRGB true |
27 #else | 27 #else |
28 #define ALLOW_SRGB false | 28 #define ALLOW_SRGB false |
29 #endif | 29 #endif |
f(malita)
2016/02/15 04:31:17
I think we no longer need these.
reed2
2016/02/15 15:25:22
Agreed. Replaced with SK_FORCE_PM4f_FOR_L32_BLITS
| |
30 | 30 |
31 SkBlitter::~SkBlitter() {} | 31 SkBlitter::~SkBlitter() {} |
32 | 32 |
33 bool SkBlitter::isNullBlitter() const { return false; } | 33 bool SkBlitter::isNullBlitter() const { return false; } |
34 | 34 |
35 bool SkBlitter::resetShaderContext(const SkShader::ContextRec&) { | 35 bool SkBlitter::resetShaderContext(const SkShader::ContextRec&) { |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
39 SkShader::Context* SkBlitter::getShaderContext() const { | 39 SkShader::Context* SkBlitter::getShaderContext() const { |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 } else { | 906 } else { |
907 blitter = allocator->createT<SkA8_Blitter>(device, *paint); | 907 blitter = allocator->createT<SkA8_Blitter>(device, *paint); |
908 } | 908 } |
909 break; | 909 break; |
910 | 910 |
911 case kRGB_565_SkColorType: | 911 case kRGB_565_SkColorType: |
912 blitter = SkBlitter_ChooseD565(device, *paint, shaderContext, alloca tor); | 912 blitter = SkBlitter_ChooseD565(device, *paint, shaderContext, alloca tor); |
913 break; | 913 break; |
914 | 914 |
915 case kN32_SkColorType: | 915 case kN32_SkColorType: |
916 if (shader) { | 916 if (device.info().isSRGB()) { |
917 if (shaderContext->supports4f() && ALLOW_SRGB) { | 917 blitter = SkBlitter_ARGB32_Create(device, *paint, shaderContext, allocator); |
918 blitter = allocator->createT<SkARGB32_Shader4f_Blitter>( | 918 } else { |
919 device, *paint , shaderContext); | 919 if (shader) { |
920 blitter = allocator->createT<SkARGB32_Shader_Blitter>( | |
921 device, *paint, shaderContext); | |
922 } else if (paint->getColor() == SK_ColorBLACK) { | |
923 blitter = allocator->createT<SkARGB32_Black_Blitter>(device, *paint); | |
924 } else if (paint->getAlpha() == 0xFF) { | |
925 blitter = allocator->createT<SkARGB32_Opaque_Blitter>(device , *paint); | |
920 } else { | 926 } else { |
921 blitter = allocator->createT<SkARGB32_Shader_Blitter>( | 927 blitter = allocator->createT<SkARGB32_Blitter>(device, *pain t); |
922 device, *paint, shaderContext); | |
923 } | 928 } |
924 } else if (paint->getColor() == SK_ColorBLACK) { | |
925 blitter = allocator->createT<SkARGB32_Black_Blitter>(device, *pa int); | |
926 } else if (paint->getAlpha() == 0xFF) { | |
927 blitter = allocator->createT<SkARGB32_Opaque_Blitter>(device, *p aint); | |
928 } else { | |
929 blitter = allocator->createT<SkARGB32_Blitter>(device, *paint); | |
930 } | 929 } |
931 break; | 930 break; |
932 | 931 |
932 case kRGBA_F16_SkColorType: | |
933 // kU16_SkColorType: | |
934 blitter = SkBlitter_ARGB64_Create(device, *paint, shaderContext, all ocator); | |
935 break; | |
936 | |
933 default: | 937 default: |
934 SkDEBUGFAIL("unsupported device config"); | 938 SkDEBUGFAIL("unsupported device config"); |
935 blitter = allocator->createT<SkNullBlitter>(); | 939 blitter = allocator->createT<SkNullBlitter>(); |
936 break; | 940 break; |
937 } | 941 } |
938 | 942 |
939 if (shader3D) { | 943 if (shader3D) { |
940 SkBlitter* innerBlitter = blitter; | 944 SkBlitter* innerBlitter = blitter; |
941 // innerBlitter was allocated by allocator, which will delete it. | 945 // innerBlitter was allocated by allocator, which will delete it. |
942 // We know shaderContext or its proxies is of type Sk3DShaderContext, so we need to | 946 // We know shaderContext or its proxies is of type Sk3DShaderContext, so we need to |
(...skipping 22 matching lines...) Expand all Loading... | |
965 SkShaderBlitter::SkShaderBlitter(const SkPixmap& device, const SkPaint& paint, | 969 SkShaderBlitter::SkShaderBlitter(const SkPixmap& device, const SkPaint& paint, |
966 SkShader::Context* shaderContext) | 970 SkShader::Context* shaderContext) |
967 : INHERITED(device) | 971 : INHERITED(device) |
968 , fShader(paint.getShader()) | 972 , fShader(paint.getShader()) |
969 , fShaderContext(shaderContext) { | 973 , fShaderContext(shaderContext) { |
970 SkASSERT(fShader); | 974 SkASSERT(fShader); |
971 SkASSERT(fShaderContext); | 975 SkASSERT(fShaderContext); |
972 | 976 |
973 fShader->ref(); | 977 fShader->ref(); |
974 fShaderFlags = fShaderContext->getFlags(); | 978 fShaderFlags = fShaderContext->getFlags(); |
979 fConstInY = SkToBool(fShaderFlags & SkShader::kConstInY32_Flag); | |
975 } | 980 } |
976 | 981 |
977 SkShaderBlitter::~SkShaderBlitter() { | 982 SkShaderBlitter::~SkShaderBlitter() { |
978 fShader->unref(); | 983 fShader->unref(); |
979 } | 984 } |
980 | 985 |
981 bool SkShaderBlitter::resetShaderContext(const SkShader::ContextRec& rec) { | 986 bool SkShaderBlitter::resetShaderContext(const SkShader::ContextRec& rec) { |
982 // Only destroy the old context if we have a new one. We need to ensure to h ave a | 987 // Only destroy the old context if we have a new one. We need to ensure to h ave a |
983 // live context in fShaderContext because the storage is owned by an SkSmall Allocator | 988 // live context in fShaderContext because the storage is owned by an SkSmall Allocator |
984 // outside of this class. | 989 // outside of this class. |
985 // The new context will be of the same size as the old one because we use th e same | 990 // The new context will be of the same size as the old one because we use th e same |
986 // shader to create it. It is therefore safe to re-use the storage. | 991 // shader to create it. It is therefore safe to re-use the storage. |
987 fShaderContext->~Context(); | 992 fShaderContext->~Context(); |
988 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); | 993 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); |
989 if (nullptr == ctx) { | 994 if (nullptr == ctx) { |
990 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call | 995 // Need a valid context in fShaderContext's storage, so we can later (or our caller) call |
991 // the in-place destructor. | 996 // the in-place destructor. |
992 new (fShaderContext) SkZeroShaderContext(*fShader, rec); | 997 new (fShaderContext) SkZeroShaderContext(*fShader, rec); |
993 return false; | 998 return false; |
994 } | 999 } |
995 return true; | 1000 return true; |
996 } | 1001 } |
OLD | NEW |