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 "SkAlphaThresholdFilter.h" | 8 #include "SkAlphaThresholdFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 GrCoordTransform fMaskCoordTransform; | 113 GrCoordTransform fMaskCoordTransform; |
114 GrTextureAccess fMaskTextureAccess; | 114 GrTextureAccess fMaskTextureAccess; |
115 | 115 |
116 typedef GrFragmentProcessor INHERITED; | 116 typedef GrFragmentProcessor INHERITED; |
117 }; | 117 }; |
118 | 118 |
119 class GrGLAlphaThresholdEffect : public GrGLFragmentProcessor { | 119 class GrGLAlphaThresholdEffect : public GrGLFragmentProcessor { |
120 public: | 120 public: |
121 GrGLAlphaThresholdEffect(const GrBackendProcessorFactory&, const GrProcessor
&); | 121 GrGLAlphaThresholdEffect(const GrBackendProcessorFactory&, const GrProcessor
&); |
122 | 122 |
123 virtual void emitCode(GrGLProgramBuilder*, | 123 virtual void emitCode(GrGLFPBuilder*, |
124 const GrFragmentProcessor&, | 124 const GrFragmentProcessor&, |
125 const GrProcessorKey&, | 125 const GrProcessorKey&, |
126 const char* outputColor, | 126 const char* outputColor, |
127 const char* inputColor, | 127 const char* inputColor, |
128 const TransformedCoordsArray&, | 128 const TransformedCoordsArray&, |
129 const TextureSamplerArray&) SK_OVERRIDE; | 129 const TextureSamplerArray&) SK_OVERRIDE; |
130 | 130 |
131 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 131 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; |
132 | 132 |
133 private: | 133 private: |
134 | 134 |
135 GrGLProgramDataManager::UniformHandle fInnerThresholdVar; | 135 GrGLProgramDataManager::UniformHandle fInnerThresholdVar; |
136 GrGLProgramDataManager::UniformHandle fOuterThresholdVar; | 136 GrGLProgramDataManager::UniformHandle fOuterThresholdVar; |
137 | 137 |
138 typedef GrGLFragmentProcessor INHERITED; | 138 typedef GrGLFragmentProcessor INHERITED; |
139 }; | 139 }; |
140 | 140 |
141 GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendProcessorFacto
ry& factory, | 141 GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendProcessorFacto
ry& factory, |
142 const GrProcessor&) | 142 const GrProcessor&) |
143 : INHERITED(factory) { | 143 : INHERITED(factory) { |
144 } | 144 } |
145 | 145 |
146 void GrGLAlphaThresholdEffect::emitCode(GrGLProgramBuilder* builder, | 146 void GrGLAlphaThresholdEffect::emitCode(GrGLFPBuilder* builder, |
147 const GrFragmentProcessor&, | 147 const GrFragmentProcessor&, |
148 const GrProcessorKey& key, | 148 const GrProcessorKey& key, |
149 const char* outputColor, | 149 const char* outputColor, |
150 const char* inputColor, | 150 const char* inputColor, |
151 const TransformedCoordsArray& coords, | 151 const TransformedCoordsArray& coords, |
152 const TextureSamplerArray& samplers) { | 152 const TextureSamplerArray& samplers) { |
153 fInnerThresholdVar = builder->addUniform( | 153 fInnerThresholdVar = builder->addUniform( |
154 GrGLProgramBuilder::kFragment_Visibility, | 154 GrGLProgramBuilder::kFragment_Visibility, |
155 kFloat_GrSLType, "inner_threshold"); | 155 kFloat_GrSLType, "inner_threshold"); |
156 fOuterThresholdVar = builder->addUniform( | 156 fOuterThresholdVar = builder->addUniform( |
157 GrGLProgramBuilder::kFragment_Visibility, | 157 GrGLProgramBuilder::kFragment_Visibility, |
158 kFloat_GrSLType, "outer_threshold"); | 158 kFloat_GrSLType, "outer_threshold"); |
159 | 159 |
160 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 160 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
161 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); | 161 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
162 SkString maskCoords2D = fsBuilder->ensureFSCoords2D(coords, 1); | 162 SkString maskCoords2D = fsBuilder->ensureFSCoords2D(coords, 1); |
163 | 163 |
164 fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); | 164 fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); |
165 fsBuilder->codeAppendf("\t\tvec2 mask_coord = %s;\n", maskCoords2D.c_str()); | 165 fsBuilder->codeAppendf("\t\tvec2 mask_coord = %s;\n", maskCoords2D.c_str()); |
166 fsBuilder->codeAppend("\t\tvec4 input_color = "); | 166 fsBuilder->codeAppend("\t\tvec4 input_color = "); |
167 fsBuilder->appendTextureLookup(samplers[0], "coord"); | 167 fsBuilder->appendTextureLookup(samplers[0], "coord"); |
168 fsBuilder->codeAppend(";\n"); | 168 fsBuilder->codeAppend(";\n"); |
169 fsBuilder->codeAppend("\t\tvec4 mask_color = "); | 169 fsBuilder->codeAppend("\t\tvec4 mask_color = "); |
170 fsBuilder->appendTextureLookup(samplers[1], "mask_coord"); | 170 fsBuilder->appendTextureLookup(samplers[1], "mask_coord"); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 (U8CPU)(SkColorGetG(source) *
scale), | 379 (U8CPU)(SkColorGetG(source) *
scale), |
380 (U8CPU)(SkColorGetB(source) *
scale)); | 380 (U8CPU)(SkColorGetB(source) *
scale)); |
381 } | 381 } |
382 } | 382 } |
383 dptr[y * dst->width() + x] = output_color; | 383 dptr[y * dst->width() + x] = output_color; |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 return true; | 387 return true; |
388 } | 388 } |
OLD | NEW |