Skia
2D Graphics Library
SkImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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 SkImageFilter_DEFINED
9 #define SkImageFilter_DEFINED
10 
13 #include "include/core/SkMatrix.h"
14 #include "include/core/SkRect.h"
15 
16 class SkColorFilter;
17 
32 public:
33  enum MapDirection {
36  };
50  SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm,
51  MapDirection, const SkIRect* inputRect = nullptr) const;
52 
60  bool isColorFilterNode(SkColorFilter** filterPtr) const;
61 
62  // DEPRECATED : use isColorFilterNode() instead
63  bool asColorFilter(SkColorFilter** filterPtr) const {
64  return this->isColorFilterNode(filterPtr);
65  }
66 
72  bool asAColorFilter(SkColorFilter** filterPtr) const;
73 
77  int countInputs() const;
78 
83  const SkImageFilter* getInput(int i) const;
84 
85  // Default impl returns union of all input bounds.
86  virtual SkRect computeFastBounds(const SkRect& bounds) const;
87 
88  // Can this filter DAG compute the resulting bounds of an object-space rectangle?
89  bool canComputeFastBounds() const;
90 
96 
98  return kSkImageFilter_Type;
99  }
100 
102  return kSkImageFilter_Type;
103  }
104 
105  static sk_sp<SkImageFilter> Deserialize(const void* data, size_t size,
106  const SkDeserialProcs* procs = nullptr) {
107  return sk_sp<SkImageFilter>(static_cast<SkImageFilter*>(
108  SkFlattenable::Deserialize(kSkImageFilter_Type, data, size, procs).release()));
109  }
110 
111 protected:
112 
114  return sk_ref_sp(const_cast<SkImageFilter*>(this));
115  }
116 
117 private:
118  friend class SkImageFilter_Base;
119 
120  using INHERITED = SkFlattenable;
121 };
122 
123 #endif
SkFlattenable.h
SkColorFilter
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:25
SkImageFilter::kReverse_MapDirection
@ kReverse_MapDirection
Definition: SkImageFilter.h:35
SkRefCnt
Definition: SkRefCnt.h:118
SkImageFilter::countInputs
int countInputs() const
Returns the number of inputs this filter will accept (some inputs can be NULL).
SkImageFilter::refMe
sk_sp< SkImageFilter > refMe() const
Definition: SkImageFilter.h:113
SkImageFilter::asColorFilter
bool asColorFilter(SkColorFilter **filterPtr) const
Definition: SkImageFilter.h:63
SkRect.h
SkFlattenable::Deserialize
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
sk_ref_sp
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:374
SkFlattenable::Type
Type
Definition: SkFlattenable.h:28
SkImageFilter::computeFastBounds
virtual SkRect computeFastBounds(const SkRect &bounds) const
SkImageFilter::makeWithLocalMatrix
sk_sp< SkImageFilter > makeWithLocalMatrix(const SkMatrix &matrix) const
If this filter can be represented by another filter + a localMatrix, return that filter,...
SkImageFilter::filterBounds
SkIRect filterBounds(const SkIRect &src, const SkMatrix &ctm, MapDirection, const SkIRect *inputRect=nullptr) const
Map a device-space rect recursively forward or backward through the filter DAG.
SkImageFilter::Deserialize
static sk_sp< SkImageFilter > Deserialize(const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
Definition: SkImageFilter.h:105
sk_sp< SkImageFilter >
SkFlattenable::kSkImageFilter_Type
@ kSkImageFilter_Type
Definition: SkFlattenable.h:32
SkFlattenable::SkFlattenable
SkFlattenable()
Definition: SkFlattenable.h:45
SkImageFilter::GetFlattenableType
static SkFlattenable::Type GetFlattenableType()
Definition: SkImageFilter.h:97
SK_API
#define SK_API
Definition: SkTypes.h:181
SkImageFilter::getInput
const SkImageFilter * getInput(int i) const
Returns the input filter at a given index, or NULL if no input is connected.
SkImageFilter::MapDirection
MapDirection
Definition: SkImageFilter.h:33
SkImageFilter::canComputeFastBounds
bool canComputeFastBounds() const
SkFilterQuality.h
SkImageFilter::isColorFilterNode
bool isColorFilterNode(SkColorFilter **filterPtr) const
Returns whether this image filter is a color filter and puts the color filter into the "filterPtr" pa...
SkImageFilter::kForward_MapDirection
@ kForward_MapDirection
Definition: SkImageFilter.h:34
SkMatrix
Definition: SkMatrix.h:48
SkMatrix.h
SkIRect
Definition: SkRect.h:28
SkRect
Definition: SkRect.h:572
SkDeserialProcs
Definition: SkSerialProcs.h:61
SkFlattenable
Definition: SkFlattenable.h:26
SkImageFilter::getFlattenableType
SkFlattenable::Type getFlattenableType() const override
Definition: SkImageFilter.h:101
SkImageFilter::asAColorFilter
bool asAColorFilter(SkColorFilter **filterPtr) const
Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely replaced b...
SkImageFilter
Base class for image filters.
Definition: SkImageFilter.h:31