1 /*
2  * Copyright 2012 The Android Open Source Project
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 #ifndef SkLightingImageFilter_DEFINED
9 #define SkLightingImageFilter_DEFINED
10 
11 #include "SkImageFilter.h"
12 #include "SkColor.h"
13 
14 
15 class SkImageFilterLight;
16 struct SkPoint3;
17 
18 class SK_API SkLightingImageFilter : public SkImageFilter {
19 public:
20     static SkImageFilter* CreateDistantLitDiffuse(const SkPoint3& direction,
21         SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
22         SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
23     static SkImageFilter* CreatePointLitDiffuse(const SkPoint3& location,
24         SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
25         SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
26     static SkImageFilter* CreateSpotLitDiffuse(const SkPoint3& location,
27         const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
28         SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
29         SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
30     static SkImageFilter* CreateDistantLitSpecular(const SkPoint3& direction,
31         SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
32         SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
33     static SkImageFilter* CreatePointLitSpecular(const SkPoint3& location,
34         SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
35         SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
36     static SkImageFilter* CreateSpotLitSpecular(const SkPoint3& location,
37         const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
38         SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
39         SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
40     ~SkLightingImageFilter();
41 
42     SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
43 
44 protected:
45     SkLightingImageFilter(SkImageFilterLight* light,
46                           SkScalar surfaceScale,
47                           SkImageFilter* input,
48                           const CropRect* cropRect);
49     void flatten(SkWriteBuffer&) const override;
light()50     const SkImageFilterLight* light() const { return fLight.get(); }
surfaceScale()51     SkScalar surfaceScale() const { return fSurfaceScale; }
canComputeFastBounds()52     bool canComputeFastBounds() const override { return false; }
53 
54 private:
55     typedef SkImageFilter INHERITED;
56     SkAutoTUnref<SkImageFilterLight> fLight;
57     SkScalar fSurfaceScale;
58 };
59 
60 #endif
61