| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 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 "GrInvariantOutput.h" |
| 132 #include "GrTextureAccess.h" | 133 #include "GrTextureAccess.h" |
| 133 #include "glsl/GrGLSLFragmentProcessor.h" | 134 #include "glsl/GrGLSLFragmentProcessor.h" |
| 134 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 135 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 135 #include "glsl/GrGLSLProgramBuilder.h" | |
| 136 #include "glsl/GrGLSLProgramDataManager.h" | 136 #include "glsl/GrGLSLProgramDataManager.h" |
| 137 #include "glsl/GrGLSLUniformHandler.h" |
| 137 #include "SkGr.h" | 138 #include "SkGr.h" |
| 138 #include "SkGrPriv.h" | 139 #include "SkGrPriv.h" |
| 139 | 140 |
| 140 class LightingFP : public GrFragmentProcessor { | 141 class LightingFP : public GrFragmentProcessor { |
| 141 public: | 142 public: |
| 142 LightingFP(GrTexture* diffuse, GrTexture* normal, const SkMatrix& diffMatrix
, | 143 LightingFP(GrTexture* diffuse, GrTexture* normal, const SkMatrix& diffMatrix
, |
| 143 const SkMatrix& normMatrix, const GrTextureParams& diffParams, | 144 const SkMatrix& normMatrix, const GrTextureParams& diffParams, |
| 144 const GrTextureParams& normParams, const SkLightingShader::Lights
* lights, | 145 const GrTextureParams& normParams, const SkLightingShader::Lights
* lights, |
| 145 const SkVector& invNormRotation) | 146 const SkVector& invNormRotation) |
| 146 : fDiffDeviceTransform(kLocal_GrCoordSet, diffMatrix, diffuse, diffParam
s.filterMode()) | 147 : fDiffDeviceTransform(kLocal_GrCoordSet, diffMatrix, diffuse, diffParam
s.filterMode()) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 173 LightingGLFP() { | 174 LightingGLFP() { |
| 174 fLightDir.fX = 10000.0f; | 175 fLightDir.fX = 10000.0f; |
| 175 fLightColor.fX = 0.0f; | 176 fLightColor.fX = 0.0f; |
| 176 fAmbientColor.fX = 0.0f; | 177 fAmbientColor.fX = 0.0f; |
| 177 fInvNormRotation.set(0.0f, 0.0f); | 178 fInvNormRotation.set(0.0f, 0.0f); |
| 178 } | 179 } |
| 179 | 180 |
| 180 void emitCode(EmitArgs& args) override { | 181 void emitCode(EmitArgs& args) override { |
| 181 | 182 |
| 182 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 183 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 184 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 183 | 185 |
| 184 // add uniforms | 186 // add uniforms |
| 185 const char* lightDirUniName = nullptr; | 187 const char* lightDirUniName = nullptr; |
| 186 fLightDirUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFrag
ment_Visibility, | 188 fLightDirUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFra
gment_Visibility, |
| 187 kVec3f_GrSLType, kDefault_G
rSLPrecision, | 189 kVec3f_GrSLType, kDefault_
GrSLPrecision, |
| 188 "LightDir", &lightDirUniNam
e); | 190 "LightDir", &lightDirUniNa
me); |
| 189 | 191 |
| 190 const char* lightColorUniName = nullptr; | 192 const char* lightColorUniName = nullptr; |
| 191 fLightColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFr
agment_Visibility, | 193 fLightColorUni = uniformHandler->addUniform(GrGLSLUniformHandler::kF
ragment_Visibility, |
| 192 kVec3f_GrSLType, kDefault
_GrSLPrecision, | 194 kVec3f_GrSLType, kDefaul
t_GrSLPrecision, |
| 193 "LightColor", &lightColor
UniName); | 195 "LightColor", &lightColo
rUniName); |
| 194 | 196 |
| 195 const char* ambientColorUniName = nullptr; | 197 const char* ambientColorUniName = nullptr; |
| 196 fAmbientColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::k
Fragment_Visibility, | 198 fAmbientColorUni = uniformHandler->addUniform(GrGLSLUniformHandler::
kFragment_Visibility, |
| 197 kVec3f_GrSLType, kDefau
lt_GrSLPrecision, | 199 kVec3f_GrSLType, kDefa
ult_GrSLPrecision, |
| 198 "AmbientColor", &ambien
tColorUniName); | 200 "AmbientColor", &ambie
ntColorUniName); |
| 199 | 201 |
| 200 const char* xformUniName = nullptr; | 202 const char* xformUniName = nullptr; |
| 201 fXformUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragmen
t_Visibility, | 203 fXformUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme
nt_Visibility, |
| 202 kVec2f_GrSLType, kDefault_GrSL
Precision, | 204 kVec2f_GrSLType, kDefault_GrS
LPrecision, |
| 203 "Xform", &xformUniName); | 205 "Xform", &xformUniName); |
| 204 | 206 |
| 205 fragBuilder->codeAppend("vec4 diffuseColor = "); | 207 fragBuilder->codeAppend("vec4 diffuseColor = "); |
| 206 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.f
Samplers[0], | 208 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.f
Samplers[0], |
| 207 args.fCoords[0].c_str(), | 209 args.fCoords[0].c_str(), |
| 208 args.fCoords[0].getType()); | 210 args.fCoords[0].getType()); |
| 209 fragBuilder->codeAppend(";"); | 211 fragBuilder->codeAppend(";"); |
| 210 | 212 |
| 211 fragBuilder->codeAppend("vec4 normalColor = "); | 213 fragBuilder->codeAppend("vec4 normalColor = "); |
| 212 fragBuilder->appendTextureLookup(args.fSamplers[1], | 214 fragBuilder->appendTextureLookup(args.fSamplers[1], |
| 213 args.fCoords[1].c_str(), | 215 args.fCoords[1].c_str(), |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 normLocalM); | 718 normLocalM); |
| 717 } | 719 } |
| 718 | 720 |
| 719 /////////////////////////////////////////////////////////////////////////////// | 721 /////////////////////////////////////////////////////////////////////////////// |
| 720 | 722 |
| 721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 723 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
| 722 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 724 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
| 723 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 725 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| 724 | 726 |
| 725 /////////////////////////////////////////////////////////////////////////////// | 727 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |