virtual SkBaseDevice* createDevice(int width, int height) = 0;
// returns true if the proxy can handle this filter natively
- virtual bool canHandleImageFilter(SkImageFilter*) = 0;
+ virtual bool canHandleImageFilter(const SkImageFilter*) = 0;
// returns true if the proxy handled the filter itself. if this returns
// false then the filter's code will be called.
- virtual bool filterImage(SkImageFilter*, const SkBitmap& src,
+ virtual bool filterImage(const SkImageFilter*, const SkBitmap& src,
const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) = 0;
};
* the result and offset parameters will be ignored by the caller.
*/
bool filterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
- SkBitmap* result, SkIPoint* offset);
+ SkBitmap* result, SkIPoint* offset) const;
/**
* Given the src bounds of an image, this returns the bounds of the result
* image after the filter has been applied.
*/
- bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst);
+ bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const;
/**
* Returns true if the filter can be processed on the GPU. This is most
* single-pass processing using asNewEffect().
*/
virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
- SkBitmap* result, SkIPoint* offset);
+ SkBitmap* result, SkIPoint* offset) const;
/**
* Returns whether this image filter is a color filter and puts the color filter into the
*/
bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
+ // Default impl returns union of all input bounds.
+ virtual void computeFastBounds(const SkRect&, SkRect*) const;
+
SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter)
protected:
virtual ~SkImageFilter();
/**
- * Constructs a new SkImageFilter read from an SkFlattenableReadBuffer object.
+ * Constructs a new SkImageFilter read from an SkReadBuffer object.
*
* @param inputCount The exact number of inputs expected for this SkImageFilter object.
* -1 can be used if the filter accepts any number of inputs.
- * @param rb SkFlattenableReadBuffer object from which the SkImageFilter is read.
+ * @param rb SkReadBuffer object from which the SkImageFilter is read.
*/
- explicit SkImageFilter(int inputCount, SkFlattenableReadBuffer& rb);
+ explicit SkImageFilter(int inputCount, SkReadBuffer& rb);
- virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE;
+ virtual void flatten(SkWriteBuffer& wb) const SK_OVERRIDE;
/**
* This is the virtual which should be overridden by the derived class
* caller.
*/
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
- SkBitmap* result, SkIPoint* offset);
- // Default impl copies src into dst and returns true
- virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*);
+ SkBitmap* result, SkIPoint* offset) const;
+ // Given the bounds of the destination rect to be filled in device
+ // coordinates (first parameter), and the CTM, compute (conservatively)
+ // which rect of the source image would be required (third parameter).
+ // Used for clipping and temp-buffer allocations, so the result need not
+ // be exact, but should never be smaller than the real answer. The default
+ // implementation recursively unions all input bounds, or returns false if
+ // no inputs.
+ virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const;
// Applies "matrix" to the crop rect, and sets "rect" to the intersection of
// "rect" and the transformed crop rect. If there is no overlap, returns