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" |
11 #include "SkString.h" | 11 #include "SkString.h" |
12 | 12 |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #include "GrInvariantOutput.h" | 15 #include "GrInvariantOutput.h" |
16 #include "gl/GrGLFragmentProcessor.h" | 16 #include "gl/GrGLFragmentProcessor.h" |
17 #include "gl/builders/GrGLProgramBuilder.h" | 17 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 18 #include "glsl/GrGLSLProgramBuilder.h" |
18 #endif | 19 #endif |
19 | 20 |
20 void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count, | 21 void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count, |
21 SkPMColor dst[]) const { | 22 SkPMColor dst[]) const { |
22 for (int i = 0; i < count; ++i) { | 23 for (int i = 0; i < count; ++i) { |
23 SkPMColor c = src[i]; | 24 SkPMColor c = src[i]; |
24 | 25 |
25 /* | 26 /* |
26 * While LuminanceToAlpha is defined to operate on un-premultiplied | 27 * While LuminanceToAlpha is defined to operate on un-premultiplied |
27 * inputs, due to the final alpha scaling it can be computed based on | 28 * inputs, due to the final alpha scaling it can be computed based on |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 public: | 65 public: |
65 GLProcessor(const GrProcessor&) {} | 66 GLProcessor(const GrProcessor&) {} |
66 | 67 |
67 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} | 68 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} |
68 | 69 |
69 virtual void emitCode(EmitArgs& args) override { | 70 virtual void emitCode(EmitArgs& args) override { |
70 if (nullptr == args.fInputColor) { | 71 if (nullptr == args.fInputColor) { |
71 args.fInputColor = "vec4(1)"; | 72 args.fInputColor = "vec4(1)"; |
72 } | 73 } |
73 | 74 |
74 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBui
lder(); | 75 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderB
uilder(); |
75 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", | 76 fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb)
;\n", |
76 SK_ITU_BT709_LUM_COEFF_R, | 77 SK_ITU_BT709_LUM_COEFF_R, |
77 SK_ITU_BT709_LUM_COEFF_G, | 78 SK_ITU_BT709_LUM_COEFF_G, |
78 SK_ITU_BT709_LUM_COEFF_B, | 79 SK_ITU_BT709_LUM_COEFF_B, |
79 args.fInputColor); | 80 args.fInputColor); |
80 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", | 81 fsBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n", |
81 args.fOutputColor); | 82 args.fOutputColor); |
82 | 83 |
83 } | 84 } |
84 | 85 |
(...skipping 20 matching lines...) Expand all Loading... |
105 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), | 106 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), |
106 GrInvariantOutput::kWill_ReadInput); | 107 GrInvariantOutput::kWill_ReadInput); |
107 } | 108 } |
108 }; | 109 }; |
109 | 110 |
110 const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) co
nst { | 111 const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) co
nst { |
111 | 112 |
112 return LumaColorFilterEffect::Create(); | 113 return LumaColorFilterEffect::Create(); |
113 } | 114 } |
114 #endif | 115 #endif |
OLD | NEW |