| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 class GrColorCubeEffect : public GrFragmentProcessor { | 187 class GrColorCubeEffect : public GrFragmentProcessor { |
| 188 public: | 188 public: |
| 189 static GrFragmentProcessor* Create(GrTexture* colorCube) { | 189 static GrFragmentProcessor* Create(GrTexture* colorCube) { |
| 190 return (NULL != colorCube) ? SkNEW_ARGS(GrColorCubeEffect, (colorCube))
: NULL; | 190 return (NULL != colorCube) ? SkNEW_ARGS(GrColorCubeEffect, (colorCube))
: NULL; |
| 191 } | 191 } |
| 192 | 192 |
| 193 virtual ~GrColorCubeEffect(); | 193 virtual ~GrColorCubeEffect(); |
| 194 | 194 |
| 195 const char* name() const override { return "ColorCube"; } | 195 const char* name() const override { return "ColorCube"; } |
| 196 | 196 |
| 197 virtual void getGLProcessorKey(const GrGLCaps& caps, | 197 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
| 198 GrProcessorKeyBuilder* b) const override; | 198 GrProcessorKeyBuilder* b) const override; |
| 199 | 199 |
| 200 GrGLFragmentProcessor* createGLInstance() const override; | 200 GrGLFragmentProcessor* createGLInstance() const override; |
| 201 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } | 201 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } |
| 202 | 202 |
| 203 | 203 |
| 204 void onComputeInvariantOutput(GrInvariantOutput*) const override; | 204 void onComputeInvariantOutput(GrInvariantOutput*) const override; |
| 205 | 205 |
| 206 class GLProcessor : public GrGLFragmentProcessor { | 206 class GLProcessor : public GrGLFragmentProcessor { |
| 207 public: | 207 public: |
| 208 GLProcessor(const GrProcessor&); | 208 GLProcessor(const GrProcessor&); |
| 209 virtual ~GLProcessor(); | 209 virtual ~GLProcessor(); |
| 210 | 210 |
| 211 virtual void emitCode(GrGLFPBuilder*, | 211 virtual void emitCode(GrGLFPBuilder*, |
| 212 const GrFragmentProcessor&, | 212 const GrFragmentProcessor&, |
| 213 const char* outputColor, | 213 const char* outputColor, |
| 214 const char* inputColor, | 214 const char* inputColor, |
| 215 const TransformedCoordsArray&, | 215 const TransformedCoordsArray&, |
| 216 const TextureSamplerArray&) override; | 216 const TextureSamplerArray&) override; |
| 217 | 217 |
| 218 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcess
orKeyBuilder*); | 218 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); |
| 219 | 219 |
| 220 void setData(const GrGLProgramDataManager&, const GrProcessor&) override
; | 220 void setData(const GrGLProgramDataManager&, const GrProcessor&) override
; |
| 221 | 221 |
| 222 private: | 222 private: |
| 223 GrGLProgramDataManager::UniformHandle fColorCubeSizeUni; | 223 GrGLProgramDataManager::UniformHandle fColorCubeSizeUni; |
| 224 GrGLProgramDataManager::UniformHandle fColorCubeInvSizeUni; | 224 GrGLProgramDataManager::UniformHandle fColorCubeInvSizeUni; |
| 225 | 225 |
| 226 typedef GrGLFragmentProcessor INHERITED; | 226 typedef GrGLFragmentProcessor INHERITED; |
| 227 }; | 227 }; |
| 228 | 228 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 240 | 240 |
| 241 GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube) | 241 GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube) |
| 242 : fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode) { | 242 : fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode) { |
| 243 this->initClassID<GrColorCubeEffect>(); | 243 this->initClassID<GrColorCubeEffect>(); |
| 244 this->addTextureAccess(&fColorCubeAccess); | 244 this->addTextureAccess(&fColorCubeAccess); |
| 245 } | 245 } |
| 246 | 246 |
| 247 GrColorCubeEffect::~GrColorCubeEffect() { | 247 GrColorCubeEffect::~GrColorCubeEffect() { |
| 248 } | 248 } |
| 249 | 249 |
| 250 void GrColorCubeEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBu
ilder* b) const { | 250 void GrColorCubeEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey
Builder* b) const { |
| 251 GLProcessor::GenKey(*this, caps, b); | 251 GLProcessor::GenKey(*this, caps, b); |
| 252 } | 252 } |
| 253 | 253 |
| 254 GrGLFragmentProcessor* GrColorCubeEffect::createGLInstance() const { | 254 GrGLFragmentProcessor* GrColorCubeEffect::createGLInstance() const { |
| 255 return SkNEW_ARGS(GLProcessor, (*this)); | 255 return SkNEW_ARGS(GLProcessor, (*this)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 258 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
| 259 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 259 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
| 260 } | 260 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 void GrColorCubeEffect::GLProcessor::setData(const GrGLProgramDataManager& pdman
, | 328 void GrColorCubeEffect::GLProcessor::setData(const GrGLProgramDataManager& pdman
, |
| 329 const GrProcessor& proc) { | 329 const GrProcessor& proc) { |
| 330 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); | 330 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); |
| 331 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); | 331 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); |
| 332 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); | 332 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); |
| 333 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); | 333 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc, | 336 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc, |
| 337 const GrGLCaps&, GrProcessorKeyBuild
er* b) { | 337 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { |
| 338 } | 338 } |
| 339 | 339 |
| 340 bool SkColorCubeFilter::asFragmentProcessors(GrContext* context, | 340 bool SkColorCubeFilter::asFragmentProcessors(GrContext* context, |
| 341 SkTDArray<GrFragmentProcessor*>* ar
ray) const { | 341 SkTDArray<GrFragmentProcessor*>* ar
ray) const { |
| 342 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 342 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
| 343 GrUniqueKey key; | 343 GrUniqueKey key; |
| 344 GrUniqueKey::Builder builder(&key, kDomain, 2); | 344 GrUniqueKey::Builder builder(&key, kDomain, 2); |
| 345 builder[0] = fUniqueID; | 345 builder[0] = fUniqueID; |
| 346 builder[1] = fCache.cubeDimension(); | 346 builder[1] = fCache.cubeDimension(); |
| 347 builder.finish(); | 347 builder.finish(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 362 GrFragmentProcessor* frag = textureCube ? GrColorCubeEffect::Create(textureC
ube) : NULL; | 362 GrFragmentProcessor* frag = textureCube ? GrColorCubeEffect::Create(textureC
ube) : NULL; |
| 363 if (frag) { | 363 if (frag) { |
| 364 if (array) { | 364 if (array) { |
| 365 *array->append() = frag; | 365 *array->append() = frag; |
| 366 } | 366 } |
| 367 return true; | 367 return true; |
| 368 } | 368 } |
| 369 return false; | 369 return false; |
| 370 } | 370 } |
| 371 #endif | 371 #endif |
| OLD | NEW |