| 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" |
| 11 #include "SkOpts.h" | 11 #include "SkOpts.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkUnPreMultiply.h" | 13 #include "SkUnPreMultiply.h" |
| 14 #include "SkWriteBuffer.h" | 14 #include "SkWriteBuffer.h" |
| 15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 16 #include "GrContext.h" | 16 #include "GrContext.h" |
| 17 #include "GrCoordTransform.h" | 17 #include "GrCoordTransform.h" |
| 18 #include "GrInvariantOutput.h" | 18 #include "GrInvariantOutput.h" |
| 19 #include "GrTexturePriv.h" | 19 #include "GrTexturePriv.h" |
| 20 #include "SkGr.h" | 20 #include "SkGr.h" |
| 21 #include "gl/GrGLFragmentProcessor.h" | 21 #include "gl/GrGLFragmentProcessor.h" |
| 22 #include "gl/builders/GrGLProgramBuilder.h" | 22 #include "gl/builders/GrGLProgramBuilder.h" |
| 23 #include "glsl/GrGLSLProgramDataManager.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 int32_t SkNextColorCubeUniqueID() { | 29 int32_t SkNextColorCubeUniqueID() { |
| 29 static int32_t gColorCubeUniqueID; | 30 static int32_t gColorCubeUniqueID; |
| 30 // do a loop in case our global wraps around, as we never want to return a 0 | 31 // do a loop in case our global wraps around, as we never want to return a 0 |
| 31 int32_t genID; | 32 int32_t genID; |
| 32 do { | 33 do { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 class GLProcessor : public GrGLFragmentProcessor { | 177 class GLProcessor : public GrGLFragmentProcessor { |
| 177 public: | 178 public: |
| 178 GLProcessor(const GrProcessor&); | 179 GLProcessor(const GrProcessor&); |
| 179 virtual ~GLProcessor(); | 180 virtual ~GLProcessor(); |
| 180 | 181 |
| 181 virtual void emitCode(EmitArgs&) override; | 182 virtual void emitCode(EmitArgs&) override; |
| 182 | 183 |
| 183 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); | 184 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); |
| 184 | 185 |
| 185 protected: | 186 protected: |
| 186 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) overri
de; | 187 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) over
ride; |
| 187 | 188 |
| 188 private: | 189 private: |
| 189 GrGLProgramDataManager::UniformHandle fColorCubeSizeUni; | 190 GrGLSLProgramDataManager::UniformHandle fColorCubeSizeUni; |
| 190 GrGLProgramDataManager::UniformHandle fColorCubeInvSizeUni; | 191 GrGLSLProgramDataManager::UniformHandle fColorCubeInvSizeUni; |
| 191 | 192 |
| 192 typedef GrGLFragmentProcessor INHERITED; | 193 typedef GrGLFragmentProcessor INHERITED; |
| 193 }; | 194 }; |
| 194 | 195 |
| 195 private: | 196 private: |
| 196 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 197 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 197 GrProcessorKeyBuilder* b) const override; | 198 GrProcessorKeyBuilder* b) const override; |
| 198 | 199 |
| 199 GrGLFragmentProcessor* onCreateGLInstance() const override; | 200 GrGLFragmentProcessor* onCreateGLInstance() const override; |
| 200 | 201 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 fsBuilder->codeAppendf("%s = vec4(mix(", args.fOutputColor); | 285 fsBuilder->codeAppendf("%s = vec4(mix(", args.fOutputColor); |
| 285 fsBuilder->appendTextureLookup(args.fSamplers[0], cCoords1); | 286 fsBuilder->appendTextureLookup(args.fSamplers[0], cCoords1); |
| 286 fsBuilder->codeAppend(".rgb, "); | 287 fsBuilder->codeAppend(".rgb, "); |
| 287 fsBuilder->appendTextureLookup(args.fSamplers[0], cCoords2); | 288 fsBuilder->appendTextureLookup(args.fSamplers[0], cCoords2); |
| 288 | 289 |
| 289 // Premultiply color by alpha. Note that the input alpha is not modified by
this shader. | 290 // Premultiply color by alpha. Note that the input alpha is not modified by
this shader. |
| 290 fsBuilder->codeAppendf(".rgb, fract(%s.b)) * vec3(%s), %s.a);\n", | 291 fsBuilder->codeAppendf(".rgb, fract(%s.b)) * vec3(%s), %s.a);\n", |
| 291 cubeIdx, nonZeroAlpha, args.fInputColor); | 292 cubeIdx, nonZeroAlpha, args.fInputColor); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void GrColorCubeEffect::GLProcessor::onSetData(const GrGLProgramDataManager& pdm
an, | 295 void GrColorCubeEffect::GLProcessor::onSetData(const GrGLSLProgramDataManager& p
dman, |
| 295 const GrProcessor& proc) { | 296 const GrProcessor& proc) { |
| 296 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); | 297 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); |
| 297 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); | 298 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); |
| 298 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); | 299 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); |
| 299 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); | 300 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); |
| 300 } | 301 } |
| 301 | 302 |
| 302 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc, | 303 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc, |
| 303 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { | 304 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { |
| 304 } | 305 } |
| 305 | 306 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 324 if (textureCube) { | 325 if (textureCube) { |
| 325 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); | 326 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); |
| 326 } else { | 327 } else { |
| 327 return nullptr; | 328 return nullptr; |
| 328 } | 329 } |
| 329 } | 330 } |
| 330 | 331 |
| 331 return GrColorCubeEffect::Create(textureCube); | 332 return GrColorCubeEffect::Create(textureCube); |
| 332 } | 333 } |
| 333 #endif | 334 #endif |
| OLD | NEW |