Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkMergeImageFilter.h
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 SkMergeImageFilter_DEFINED
9 #define SkMergeImageFilter_DEFINED
10 
11 #include "SkImageFilter.h"
12 
13 #include "SkXfermode.h"
14 
15 class SK_API SkMergeImageFilter : public SkImageFilter {
16 public:
17  ~SkMergeImageFilter() override;
18 
21  const CropRect* cropRect = nullptr);
22  static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilter> filters[],
23  int count,
24  const SkXfermode::Mode modes[] = nullptr,
25  const CropRect* cropRect = nullptr);
26 
27  SK_TO_STRING_OVERRIDE()
28  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
29 
30 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
31  static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
33  const CropRect* cropRect = nullptr) {
34  return Make(sk_ref_sp<SkImageFilter>(first),
35  sk_ref_sp<SkImageFilter>(second),
36  mode, cropRect).release();
37  }
38 
39  static SkImageFilter* Create(SkImageFilter* filters[], int count,
40  const SkXfermode::Mode modes[] = nullptr,
41  const CropRect* cropRect = nullptr) {
42  SkAutoTDeleteArray<sk_sp<SkImageFilter>> temp(new sk_sp<SkImageFilter>[count]);
43  for (int i = 0; i < count; ++i) {
44  temp[i] = sk_ref_sp<SkImageFilter>(filters[i]);
45  }
46  return Make(temp.get(), count, modes, cropRect).release();
47  }
48 #endif
49 
50 protected:
51  void flatten(SkWriteBuffer&) const override;
52  sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
53  SkIPoint* offset) const override;
54  bool onCanHandleComplexCTM() const override { return true; }
55 
56 private:
57  SkMergeImageFilter(sk_sp<SkImageFilter> filters[], int count, const SkXfermode::Mode modes[],
58  const CropRect* cropRect);
59 
60  uint8_t* fModes; // SkXfermode::Mode
61 
62  // private storage, to avoid dynamically allocating storage for our copy
63  // of the modes (unless the count is so large we can't fit).
64  intptr_t fStorage[16];
65 
66  void initAllocModes();
67  void initModes(const SkXfermode::Mode []);
68 
69  typedef SkImageFilter INHERITED;
70 };
71 
72 #endif
T *SK_WARN_UNUSED_RESULT release()
Return the bare pointer, and set the internal object pointer to nullptr.
Definition: SkRefCnt.h:363
Definition: SkImageFilter.h:55
Mode
List of predefined xfermodes.
Definition: SkXfermode.h:71
[Sa + Da * (1 - Sa), Sc + Dc * (1 - Sa)]
Definition: SkXfermode.h:75
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
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: SkMergeImageFilter.h:15
Base class for image filters.
Definition: SkImageFilter.h:35
Definition: SkWriteBuffer.h:26
bool onCanHandleComplexCTM() const override
Override this to describe the behavior of your subclass - as a leaf node.
Definition: SkMergeImageFilter.h:54
Definition: SkImageFilter.h:37
SkIPoint holds two 32 bit integer coordinates.
Definition: SkPoint.h:40