1 /*
2  * Copyright 2012 The Android Open Source Project
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 SkOffsetImageFilter_DEFINED
9 #define SkOffsetImageFilter_DEFINED
10 
11 #include "SkImageFilter.h"
12 #include "SkPoint.h"
13 
14 class SK_API SkOffsetImageFilter : public SkImageFilter {
15 public:
16     static sk_sp<SkImageFilter> Make(SkScalar dx, SkScalar dy,
17                                      sk_sp<SkImageFilter> input,
18                                      const CropRect* cropRect = nullptr);
19 
20     SkRect computeFastBounds(const SkRect& src) const override;
21 
22     SK_TO_STRING_OVERRIDE()
23     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
24 
25 protected:
26     void flatten(SkWriteBuffer&) const override;
27     sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
28                                         SkIPoint* offset) const override;
29     SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
30 
31 private:
32     SkOffsetImageFilter(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input, const CropRect*);
33 
34     SkVector fOffset;
35 
36     typedef SkImageFilter INHERITED;
37 };
38 
39 #endif
40