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 "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 : GrGLEffect(factory ) { | 977 : GrGLEffect(factory ) { |
978 } | 978 } |
979 virtual void emitCode(GrGLShaderBuilder* builder, | 979 virtual void emitCode(GrGLShaderBuilder* builder, |
980 const GrDrawEffect& drawEffect, | 980 const GrDrawEffect& drawEffect, |
981 EffectKey key, | 981 EffectKey key, |
982 const char* outputColor, | 982 const char* outputColor, |
983 const char* inputColor, | 983 const char* inputColor, |
984 const TextureSamplerArray& samplers) SK_OVERRIDE { | 984 const TextureSamplerArray& samplers) SK_OVERRIDE { |
985 const char* dstColorName = builder->dstColor(); | 985 const char* dstColorName = builder->dstColor(); |
986 GrAssert(NULL != dstColorName); | 986 GrAssert(NULL != dstColorName); |
987 builder->fsCodeAppendf("\t\t%s.a = 1.0 - (1.0 - %s.a) * (1.0 - %s.a)
;\n", | 987 if (NULL == inputColor){ |
988 outputColor, dstColorName, inputColor); | 988 // the input color is solid white |
989 builder->fsCodeAppendf("\t\t%s.rgb = min((1.0 - %s.a) * %s.rgb + %s.
rgb," | 989 builder->fsCodeAppendf("\t\t%s.a = 1.0;\n", outputColor); |
990 " (1.0 - %s.a) * %s.rgb + %s.
rgb);\n", | 990 builder->fsCodeAppendf("\t\t%s.rgb = vec3(1.0, 1.0, 1.0) - %s.aa
a + %s.rgb;\n", |
991 outputColor, | 991 outputColor, dstColorName, dstColorName); |
992 inputColor, dstColorName, inputColor, | 992 } else { |
993 dstColorName, inputColor, dstColorName); | 993 builder->fsCodeAppendf("\t\t%s.a = 1.0 - (1.0 - %s.a) * (1.0 - %
s.a);\n", |
| 994 outputColor, dstColorName, inputColor); |
| 995 builder->fsCodeAppendf("\t\t%s.rgb = min((1.0 - %s.a) * %s.rgb +
%s.rgb," |
| 996 " (1.0 - %s.a) * %s.rgb +
%s.rgb);\n", |
| 997 outputColor, |
| 998 inputColor, dstColorName, inputColor, |
| 999 dstColorName, inputColor, dstColorName); |
| 1000 } |
994 } | 1001 } |
995 | 1002 |
996 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { r
eturn 0; } | 1003 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { r
eturn 0; } |
997 | 1004 |
998 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_
OVERRIDE {} | 1005 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_
OVERRIDE {} |
999 | 1006 |
1000 private: | 1007 private: |
1001 typedef GrGLEffect INHERITED; | 1008 typedef GrGLEffect INHERITED; |
1002 }; | 1009 }; |
1003 | 1010 |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 return proc16; | 1612 return proc16; |
1606 } | 1613 } |
1607 | 1614 |
1608 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1615 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1609 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1616 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1610 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) | 1617 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) |
1611 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) | 1618 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) |
1612 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) | 1619 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) |
1613 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) | 1620 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) |
1614 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1621 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |