Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkDropShadowImageFilter.h
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,
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 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
36  static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY,
37  SkColor color, ShadowMode shadowMode,
38  SkImageFilter* input = nullptr,
39  const CropRect* cropRect = nullptr) {
40  return Make(dx, dy, sigmaX, sigmaY, color, shadowMode,
41  sk_ref_sp<SkImageFilter>(input), cropRect).release();
42  }
43 #endif
44 
45 protected:
46  void flatten(SkWriteBuffer&) const override;
47  sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
48  SkIPoint* offset) const override;
49  SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
50 
51 private:
52  SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
53  ShadowMode shadowMode, sk_sp<SkImageFilter> input,
54  const CropRect* cropRect);
55 
56  SkScalar fDx, fDy, fSigmaX, fSigmaY;
57  SkColor fColor;
58  ShadowMode fShadowMode;
59 
60  typedef SkImageFilter INHERITED;
61 };
62 
63 #endif
T *SK_WARN_UNUSED_RESULT release()
Return the bare pointer, and set the internal object pointer to nullptr.
Definition: SkRefCnt.h:363
Definition: SkDropShadowImageFilter.h:15
Definition: SkImageFilter.h:55
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
virtual sk_sp< SkSpecialImage > onFilterImage(SkSpecialImage *src, const Context &, SkIPoint *offset) const =0
This is the virtual which should be overridden by the derived class to perform image filtering...
Definition: SkRefCnt.h:135
Base class for image filters.
Definition: SkImageFilter.h:35
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
Definition: SkWriteBuffer.h:26
Definition: SkRect.h:390
virtual SkIRect onFilterNodeBounds(const SkIRect &, const SkMatrix &, MapDirection) const
Performs a forwards or reverse mapping of the given rect to accommodate this filter's margin requirem...
Definition: SkImageFilter.h:37
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20
SkIPoint holds two 32 bit integer coordinates.
Definition: SkPoint.h:40
Types and macros for colors.