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 { |
| 15 kDrawShadowAndForeground_ShadowMode, |
| 16 kDrawShadowOnly_ShadowMode |
| 17 }; |
| 18 |
| 19 /** @deprecated use another Create function below instead */ |
14 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, | 20 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, |
15 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, | 21 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, |
16 SkImageFilter* input = NULL, | 22 SkImageFilter* input = NULL, |
17 const CropRect* cropRect = NULL, | 23 const CropRect* cropRect = NULL, |
18 uint32_t uniqueID = 0) { | 24 uint32_t uniqueID = 0) { |
19 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, | 25 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, colo
r, |
20 color, input, cropRect, uniq
ueID)); | 26 kDrawShadowAndForeground_Sha
dowMode, |
| 27 input, cropRect, uniqueID)); |
21 } | 28 } |
| 29 |
| 30 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, |
| 31 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, |
| 32 ShadowMode shadowMode, |
| 33 SkImageFilter* input, |
| 34 const CropRect* cropRect, |
| 35 uint32_t uniqueID) { |
| 36 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, colo
r, |
| 37 shadowMode, input, cropRect,
uniqueID)); |
| 38 } |
| 39 |
| 40 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, |
| 41 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, |
| 42 ShadowMode shadowMode) { |
| 43 return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, colo
r, |
| 44 shadowMode, NULL, NULL, 0)); |
| 45 } |
| 46 |
22 virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; | 47 virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; |
23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) | 48 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) |
24 | 49 |
25 protected: | 50 protected: |
26 SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar
sigmaY, SkColor, | 51 SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar
sigmaY, SkColor, |
27 SkImageFilter* input, const CropRect* cropRect, uint
32_t uniqueID); | 52 ShadowMode shadowMode, SkImageFilter* input, const C
ropRect* cropRect, |
| 53 uint32_t uniqueID); |
28 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 54 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
29 explicit SkDropShadowImageFilter(SkReadBuffer&); | 55 explicit SkDropShadowImageFilter(SkReadBuffer&); |
30 #endif | 56 #endif |
31 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 57 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
32 virtual bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, S
kBitmap* result, SkIPoint* loc) const SK_OVERRIDE; | 58 virtual bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, S
kBitmap* result, SkIPoint* loc) const SK_OVERRIDE; |
33 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, | 59 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, |
34 SkIRect* dst) const SK_OVERRIDE; | 60 SkIRect* dst) const SK_OVERRIDE; |
35 | 61 |
36 private: | 62 private: |
37 SkScalar fDx, fDy, fSigmaX, fSigmaY; | 63 SkScalar fDx, fDy, fSigmaX, fSigmaY; |
38 SkColor fColor; | 64 SkColor fColor; |
| 65 ShadowMode fShadowMode; |
39 typedef SkImageFilter INHERITED; | 66 typedef SkImageFilter INHERITED; |
40 }; | 67 }; |
OLD | NEW |