| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 class GLProcessor : public GrGLFragmentProcessor { | 76 class GLProcessor : public GrGLFragmentProcessor { |
| 77 public: | 77 public: |
| 78 GLProcessor(const GrBackendProcessorFactory& factory, | 78 GLProcessor(const GrBackendProcessorFactory& factory, |
| 79 const GrProcessor&) | 79 const GrProcessor&) |
| 80 : INHERITED(factory) { | 80 : INHERITED(factory) { |
| 81 } | 81 } |
| 82 | 82 |
| 83 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu
ilder* b) {} | 83 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu
ilder* b) {} |
| 84 | 84 |
| 85 virtual void emitCode(GrGLProgramBuilder* builder, | 85 virtual void emitCode(GrGLFPBuilder* builder, |
| 86 const GrFragmentProcessor&, | 86 const GrFragmentProcessor&, |
| 87 const GrProcessorKey&, | 87 const GrProcessorKey&, |
| 88 const char* outputColor, | 88 const char* outputColor, |
| 89 const char* inputColor, | 89 const char* inputColor, |
| 90 const TransformedCoordsArray&, | 90 const TransformedCoordsArray&, |
| 91 const TextureSamplerArray&) SK_OVERRIDE { | 91 const TextureSamplerArray&) SK_OVERRIDE { |
| 92 if (NULL == inputColor) { | 92 if (NULL == inputColor) { |
| 93 inputColor = "vec4(1)"; | 93 inputColor = "vec4(1)"; |
| 94 } | 94 } |
| 95 | 95 |
| 96 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui
lder(); | 96 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder
(); |
| 97 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", | 97 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", |
| 98 SK_ITU_BT709_LUM_COEFF_R, | 98 SK_ITU_BT709_LUM_COEFF_R, |
| 99 SK_ITU_BT709_LUM_COEFF_G, | 99 SK_ITU_BT709_LUM_COEFF_G, |
| 100 SK_ITU_BT709_LUM_COEFF_B, | 100 SK_ITU_BT709_LUM_COEFF_B, |
| 101 inputColor); | 101 inputColor); |
| 102 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", | 102 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", |
| 103 outputColor); | 103 outputColor); |
| 104 | 104 |
| 105 } | 105 } |
| 106 | 106 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 118 inout->fColor = GrColorPackRGBA(0, 0, 0, GrColorUnpackA(inout->fColor)); | 118 inout->fColor = GrColorPackRGBA(0, 0, 0, GrColorUnpackA(inout->fColor)); |
| 119 inout->fValidFlags = kRGB_GrColorComponentFlags; | 119 inout->fValidFlags = kRGB_GrColorComponentFlags; |
| 120 inout->fIsSingleComponent = false; | 120 inout->fIsSingleComponent = false; |
| 121 } | 121 } |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const { | 124 GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const { |
| 125 return LumaColorFilterEffect::Create(); | 125 return LumaColorFilterEffect::Create(); |
| 126 } | 126 } |
| 127 #endif | 127 #endif |
| OLD | NEW |