OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColor.h" | 8 #include "SkColor.h" |
9 #include "SkImageFilter.h" | 9 #include "SkImageFilter.h" |
10 #include "SkScalar.h" | 10 #include "SkScalar.h" |
11 | 11 |
12 class SK_API SkDropShadowImageFilter : public SkImageFilter { | 12 class SK_API SkDropShadowImageFilter : public SkImageFilter { |
13 public: | 13 public: |
14 enum ShadowMode { | 14 enum ShadowMode { |
15 kDrawShadowAndForeground_ShadowMode, | 15 kDrawShadowAndForeground_ShadowMode, |
16 kDrawShadowOnly_ShadowMode, | 16 kDrawShadowOnly_ShadowMode, |
17 | 17 |
18 kLast_ShadowMode = kDrawShadowOnly_ShadowMode | 18 kLast_ShadowMode = kDrawShadowOnly_ShadowMode |
19 }; | 19 }; |
20 | 20 |
21 static const int kShadowModeCount = kLast_ShadowMode+1; | 21 static const int kShadowModeCount = kLast_ShadowMode+1; |
22 | 22 |
23 /** @deprecated use another Create function below instead */ | |
24 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, | |
25 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, | |
26 SkImageFilter* input = NULL, | |
27 const CropRect* cropRect = NULL) { | |
28 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, colo
r, | |
29 kDrawShadowAndForeground_Sha
dowMode, | |
30 input, cropRect)); | |
31 } | |
32 | |
33 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, | 23 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, |
34 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, | 24 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, |
35 ShadowMode shadowMode, | 25 ShadowMode shadowMode, |
36 SkImageFilter* input = NULL, | 26 SkImageFilter* input = NULL, |
37 const CropRect* cropRect = NULL) { | 27 const CropRect* cropRect = NULL) { |
38 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, colo
r, | 28 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, colo
r, |
39 shadowMode, input, cropRect)
); | 29 shadowMode, input, cropRect)
); |
40 } | 30 } |
41 | 31 |
42 void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; | 32 void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; |
43 SK_TO_STRING_OVERRIDE() | 33 SK_TO_STRING_OVERRIDE() |
44 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) | 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) |
45 | 35 |
46 protected: | 36 protected: |
47 SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar
sigmaY, SkColor, | 37 SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar
sigmaY, SkColor, |
48 ShadowMode shadowMode, SkImageFilter* input, const C
ropRect* cropRect); | 38 ShadowMode shadowMode, SkImageFilter* input, const C
ropRect* cropRect); |
49 void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 39 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
50 bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap*
result, SkIPoint* loc) const SK_OVERRIDE; | 40 bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap*
result, SkIPoint* loc) const SK_OVERRIDE; |
51 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, | 41 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, |
52 SkIRect* dst) const SK_OVERRIDE; | 42 SkIRect* dst) const SK_OVERRIDE; |
53 | 43 |
54 private: | 44 private: |
55 SkScalar fDx, fDy, fSigmaX, fSigmaY; | 45 SkScalar fDx, fDy, fSigmaX, fSigmaY; |
56 SkColor fColor; | 46 SkColor fColor; |
57 ShadowMode fShadowMode; | 47 ShadowMode fShadowMode; |
58 typedef SkImageFilter INHERITED; | 48 typedef SkImageFilter INHERITED; |
59 }; | 49 }; |
OLD | NEW |