| 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 | 9 |
| 10 #ifndef SkLightingShader_DEFINED | 10 #ifndef SkLightingShader_DEFINED |
| 11 #define SkLightingShader_DEFINED | 11 #define SkLightingShader_DEFINED |
| 12 | 12 |
| 13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
| 14 #include "SkLight.h" | 14 #include "SkLight.h" |
| 15 #include "SkShader.h" | 15 #include "SkShader.h" |
| 16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 17 | 17 |
| 18 class SkBitmap; | 18 class SkBitmap; |
| 19 class SkMatrix; | 19 class SkMatrix; |
| 20 | 20 |
| 21 class SK_API SkLightingShader { | 21 class SK_API SkLightingShader { |
| 22 public: | 22 public: |
| 23 class Lights : public SkRefCnt { | 23 class Lights : public SkRefCnt { |
| 24 public: | 24 public: |
| 25 class Builder { | 25 class Builder { |
| 26 public: | 26 public: |
| 27 Builder(const SkLight lights[], int numLights) | 27 Builder(const SkLight lights[], int numLights) |
| 28 : fLights(SkNEW_ARGS(Lights, (lights, numLights))) { | 28 : fLights(new Lights(lights, numLights)) {} |
| 29 } | |
| 30 | 29 |
| 31 Builder() : fLights(SkNEW(Lights)) { } | 30 Builder() : fLights(new Lights) {} |
| 32 | 31 |
| 33 // TODO: limit the number of lights here or just ignore those | 32 // TODO: limit the number of lights here or just ignore those |
| 34 // above some maximum? | 33 // above some maximum? |
| 35 void add(const SkLight& light) { | 34 void add(const SkLight& light) { |
| 36 if (fLights) { | 35 if (fLights) { |
| 37 *fLights->fLights.push() = light; | 36 *fLights->fLights.push() = light; |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 const Lights* finish() { | 40 const Lights* finish() { |
| 42 return fLights.detach(); | 41 return fLights.detach(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 (127, 127, 0). | 91 (127, 127, 0). |
| 93 */ | 92 */ |
| 94 static SkShader* Create(const SkBitmap& diffuse, const SkBitmap& normal, | 93 static SkShader* Create(const SkBitmap& diffuse, const SkBitmap& normal, |
| 95 const Lights* lights, const SkVector& invNormRotatio
n, | 94 const Lights* lights, const SkVector& invNormRotatio
n, |
| 96 const SkMatrix* diffLocalMatrix, const SkMatrix* nor
mLocalMatrix); | 95 const SkMatrix* diffLocalMatrix, const SkMatrix* nor
mLocalMatrix); |
| 97 | 96 |
| 98 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 97 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 #endif | 100 #endif |
| OLD | NEW |