| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 GrGLFragmentProcessor* createGLInstance() const override { | 73 GrGLFragmentProcessor* createGLInstance() const override { |
| 74 return SkNEW_ARGS(GLProcessor, (*this)); | 74 return SkNEW_ARGS(GLProcessor, (*this)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 class GLProcessor : public GrGLFragmentProcessor { | 77 class GLProcessor : public GrGLFragmentProcessor { |
| 78 public: | 78 public: |
| 79 GLProcessor(const GrProcessor&) {} | 79 GLProcessor(const GrProcessor&) {} |
| 80 | 80 |
| 81 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} | 81 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} |
| 82 | 82 |
| 83 virtual void emitCode(GrGLFPBuilder* builder, | 83 virtual void emitCode(EmitArgs& args) override { |
| 84 const GrFragmentProcessor&, | 84 if (NULL == args.fInputColor) { |
| 85 const char* outputColor, | 85 args.fInputColor = "vec4(1)"; |
| 86 const char* inputColor, | |
| 87 const TransformedCoordsArray&, | |
| 88 const TextureSamplerArray&) override { | |
| 89 if (NULL == inputColor) { | |
| 90 inputColor = "vec4(1)"; | |
| 91 } | 86 } |
| 92 | 87 |
| 93 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder()
; | 88 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBui
lder(); |
| 94 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", | 89 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", |
| 95 SK_ITU_BT709_LUM_COEFF_R, | 90 SK_ITU_BT709_LUM_COEFF_R, |
| 96 SK_ITU_BT709_LUM_COEFF_G, | 91 SK_ITU_BT709_LUM_COEFF_G, |
| 97 SK_ITU_BT709_LUM_COEFF_B, | 92 SK_ITU_BT709_LUM_COEFF_B, |
| 98 inputColor); | 93 args.fInputColor); |
| 99 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", | 94 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", |
| 100 outputColor); | 95 args.fOutputColor); |
| 101 | 96 |
| 102 } | 97 } |
| 103 | 98 |
| 104 private: | 99 private: |
| 105 typedef GrGLFragmentProcessor INHERITED; | 100 typedef GrGLFragmentProcessor INHERITED; |
| 106 }; | 101 }; |
| 107 | 102 |
| 108 private: | 103 private: |
| 109 LumaColorFilterEffect() { | 104 LumaColorFilterEffect() { |
| 110 this->initClassID<LumaColorFilterEffect>(); | 105 this->initClassID<LumaColorFilterEffect>(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 128 *array->append() = frag; | 123 *array->append() = frag; |
| 129 } else { | 124 } else { |
| 130 frag->unref(); | 125 frag->unref(); |
| 131 SkDEBUGCODE(frag = NULL;) | 126 SkDEBUGCODE(frag = NULL;) |
| 132 } | 127 } |
| 133 return true; | 128 return true; |
| 134 } | 129 } |
| 135 return false; | 130 return false; |
| 136 } | 131 } |
| 137 #endif | 132 #endif |
| OLD | NEW |