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

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

Issue 14418005: Remove redundant setting of alpha in hard-light GPU shader. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 /* 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 const GrDrawEffect& drawEffect, 989 const GrDrawEffect& drawEffect,
990 EffectKey key, 990 EffectKey key,
991 const char* outputColor, 991 const char* outputColor,
992 const char* inputColor, 992 const char* inputColor,
993 const TextureSamplerArray& samplers) SK_OVERRIDE { 993 const TextureSamplerArray& samplers) SK_OVERRIDE {
994 const char* dstColor = builder->dstColor(); 994 const char* dstColor = builder->dstColor();
995 GrAssert(NULL != dstColor); 995 GrAssert(NULL != dstColor);
996 996
997 // We don't try to optimize for this case at all 997 // We don't try to optimize for this case at all
998 if (NULL == inputColor) { 998 if (NULL == inputColor) {
999 builder->fsCodeAppendf("\tconst vec4 ones = %s;\n", GrGLSLOnesVe cf(4)); 999 builder->fsCodeAppendf("\t\tconst vec4 ones = %s;\n", GrGLSLOnes Vecf(4));
1000 inputColor = "ones"; 1000 inputColor = "ones";
1001 } 1001 }
1002 1002
1003 SkXfermode::Mode mode = drawEffect.castEffect<XferEffect>().mode(); 1003 SkXfermode::Mode mode = drawEffect.castEffect<XferEffect>().mode();
1004 builder->fsCodeAppendf("\t\t// SkXfermode::Mode: %s\n", SkXfermode:: ModeName(mode)); 1004 builder->fsCodeAppendf("\t\t// SkXfermode::Mode: %s\n", SkXfermode:: ModeName(mode));
1005 1005
1006 // These all perform src-over on the alpha channel. 1006 // These all perform src-over on the alpha channel.
1007 builder->fsCodeAppendf("\t\t%s.a = %s.a + (1.0 - %s.a) * %s.a;\n", 1007 builder->fsCodeAppendf("\t\t%s.a = %s.a + (1.0 - %s.a) * %s.a;\n",
1008 outputColor, inputColor, inputColor, dstColo r); 1008 outputColor, inputColor, inputColor, dstColo r);
1009 1009
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 return drawEffect.castEffect<XferEffect>().mode(); 1128 return drawEffect.castEffect<XferEffect>().mode();
1129 } 1129 }
1130 1130
1131 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {} 1131 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {}
1132 1132
1133 private: 1133 private:
1134 static void HardLight(GrGLShaderBuilder* builder, 1134 static void HardLight(GrGLShaderBuilder* builder,
1135 const char* final, 1135 const char* final,
1136 const char* src, 1136 const char* src,
1137 const char* dst) { 1137 const char* dst) {
1138 builder->fsCodeAppendf("\t\t%s.a = 1.0 - (1.0 - %s.a) * (1.0 - %s.a) ;\n",
1139 final, dst, src);
1140 builder->fsCodeAppendf("\t\t%s.rgb = mix(2.0 * %s.rgb * %s.rgb, ", 1138 builder->fsCodeAppendf("\t\t%s.rgb = mix(2.0 * %s.rgb * %s.rgb, ",
1141 final, src, dst); 1139 final, src, dst);
1142 builder->fsCodeAppendf("%s.aaa * %s.aaa - 2.0 * (%s.aaa - %s.rgb) * (%s.aaa - %s.rgb),", 1140 builder->fsCodeAppendf("%s.aaa * %s.aaa - 2.0 * (%s.aaa - %s.rgb) * (%s.aaa - %s.rgb),",
1143 src, dst, dst, dst, src, src); 1141 src, dst, dst, dst, src, src);
1144 builder->fsCodeAppendf("vec3(greaterThan(2.0 * %s.rgb, %s.aaa)));\n" , 1142 builder->fsCodeAppendf("vec3(greaterThan(2.0 * %s.rgb, %s.aaa)));\n" ,
1145 src, src); 1143 src, src);
1146 builder->fsCodeAppendf("\t\t%s.rgb += %s.rgb * (1.0 - %s.a) + %s.rgb * (1.0 - %s.a);\n", 1144 builder->fsCodeAppendf("\t\t%s.rgb += %s.rgb * (1.0 - %s.a) + %s.rgb * (1.0 - %s.a);\n",
1147 final, src, dst, dst, src); 1145 final, src, dst, dst, src);
1148 } 1146 }
1149 1147
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 return proc16; 1968 return proc16;
1971 } 1969 }
1972 1970
1973 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1971 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) 1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) 1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
1977 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) 1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
1978 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) 1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
1979 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1977 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698