OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkLightingImageFilter.h" | 8 #include "SkLightingImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 GrGLLightingEffect::~GrGLLightingEffect() { | 1197 GrGLLightingEffect::~GrGLLightingEffect() { |
1198 delete fLight; | 1198 delete fLight; |
1199 } | 1199 } |
1200 | 1200 |
1201 void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, | 1201 void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, |
1202 const GrDrawEffect&, | 1202 const GrDrawEffect&, |
1203 EffectKey key, | 1203 EffectKey key, |
1204 const char* outputColor, | 1204 const char* outputColor, |
1205 const char* inputColor, | 1205 const char* inputColor, |
1206 const TextureSamplerArray& samplers) { | 1206 const TextureSamplerArray& samplers) { |
1207 const char* coords; | 1207 SkString coords; |
1208 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); | 1208 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); |
1209 | 1209 |
1210 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader
Type, | 1210 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader
Type, |
1211 kVec2f_GrSLType, | 1211 kVec2f_GrSLType, |
1212 "ImageIncrement"); | 1212 "ImageIncrement"); |
1213 fSurfaceScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderTy
pe, | 1213 fSurfaceScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderTy
pe, |
1214 kFloat_GrSLType, | 1214 kFloat_GrSLType, |
1215 "SurfaceScale"); | 1215 "SurfaceScale"); |
1216 fLight->emitLightColorUniform(builder); | 1216 fLight->emitLightColorUniform(builder); |
1217 SkString lightFunc; | 1217 SkString lightFunc; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 sobelFuncName.c_str()); | 1260 sobelFuncName.c_str()); |
1261 SkString interiorNormalName; | 1261 SkString interiorNormalName; |
1262 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, | 1262 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, |
1263 kVec3f_GrSLType, | 1263 kVec3f_GrSLType, |
1264 "interiorNormal", | 1264 "interiorNormal", |
1265 SK_ARRAY_COUNT(gInteriorNormalArgs), | 1265 SK_ARRAY_COUNT(gInteriorNormalArgs), |
1266 gInteriorNormalArgs, | 1266 gInteriorNormalArgs, |
1267 interiorNormalBody.c_str(), | 1267 interiorNormalBody.c_str(), |
1268 &interiorNormalName); | 1268 &interiorNormalName); |
1269 | 1269 |
1270 builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords); | 1270 builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords.c_str()); |
1271 builder->fsCodeAppend("\t\tfloat m[9];\n"); | 1271 builder->fsCodeAppend("\t\tfloat m[9];\n"); |
1272 | 1272 |
1273 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); | 1273 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
1274 const char* surfScale = builder->getUniformCStr(fSurfaceScaleUni); | 1274 const char* surfScale = builder->getUniformCStr(fSurfaceScaleUni); |
1275 | 1275 |
1276 int index = 0; | 1276 int index = 0; |
1277 for (int dy = -1; dy <= 1; dy++) { | 1277 for (int dy = -1; dy <= 1; dy++) { |
1278 for (int dx = -1; dx <= 1; dx++) { | 1278 for (int dx = -1; dx <= 1; dx++) { |
1279 SkString texCoords; | 1279 SkString texCoords; |
1280 texCoords.appendf("coord + vec2(%d, %d) * %s", dx, dy, imgInc); | 1280 texCoords.appendf("coord + vec2(%d, %d) * %s", dx, dy, imgInc); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 | 1572 |
1573 #endif | 1573 #endif |
1574 | 1574 |
1575 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1575 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
1576 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1576 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
1578 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDistantLight) | 1578 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDistantLight) |
1579 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPointLight) | 1579 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPointLight) |
1580 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpotLight) | 1580 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpotLight) |
1581 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1581 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |