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 static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, | 23 static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkSc
alar sigmaY, |
24 SkScalar sigmaX, SkScalar sigmaY, SkC
olor color, | 24 SkColor color, ShadowMode shadowMode, SkImageFi
lter* input = NULL, |
25 ShadowMode shadowMode, | 25 const CropRect* cropRect = NULL) { |
26 SkImageFilter* input = NULL, | |
27 const CropRect* cropRect = NULL) { | |
28 return new SkDropShadowImageFilter(dx, dy, sigmaX, sigmaY, color, shadow
Mode, input, | 26 return new SkDropShadowImageFilter(dx, dy, sigmaX, sigmaY, color, shadow
Mode, input, |
29 cropRect); | 27 cropRect); |
30 } | 28 } |
31 | 29 |
32 void computeFastBounds(const SkRect&, SkRect*) const override; | 30 void computeFastBounds(const SkRect&, SkRect*) const override; |
33 SK_TO_STRING_OVERRIDE() | 31 SK_TO_STRING_OVERRIDE() |
34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) | 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) |
35 | 33 |
36 protected: | 34 protected: |
| 35 void flatten(SkWriteBuffer&) const override; |
| 36 bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap*
result, |
| 37 SkIPoint* loc) const override; |
| 38 bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const
override; |
| 39 |
| 40 private: |
37 SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar
sigmaY, SkColor, | 41 SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar
sigmaY, SkColor, |
38 ShadowMode shadowMode, SkImageFilter* input, const C
ropRect* cropRect); | 42 ShadowMode shadowMode, SkImageFilter* input, const C
ropRect* cropRect); |
39 void flatten(SkWriteBuffer&) const override; | |
40 bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap*
result, SkIPoint* loc) const override; | |
41 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, | |
42 SkIRect* dst) const override; | |
43 | 43 |
44 private: | |
45 SkScalar fDx, fDy, fSigmaX, fSigmaY; | 44 SkScalar fDx, fDy, fSigmaX, fSigmaY; |
46 SkColor fColor; | 45 SkColor fColor; |
47 ShadowMode fShadowMode; | 46 ShadowMode fShadowMode; |
| 47 |
48 typedef SkImageFilter INHERITED; | 48 typedef SkImageFilter INHERITED; |
49 }; | 49 }; |
OLD | NEW |