| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 typedef SkShader INHERITED; | 123 typedef SkShader INHERITED; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 //////////////////////////////////////////////////////////////////////////// | 126 //////////////////////////////////////////////////////////////////////////// |
| 127 | 127 |
| 128 #if SK_SUPPORT_GPU | 128 #if SK_SUPPORT_GPU |
| 129 | 129 |
| 130 #include "GrCoordTransform.h" | 130 #include "GrCoordTransform.h" |
| 131 #include "GrFragmentProcessor.h" | 131 #include "GrFragmentProcessor.h" |
| 132 #include "GrTextureAccess.h" | 132 #include "GrTextureAccess.h" |
| 133 #include "gl/GrGLFragmentProcessor.h" | 133 #include "glsl/GrGLSLFragmentProcessor.h" |
| 134 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 134 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 135 #include "glsl/GrGLSLProgramBuilder.h" | 135 #include "glsl/GrGLSLProgramBuilder.h" |
| 136 #include "glsl/GrGLSLProgramDataManager.h" | 136 #include "glsl/GrGLSLProgramDataManager.h" |
| 137 #include "SkGr.h" | 137 #include "SkGr.h" |
| 138 #include "SkGrPriv.h" | 138 #include "SkGrPriv.h" |
| 139 | 139 |
| 140 class LightingFP : public GrFragmentProcessor { | 140 class LightingFP : public GrFragmentProcessor { |
| 141 public: | 141 public: |
| 142 LightingFP(GrTexture* diffuse, GrTexture* normal, const SkMatrix& diffMatrix
, | 142 LightingFP(GrTexture* diffuse, GrTexture* normal, const SkMatrix& diffMatrix
, |
| 143 const SkMatrix& normMatrix, const GrTextureParams& diffParams, | 143 const SkMatrix& normMatrix, const GrTextureParams& diffParams, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 } else { | 161 } else { |
| 162 // TODO: handle more than one of these | 162 // TODO: handle more than one of these |
| 163 fLightColor = lights->light(i).color(); | 163 fLightColor = lights->light(i).color(); |
| 164 fLightDir = lights->light(i).dir(); | 164 fLightDir = lights->light(i).dir(); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 this->initClassID<LightingFP>(); | 168 this->initClassID<LightingFP>(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 class LightingGLFP : public GrGLFragmentProcessor { | 171 class LightingGLFP : public GrGLSLFragmentProcessor { |
| 172 public: | 172 public: |
| 173 LightingGLFP() { | 173 LightingGLFP() { |
| 174 fLightDir.fX = 10000.0f; | 174 fLightDir.fX = 10000.0f; |
| 175 fLightColor.fX = 0.0f; | 175 fLightColor.fX = 0.0f; |
| 176 fAmbientColor.fX = 0.0f; | 176 fAmbientColor.fX = 0.0f; |
| 177 fInvNormRotation.set(0.0f, 0.0f); | 177 fInvNormRotation.set(0.0f, 0.0f); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void emitCode(EmitArgs& args) override { | 180 void emitCode(EmitArgs& args) override { |
| 181 | 181 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 290 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 291 inout->mulByUnknownFourComponents(); | 291 inout->mulByUnknownFourComponents(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 const SkVector3& lightDir() const { return fLightDir; } | 294 const SkVector3& lightDir() const { return fLightDir; } |
| 295 const SkColor3f& lightColor() const { return fLightColor; } | 295 const SkColor3f& lightColor() const { return fLightColor; } |
| 296 const SkColor3f& ambientColor() const { return fAmbientColor; } | 296 const SkColor3f& ambientColor() const { return fAmbientColor; } |
| 297 const SkVector& invNormRotation() const { return fInvNormRotation; } | 297 const SkVector& invNormRotation() const { return fInvNormRotation; } |
| 298 | 298 |
| 299 private: | 299 private: |
| 300 GrGLFragmentProcessor* onCreateGLInstance() const override { return new Ligh
tingGLFP; } | 300 GrGLSLFragmentProcessor* onCreateGLInstance() const override { return new Li
ghtingGLFP; } |
| 301 | 301 |
| 302 bool onIsEqual(const GrFragmentProcessor& proc) const override { | 302 bool onIsEqual(const GrFragmentProcessor& proc) const override { |
| 303 const LightingFP& lightingFP = proc.cast<LightingFP>(); | 303 const LightingFP& lightingFP = proc.cast<LightingFP>(); |
| 304 return fDiffDeviceTransform == lightingFP.fDiffDeviceTransform && | 304 return fDiffDeviceTransform == lightingFP.fDiffDeviceTransform && |
| 305 fNormDeviceTransform == lightingFP.fNormDeviceTransform && | 305 fNormDeviceTransform == lightingFP.fNormDeviceTransform && |
| 306 fDiffuseTextureAccess == lightingFP.fDiffuseTextureAccess && | 306 fDiffuseTextureAccess == lightingFP.fDiffuseTextureAccess && |
| 307 fNormalTextureAccess == lightingFP.fNormalTextureAccess && | 307 fNormalTextureAccess == lightingFP.fNormalTextureAccess && |
| 308 fLightDir == lightingFP.fLightDir && | 308 fLightDir == lightingFP.fLightDir && |
| 309 fLightColor == lightingFP.fLightColor && | 309 fLightColor == lightingFP.fLightColor && |
| 310 fAmbientColor == lightingFP.fAmbientColor && | 310 fAmbientColor == lightingFP.fAmbientColor && |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 normLocalM); | 714 normLocalM); |
| 715 } | 715 } |
| 716 | 716 |
| 717 /////////////////////////////////////////////////////////////////////////////// | 717 /////////////////////////////////////////////////////////////////////////////// |
| 718 | 718 |
| 719 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 719 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
| 720 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 720 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
| 721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| 722 | 722 |
| 723 /////////////////////////////////////////////////////////////////////////////// | 723 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |