• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2013 Google Inc.
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 SkDropShadowImageFilter_DEFINED
9 #define SkDropShadowImageFilter_DEFINED
10 
11 #include "SkColor.h"
12 #include "SkImageFilter.h"
13 #include "SkScalar.h"
14 
15 class SK_API SkDropShadowImageFilter : public SkImageFilter {
16 public:
17     enum ShadowMode {
18         kDrawShadowAndForeground_ShadowMode,
19         kDrawShadowOnly_ShadowMode,
20 
21         kLast_ShadowMode = kDrawShadowOnly_ShadowMode
22     };
23 
24     static const int kShadowModeCount = kLast_ShadowMode+1;
25 
26     static sk_sp<SkImageFilter> Make(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY,
27                                      SkColor color, ShadowMode shadowMode,
28                                      sk_sp<SkImageFilter> input,
29                                      const CropRect* cropRect = nullptr);
30 
31     SkRect computeFastBounds(const SkRect&) const override;
32     SK_TO_STRING_OVERRIDE()
33     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
34 
35 protected:
36     void flatten(SkWriteBuffer&) const override;
37     sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
38                                         SkIPoint* offset) const override;
39     sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
40     SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
41 
42 private:
43     SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
44                             ShadowMode shadowMode, sk_sp<SkImageFilter> input,
45                             const CropRect* cropRect);
46 
47     SkScalar fDx, fDy, fSigmaX, fSigmaY;
48     SkColor fColor;
49     ShadowMode fShadowMode;
50 
51     typedef SkImageFilter INHERITED;
52 };
53 
54 #endif
55