vjiaoblack | 53da5ba | 2016-08-01 10:02:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | |
| 9 | #ifndef SkShadowShader_DEFINED |
| 10 | #define SkShadowShader_DEFINED |
| 11 | |
| 12 | #ifdef SK_EXPERIMENTAL_SHADOWING |
| 13 | |
| 14 | class SkLights; |
| 15 | class SkShader; |
| 16 | |
| 17 | class SK_API SkShadowShader { |
| 18 | public: |
| 19 | /** This shader combines the diffuse color in 'diffuseShader' with the shadows |
| 20 | * determined by the 'povDepthShader' and the shadow maps stored in each of the |
| 21 | * lights in 'lights' |
vjiaoblack | bb10606 | 2016-08-31 11:15:21 -0700 | [diff] [blame] | 22 | * |
| 23 | * Please note that the shadow shader is required to be in Stage0, otherwise |
| 24 | * the texture coords will be wrong within the shader. |
vjiaoblack | 53da5ba | 2016-08-01 10:02:31 -0700 | [diff] [blame] | 25 | */ |
| 26 | static sk_sp<SkShader> Make(sk_sp<SkShader> povDepthShader, |
| 27 | sk_sp<SkShader> diffuseShader, |
| 28 | sk_sp<SkLights> lights, |
vjiaoblack | e6f5d56 | 2016-08-25 06:30:23 -0700 | [diff] [blame] | 29 | int diffuseWidth, int diffuseHeight, |
| 30 | const SkShadowParams& params); |
vjiaoblack | 53da5ba | 2016-08-01 10:02:31 -0700 | [diff] [blame] | 31 | |
vjiaoblack | 955e879 | 2016-08-05 07:55:01 -0700 | [diff] [blame] | 32 | // The shadow shader supports any number of ambient lights, but only |
| 33 | // 4 non-ambient lights (currently just refers to directional lights). |
| 34 | static constexpr int kMaxNonAmbientLights = 4; |
| 35 | |
vjiaoblack | 53da5ba | 2016-08-01 10:02:31 -0700 | [diff] [blame] | 36 | SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 37 | }; |
| 38 | |
| 39 | #endif |
| 40 | #endif |