OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 "SkLumaColorFilter.h" | 8 #include "SkLumaColorFilter.h" |
9 | 9 |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 public: | 65 public: |
66 GLSLProcessor(const GrProcessor&) {} | 66 GLSLProcessor(const GrProcessor&) {} |
67 | 67 |
68 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} | 68 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} |
69 | 69 |
70 virtual void emitCode(EmitArgs& args) override { | 70 virtual void emitCode(EmitArgs& args) override { |
71 if (nullptr == args.fInputColor) { | 71 if (nullptr == args.fInputColor) { |
72 args.fInputColor = "vec4(1)"; | 72 args.fInputColor = "vec4(1)"; |
73 } | 73 } |
74 | 74 |
75 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderB
uilder(); | 75 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
76 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", | 76 fragBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rg
b);\n", |
77 SK_ITU_BT709_LUM_COEFF_R, | 77 SK_ITU_BT709_LUM_COEFF_R, |
78 SK_ITU_BT709_LUM_COEFF_G, | 78 SK_ITU_BT709_LUM_COEFF_G, |
79 SK_ITU_BT709_LUM_COEFF_B, | 79 SK_ITU_BT709_LUM_COEFF_B, |
80 args.fInputColor); | 80 args.fInputColor); |
81 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", | 81 fragBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", |
82 args.fOutputColor); | 82 args.fOutputColor); |
83 | 83 |
84 } | 84 } |
85 | 85 |
86 private: | 86 private: |
87 typedef GrGLSLFragmentProcessor INHERITED; | 87 typedef GrGLSLFragmentProcessor INHERITED; |
88 }; | 88 }; |
89 | 89 |
90 private: | 90 private: |
91 LumaColorFilterEffect() { | 91 LumaColorFilterEffect() { |
92 this->initClassID<LumaColorFilterEffect>(); | 92 this->initClassID<LumaColorFilterEffect>(); |
(...skipping 15 matching lines...) Expand all Loading... |
108 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), | 108 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), |
109 GrInvariantOutput::kWill_ReadInput); | 109 GrInvariantOutput::kWill_ReadInput); |
110 } | 110 } |
111 }; | 111 }; |
112 | 112 |
113 const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) co
nst { | 113 const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) co
nst { |
114 | 114 |
115 return LumaColorFilterEffect::Create(); | 115 return LumaColorFilterEffect::Create(); |
116 } | 116 } |
117 #endif | 117 #endif |
OLD | NEW |