SkImageFilter.h revision 15356a68b2a87e3ab9fc49392d085a4201ffeb62
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 11#include "SkFlattenable.h" 12 13class SkBitmap; 14class SkMatrix; 15struct SkPoint; 16 17/** 18 * Experimental. 19 * 20 * Base class for image filters. If one is installed in the paint, then 21 * all drawing occurs as usual, but it is as if the drawing happened into an 22 * offscreen (before the xfermode is applied). This offscreen bitmap will 23 * then be handed to the imagefilter, who in turn creates a new bitmap which 24 * is what will finally be drawn to the device (using the original xfermode). 25 * 26 * If the imagefilter returns false, nothing is drawn. 27 */ 28class SK_API SkImageFilter : public SkRefCnt /*SkFlattenable*/ { 29public: 30 31 /** 32 * Request a new (result) image to be created from the src image. 33 * If the src has no pixels (isNull()) then the request just wants to 34 * receive the config and width/height of the result. 35 * 36 * The matrix is the current matrix on the canvas. 37 * 38 * Offset is the amount to translate the resulting image relative to the 39 * src when it is drawn. 40 * 41 * If the result image cannot be created, return false, in which case both 42 * the result and offset parameters will be ignored by the caller. 43 */ 44 bool filterImage(const SkBitmap& src, const SkMatrix&, 45 SkBitmap* result, SkIPoint* offset); 46 47 /** 48 * Experimental. 49 * 50 * If the filter can be expressed as a gaussian-blur, return true and 51 * set the sigma to the values for horizontal and vertical. 52 */ 53 virtual bool asABlur(SkSize* sigma) const; 54 55protected: 56 virtual bool onFilterImage(const SkBitmap& src, const SkMatrix&, 57 SkBitmap* result, SkIPoint* offset); 58 59private: 60 typedef SkRefCnt INHERITED; 61}; 62 63#endif 64