OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkColorCubeFilter.h" | 8 #include "SkColorCubeFilter.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 const char* name() const override { return "ColorCube"; } | 171 const char* name() const override { return "ColorCube"; } |
172 | 172 |
173 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } | 173 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } |
174 | 174 |
175 | 175 |
176 void onComputeInvariantOutput(GrInvariantOutput*) const override; | 176 void onComputeInvariantOutput(GrInvariantOutput*) const override; |
177 | 177 |
178 class GLSLProcessor : public GrGLSLFragmentProcessor { | 178 class GLSLProcessor : public GrGLSLFragmentProcessor { |
179 public: | 179 public: |
180 GLSLProcessor(const GrProcessor&); | 180 void emitCode(EmitArgs&) override; |
181 virtual ~GLSLProcessor(); | |
182 | |
183 virtual void emitCode(EmitArgs&) override; | |
184 | 181 |
185 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); | 182 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); |
186 | 183 |
187 protected: | 184 protected: |
188 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) over
ride; | 185 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) over
ride; |
189 | 186 |
190 private: | 187 private: |
191 GrGLSLProgramDataManager::UniformHandle fColorCubeSizeUni; | 188 GrGLSLProgramDataManager::UniformHandle fColorCubeSizeUni; |
192 GrGLSLProgramDataManager::UniformHandle fColorCubeInvSizeUni; | 189 GrGLSLProgramDataManager::UniformHandle fColorCubeInvSizeUni; |
193 | 190 |
(...skipping 25 matching lines...) Expand all Loading... |
219 | 216 |
220 GrColorCubeEffect::~GrColorCubeEffect() { | 217 GrColorCubeEffect::~GrColorCubeEffect() { |
221 } | 218 } |
222 | 219 |
223 void GrColorCubeEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 220 void GrColorCubeEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
224 GrProcessorKeyBuilder* b) const { | 221 GrProcessorKeyBuilder* b) const { |
225 GLSLProcessor::GenKey(*this, caps, b); | 222 GLSLProcessor::GenKey(*this, caps, b); |
226 } | 223 } |
227 | 224 |
228 GrGLSLFragmentProcessor* GrColorCubeEffect::onCreateGLSLInstance() const { | 225 GrGLSLFragmentProcessor* GrColorCubeEffect::onCreateGLSLInstance() const { |
229 return new GLSLProcessor(*this); | 226 return new GLSLProcessor; |
230 } | 227 } |
231 | 228 |
232 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 229 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
233 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 230 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
234 } | 231 } |
235 | 232 |
236 /////////////////////////////////////////////////////////////////////////////// | 233 /////////////////////////////////////////////////////////////////////////////// |
237 | 234 |
238 GrColorCubeEffect::GLSLProcessor::GLSLProcessor(const GrProcessor&) { | |
239 } | |
240 | |
241 GrColorCubeEffect::GLSLProcessor::~GLSLProcessor() { | |
242 } | |
243 | |
244 void GrColorCubeEffect::GLSLProcessor::emitCode(EmitArgs& args) { | 235 void GrColorCubeEffect::GLSLProcessor::emitCode(EmitArgs& args) { |
245 if (nullptr == args.fInputColor) { | 236 if (nullptr == args.fInputColor) { |
246 args.fInputColor = "vec4(1)"; | 237 args.fInputColor = "vec4(1)"; |
247 } | 238 } |
248 | 239 |
249 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 240 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
250 fColorCubeSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme
nt_Visibility, | 241 fColorCubeSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme
nt_Visibility, |
251 kFloat_GrSLType, kDefault_GrS
LPrecision, | 242 kFloat_GrSLType, kDefault_GrS
LPrecision, |
252 "Size"); | 243 "Size"); |
253 const char* colorCubeSizeUni = uniformHandler->getUniformCStr(fColorCubeSize
Uni); | 244 const char* colorCubeSizeUni = uniformHandler->getUniformCStr(fColorCubeSize
Uni); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 if (textureCube) { | 319 if (textureCube) { |
329 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); | 320 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); |
330 } else { | 321 } else { |
331 return nullptr; | 322 return nullptr; |
332 } | 323 } |
333 } | 324 } |
334 | 325 |
335 return GrColorCubeEffect::Create(textureCube); | 326 return GrColorCubeEffect::Create(textureCube); |
336 } | 327 } |
337 #endif | 328 #endif |
OLD | NEW |