Index: src/core/SkLightingShader.h |
diff --git a/src/core/SkLightingShader.h b/src/core/SkLightingShader.h |
index f25b30342a70699506cc03a5ffbc786e1e620207..6301eeeea13595919e5626829ac36134e93ccbe3 100644 |
--- a/src/core/SkLightingShader.h |
+++ b/src/core/SkLightingShader.h |
@@ -16,6 +16,58 @@ class SkMatrix; |
class SK_API SkLightingShader { |
public: |
+ /** Abstract class that generates or reads in normals for use by SkLightingShader. Currently |
+ implements the GPU side only. Not to be used as part of the API yet. Used internally by |
+ SkLightingShader. |
+ */ |
+ class NormalSource : public SkFlattenable { |
+ public: |
+ virtual ~NormalSource(); |
+ |
+#if SK_SUPPORT_GPU |
+ |
+ /** Returns a fragment processor that takes no input and outputs a normal (already rotated) |
egdaniel
2016/06/14 18:30:45
in general the no input here isn't true. I believe
dvonbeck
2016/06/14 18:41:44
That would be coming in as a universal though, rig
egdaniel
2016/06/14 19:01:18
Ah right this is asFragmentProcessor, I was thinki
|
+ as its output color. To be used as a child fragment processor. |
+ */ |
+ virtual sk_sp<GrFragmentProcessor> asFragmentProcessor( |
+ GrContext* context, |
+ const SkMatrix& viewM, |
+ const SkMatrix* localMatrix, |
+ SkFilterQuality filterQuality, |
+ SkSourceGammaTreatment gammaTreatment) const = 0; |
+#endif |
+ |
+ 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: |
+ 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. |
It returns a shader with a reference count of 1. |