Chromium Code Reviews| Index: src/core/SkLightingShader.h |
| diff --git a/src/effects/SkLightingShader.h b/src/core/SkLightingShader.h |
| similarity index 57% |
| rename from src/effects/SkLightingShader.h |
| rename to src/core/SkLightingShader.h |
| index 64d41a291e7bd8d90d402e1b33954bd3cd78a1dc..4835b58337b850d5733adeefc4f22cde29b7a3b4 100644 |
| --- a/src/effects/SkLightingShader.h |
| +++ b/src/core/SkLightingShader.h |
| @@ -10,15 +10,55 @@ |
| #ifndef SkLightingShader_DEFINED |
| #define SkLightingShader_DEFINED |
| -#include "SkPoint3.h" |
| +#include "SkFlattenable.h" |
| +#include "SkLight.h" |
| #include "SkShader.h" |
| +#include "SkTDArray.h" |
| + |
| +class SkBitmap; |
| +class SkMatrix; |
| class SK_API SkLightingShader { |
| public: |
| - struct Light { |
| - SkVector3 fDirection; // direction towards the light (+Z is out of the screen). |
| - // If degenerate, it will be replaced with (0, 0, 1). |
| - SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in each channel. |
| + class Lights : public SkRefCnt { |
| + public: |
| + class Builder { |
|
jvanverth1
2015/08/19 13:57:48
This class is new -- can you mention it in the cha
robertphillips
2015/08/19 16:17:57
Done.
|
| + public: |
| + Builder(const SkLight lights[], int numLights) |
| + : fLights(SkNEW_ARGS(Lights, (lights, numLights))) { |
| + } |
| + |
| + Builder() : fLights(SkNEW(Lights)) { } |
| + |
| + void add(const SkLight& light) { |
|
jvanverth1
2015/08/19 13:57:48
I think we'll need a way to limit the number of di
robertphillips
2015/08/19 16:17:57
I've added a TODO.
|
| + if (fLights) { |
| + *fLights->fLights.push() = light; |
| + } |
| + } |
| + |
| + const Lights* finish() { |
| + return fLights.detach(); |
| + } |
| + |
| + private: |
| + SkAutoTUnref<Lights> fLights; |
| + }; |
| + |
| + int numLights() const { |
| + return fLights.count(); |
| + } |
| + |
| + const SkLight& light(int index) const { |
| + return fLights[index]; |
| + } |
| + |
| + private: |
| + Lights() {} |
| + Lights(const SkLight lights[], int numLights) : fLights(lights, numLights) {} |
| + |
| + SkTDArray<SkLight> fLights; |
| + |
| + typedef SkRefCnt INHERITED; |
| }; |
| /** Returns a shader that lights the diffuse and normal maps with a single light. |
| @@ -50,8 +90,8 @@ public: |
| (127, 127, 0). |
| */ |
| static SkShader* Create(const SkBitmap& diffuse, const SkBitmap& normal, |
| - const SkLightingShader::Light& light, const SkColor3f& ambient, |
| - const SkMatrix* localMatrix); |
| + const Lights* lights, const SkVector& invNormRotation, |
| + const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix); |
| SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| }; |