Chromium Code Reviews| Index: src/core/SkLightingShader.h |
| diff --git a/src/core/SkLightingShader.h b/src/core/SkLightingShader.h |
| index 75a7738755865704972e22bc1c7232bb93764adf..a218b59b2404c251803cd8579a8c5ffb371c40bb 100644 |
| --- a/src/core/SkLightingShader.h |
| +++ b/src/core/SkLightingShader.h |
| @@ -16,8 +16,7 @@ class SkMatrix; |
| class SK_API SkLightingShader { |
| public: |
| - /** Abstract class that generates or reads in normals for use by SkLightingShader. Not to be |
| - used as part of the API yet. Used internally by SkLightingShader. |
| + /** Abstract class that generates or reads in normals for use by SkLightingShader. |
| */ |
| class NormalSource : public SkFlattenable { |
| public: |
| @@ -35,7 +34,7 @@ public: |
| SkFilterQuality filterQuality, |
| SkSourceGammaTreatment gammaTreatment) const = 0; |
| #endif |
| - |
| + |
|
egdaniel
2016/06/16 13:15:08
extra spaces added here?
dvonbeck
2016/06/16 23:21:57
Oops, that was an accident. Reverted. Are space-on
|
| class Provider { |
| public: |
| virtual ~Provider(){}; |
| @@ -63,66 +62,53 @@ public: |
| SK_DEFINE_FLATTENABLE_TYPE(NormalSource) |
| }; |
| - /** Returns a normal source that provides normals sourced from the the normal map argument. |
| - Not to be used as part of the API yet. Used internally by SkLightingShader. |
| - |
| - @param normal the normal map |
| - @param invNormRotation rotation applied to the normal map's normals |
| - @param normLocalM the local matrix for the normal map |
| - |
| - nullptr will be returned if |
| - 'normal' is empty |
| - 'normal' too big (> 65535 on either side) |
| - |
| - The normal map is currently assumed to be an 8888 image where the normal at a texel |
| - is retrieved by: |
| - N.x = R-127; |
| - N.y = G-127; |
| - N.z = B-127; |
| - N.normalize(); |
| - The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is |
| - (127, 127, 0). |
| - */ |
| class NormalMapSource { |
| public: |
| + |
| + /** Returns a normal source that provides normals sourced from the the normal map argument. |
| + |
| + @param normal the normal map |
| + @param invNormRotation rotation applied to the normal map's normals |
| + @param normLocalM the local matrix for the normal map |
| + |
| + nullptr will be returned if |
| + 'normal' is empty |
| + 'normal' too big (> 65535 on either side) |
| + |
| + The normal map is currently assumed to be an 8888 image where the normal at a texel is |
| + retrieved by: |
| + N.x = R-127; |
| + N.y = G-127; |
| + N.z = B-127; |
| + N.normalize(); |
| + The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is |
| + (127, 127, 0). |
| + */ |
| static sk_sp<NormalSource> Make(const SkBitmap& normal, const SkVector& invNormRotation, |
| const SkMatrix* normLocalM); |
| - |
| SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| }; |
| - /** Returns a shader that lights the diffuse and normal maps with a set of lights. |
| + /** Returns a shader that lights the diffuse map and normals with a set of lights. |
| It returns a shader with a reference count of 1. |
| The caller should decrement the shader's reference count when done with the shader. |
| It is an error for count to be < 2. |
| @param diffuse the diffuse bitmap |
| - @param normal the normal map |
| - @param lights the lights applied to the normal map |
| - @param invNormRotation rotation applied to the normal map's normals |
| + @param lights the lights applied to the normals |
| @param diffLocalMatrix the local matrix for the diffuse texture |
| - @param normLocalMatrix the local matrix for the normal map |
| + @param normalSource the source for the normals |
| nullptr will be returned if: |
| - either 'diffuse' or 'normal' are empty |
| - either 'diffuse' or 'normal' are too big (> 65535 on a side) |
| - 'diffuse' and 'normal' aren't the same size |
| + 'diffuse' is empty |
| + 'diffuse' is too big (> 65535 on any side) |
| The lighting equation is currently: |
| result = LightColor * DiffuseColor * (Normal * LightDir) + AmbientColor |
| - The normal map is currently assumed to be an 8888 image where the normal at a texel |
| - is retrieved by: |
| - N.x = R-127; |
| - N.y = G-127; |
| - N.z = B-127; |
| - N.normalize(); |
| - The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is |
| - (127, 127, 0). |
| */ |
| - static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal, |
| - sk_sp<SkLights> lights, const SkVector& invNormRotation, |
| - const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix); |
| + static sk_sp<SkShader> Make(const SkBitmap& diffuse, sk_sp<SkLights> lights, |
| + const SkMatrix* diffLocalMatrix, sk_sp<NormalSource> normalSource); |
| SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| }; |