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"
21 class GrFragmentProcessor;
23 class SkColorSpaceXformer;
26 class SkImageFilterCache;
27 struct SkImageFilterCacheKey;
59 , fClipBounds(clipBounds)
61 , fOutputProperties(outputProperties)
64 const SkMatrix& ctm()
const {
return fCTM; }
65 const SkIRect& clipBounds()
const {
return fClipBounds; }
66 SkImageFilterCache* cache()
const {
return fCache; }
67 const OutputProperties& outputProperties()
const {
return fOutputProperties; }
72 SkImageFilterCache* fCache;
79 kHasLeft_CropEdge = 0x01,
80 kHasTop_CropEdge = 0x02,
81 kHasWidth_CropEdge = 0x04,
82 kHasHeight_CropEdge = 0x08,
83 kHasAll_CropEdge = 0x0F,
86 explicit CropRect(
const SkRect& rect, uint32_t flags = kHasAll_CropEdge)
87 : fRect(rect), fFlags(flags) {}
88 uint32_t flags()
const {
return fFlags; }
89 const SkRect& rect()
const {
return fRect; }
90 #ifndef SK_IGNORE_TO_STRING
104 void applyTo(
const SkIRect& imageBounds,
const SkMatrix&,
bool embiggen,
136 kForward_MapDirection,
137 kReverse_MapDirection
151 MapDirection = kReverse_MapDirection)
const;
157 const OutputProperties& outputProperties);
168 return this->onIsColorFilterNode(filterPtr);
173 return this->isColorFilterNode(filterPtr);
194 SkASSERT(i < fInputs.count());
195 return fInputs[i].get();
209 CropRect getCropRect()
const {
return fCropRect; }
215 bool canComputeFastBounds()
const;
228 bool canHandleComplexCTM()
const;
234 SkFilterQuality quality,
237 SK_TO_STRING_PUREVIRT()
239 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
252 bool unflatten(SkReadBuffer&,
int expectedInputs);
254 const CropRect& cropRect()
const {
return fCropRect; }
255 int inputCount()
const {
return fInputs.count(); }
263 SkAutoSTArray<2, sk_sp<SkImageFilter>> fInputs;
265 void allocInputs(
int count);
283 const CropRect* getCropRectIfSet()
const {
284 return this->cropRectIsSet() ? &fCropRect :
nullptr;
368 bool applyCropRect(
const Context&,
const SkIRect& srcBounds,
SkIRect* dstBounds)
const;
388 Context mapContext(
const Context& ctx)
const;
403 return this->onMakeColorSpace(xformer);
409 friend class ArithmeticImageFilterImpl;
410 friend class SkAlphaThresholdFilterImpl;
411 friend class SkBlurImageFilterImpl;
413 friend class SkColorSpaceXformer;
415 friend class SkDiffuseLightingImageFilter;
421 friend class SkMatrixImageFilter;
422 friend class SkLocalMatrixImageFilter;
426 friend class SkSpecularLightingImageFilter;
428 friend class SkXfermodeImageFilter_Base;
432 static void PurgeCache();
436 bool usesSrcInput()
const {
return fUsesSrcInput; }
437 virtual bool affectsTransparentBlack()
const {
return false; }
439 SkAutoSTArray<2, sk_sp<SkImageFilter>> fInputs;
444 mutable SkTArray<SkImageFilterCacheKey> fCacheKeys;
445 mutable SkMutex fMutex;
452 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
455 if (!localVar.unflatten(buffer, expectedCount)) { \
Definition: SkDropShadowImageFilter.h:15
Definition: SkImageFilter.h:76
Definition: SkImageFilter.h:42
Definition: SkColorSpace.h:59
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:32
int countInputs() const
Returns the number of inputs this filter will accept (some inputs can be NULL).
Definition: SkImageFilter.h:187
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:167
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
Definition: SkMergeImageFilter.h:13
Definition: SkMatrixConvolutionImageFilter.h:24
sk_sp< SkImageFilter > makeColorSpace(SkColorSpaceXformer *xformer) const
Returns an image filter transformed into a new color space via the |xformer|.
Definition: SkImageFilter.h:402
Definition: SkColorFilterImageFilter.h:15
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:350
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:358
Base class for image filters.
Definition: SkImageFilter.h:36
Definition: SkOffsetImageFilter.h:14
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:246
Definition: SkMagnifierImageFilter.h:15
Definition: GrContext.h:47
TileUsage
Definition: SkImageFilter.h:112
Definition: SkTileImageFilter.h:13
the created device will never be drawn tiled
Definition: SkImageFilter.h:114
SkImageFilter * getInput(int i) const
Returns the input filter at a given index, or NULL if no input is connected.
Definition: SkImageFilter.h:193
Definition: SkImageSource.h:14
Definition: SkImageFilter.h:242
Definition: SkWriteBuffer.h:27
the created device may be drawn tiled
Definition: SkImageFilter.h:113
Definition: SkMorphologyImageFilter.h:16
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:207
Definition: SkComposeImageFilter.h:13
Definition: SkImageFilter.h:54
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
Definition: SkDisplacementMapEffect.h:13