8 #ifndef SkImageFilter_DEFINED
9 #define SkImageFilter_DEFINED
11 #include "../private/SkTArray.h"
12 #include "../private/SkTemplates.h"
13 #include "../private/SkMutex.h"
14 #include "SkColorSpace.h"
15 #include "SkFilterQuality.h"
16 #include "SkFlattenable.h"
25 class SkImageFilterCache;
26 struct SkImageFilterCacheKey;
41 , fClipBounds(clipBounds)
45 const SkMatrix& ctm()
const {
return fCTM; }
46 const SkIRect& clipBounds()
const {
return fClipBounds; }
47 SkImageFilterCache* cache()
const {
return fCache; }
52 SkImageFilterCache* fCache;
58 kHasLeft_CropEdge = 0x01,
59 kHasTop_CropEdge = 0x02,
60 kHasWidth_CropEdge = 0x04,
61 kHasHeight_CropEdge = 0x08,
62 kHasAll_CropEdge = 0x0F,
65 explicit CropRect(
const SkRect& rect, uint32_t flags = kHasAll_CropEdge)
66 : fRect(rect), fFlags(flags) {}
67 uint32_t flags()
const {
return fFlags; }
68 const SkRect& rect()
const {
return fRect; }
69 #ifndef SK_IGNORE_TO_STRING
83 void applyTo(
const SkIRect& imageBounds,
const SkMatrix&,
bool embiggen,
115 kForward_MapDirection,
116 kReverse_MapDirection
130 MapDirection = kReverse_MapDirection)
const;
147 return this->onIsColorFilterNode(filterPtr);
152 return this->isColorFilterNode(filterPtr);
157 const CropRect* cropRect =
nullptr);
177 SkASSERT(i < fInputs.count());
178 return fInputs[i].get();
192 CropRect getCropRect()
const {
return fCropRect; }
198 bool canComputeFastBounds()
const;
206 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
208 return this->makeWithLocalMatrix(matrix).release();
217 bool canHandleComplexCTM()
const;
223 SkFilterQuality quality,
226 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
228 SkFilterQuality filterQuality,
230 return MakeMatrixFilter(matrix, filterQuality, sk_ref_sp<SkImageFilter>(input)).release();
234 SK_TO_STRING_PUREVIRT()
236 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
249 bool unflatten(SkReadBuffer&,
int expectedInputs);
251 const CropRect& cropRect()
const {
return fCropRect; }
252 int inputCount()
const {
return fInputs.count(); }
260 SkAutoSTArray<2, sk_sp<SkImageFilter>> fInputs;
262 void allocInputs(
int count);
361 bool applyCropRect(
const Context&,
const SkIRect& srcBounds,
SkIRect* dstBounds)
const;
381 Context mapContext(
const Context& ctx)
const;
385 static void PurgeCache();
389 bool usesSrcInput()
const {
return fUsesSrcInput; }
390 virtual bool affectsTransparentBlack()
const {
return false; }
392 SkAutoSTArray<2, sk_sp<SkImageFilter>> fInputs;
397 mutable SkTArray<SkImageFilterCacheKey> fCacheKeys;
398 mutable SkMutex fMutex;
405 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
408 if (!localVar.unflatten(buffer, expectedCount)) { \
Definition: SkImageFilter.h:55
Provides custom fragment shader code.
Definition: GrFragmentProcessor.h:24
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:29
int countInputs() const
Returns the number of inputs this filter will accept (some inputs can be NULL).
Definition: SkImageFilter.h:170
bool isColorFilterNode(SkColorFilter **filterPtr) const
Returns whether this image filter is a color filter and puts the color filter into the "filterPtr" pa...
Definition: SkImageFilter.h:146
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
virtual bool onIsColorFilterNode(SkColorFilter **) const
Return true (and return a ref'd colorfilter) if this node in the DAG is just a colorfilter w/o CropRe...
Definition: SkImageFilter.h:343
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:70
virtual bool onCanHandleComplexCTM() const
Override this to describe the behavior of your subclass - as a leaf node.
Definition: SkImageFilter.h:351
Base class for image filters.
Definition: SkImageFilter.h:35
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:258
Definition: GrContext.h:48
TileUsage
Definition: SkImageFilter.h:91
the created device will never be drawn tiled
Definition: SkImageFilter.h:93
SkImageFilter * getInput(int i) const
Returns the input filter at a given index, or NULL if no input is connected.
Definition: SkImageFilter.h:176
Definition: SkImageFilter.h:239
Definition: SkWriteBuffer.h:26
the created device may be drawn tiled
Definition: SkImageFilter.h:92
virtual void flatten(SkWriteBuffer &) const
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
Definition: SkFlattenable.h:117
bool cropRectIsSet() const
Returns whether any edges of the crop rect have been set.
Definition: SkImageFilter.h:190
Definition: SkImageFilter.h:37
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20
Definition: SkGraphics.h:17
SkIPoint holds two 32 bit integer coordinates.
Definition: SkPoint.h:40
Light weight class for managing strings.
Definition: SkString.h:121