Chromium Code Reviews| Index: include/core/SkMaskFilter.h |
| =================================================================== |
| --- include/core/SkMaskFilter.h (revision 9773) |
| +++ include/core/SkMaskFilter.h (working copy) |
| @@ -14,6 +14,7 @@ |
| #include "SkMask.h" |
| #include "SkPaint.h" |
| +class SkBitmap; |
| class SkBlitter; |
| class SkBounder; |
| class SkMatrix; |
| @@ -58,27 +59,47 @@ |
| virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, |
| SkIPoint* margin) const; |
| - enum BlurType { |
| - kNone_BlurType, //!< this maskfilter is not a blur |
| - kNormal_BlurType, //!< fuzzy inside and outside |
| - kSolid_BlurType, //!< solid inside, fuzzy outside |
| - kOuter_BlurType, //!< nothing inside, fuzzy outside |
| - kInner_BlurType //!< fuzzy inside, nothing outside |
| - }; |
| +#if SK_SUPPORT_GPU |
| + /** |
| + * Returns true if the filter can be expressed a single-pass |
| + * GrEffect, used to process this filter on the GPU, or false if |
| + * not. |
| + * |
| + * If effect is non-NULL, a new GrEffect instance is stored |
| + * in it. The caller assumes ownership of the stage, and it is up to the |
| + * caller to unref it. |
| + */ |
| + virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const; |
|
robertphillips
2013/06/28 17:46:12
The next two calls mimic the ImageFilter. What do
bsalomon
2013/06/28 18:32:42
Is it useful to be able to filter CPU bitmaps? See
|
| - struct BlurInfo { |
| - SkScalar fRadius; |
| - bool fIgnoreTransform; |
| - bool fHighQuality; |
| - }; |
| + /** |
| + * Returns true if the filter can be processed on the GPU. This is most |
| + * often used for multi-pass effects, where intermediate results must be |
| + * rendered to textures. For single-pass effects, use asNewEffect(). |
| + * |
| + * 'maskRect' returns the device space portion of the mask the the filter |
| + * needs. The mask passed into 'filterMaskGPU' should have the same extent |
| + * as 'maskRect' but be translated to the upper-left corner of the mask |
| + * (i.e., (maskRect.fLeft, maskRect.fTop) appears at (0, 0) in the mask). |
| + */ |
| + virtual bool canFilterMaskGPU(const SkRect& devBounds, |
| + const SkIRect& clipBounds, |
| + const SkMatrix& ctm, |
| + SkRect* maskRect) const; |
| /** |
| - * Optional method for maskfilters that can be described as a blur. If so, |
| - * they return the corresponding BlurType and set the fields in BlurInfo |
| - * (if not null). If they cannot be described as a blur, they return |
| - * kNone_BlurType and ignore the info parameter. |
| + * Perform this mask filter on the GPU. This is most often used for |
| + * multi-pass effects, where intermediate results must be rendered to |
| + * textures. For single-pass effects, use asNewEffect(). 'src' is the |
| + * source image for processing, as a texture-backed bitmap. 'result' is |
| + * the destination bitmap, which should contain a texture-backed pixelref |
| + * on success. 'maskRect' should be the rect returned from canFilterMaskGPU. |
| + * |
| + * Note: the texture backing 'src' may be recycled for 'result' |
| */ |
|
robertphillips
2013/06/28 17:46:12
What do you think about this signature actually be
bsalomon
2013/06/28 18:32:42
oh dear... why?
|
| - virtual BlurType asABlur(BlurInfo*) const; |
| + virtual bool filterMaskGPU(const SkBitmap& src, |
| + const SkRect& maskRect, |
| + SkBitmap* result) const; |
| +#endif |
| /** |
| * The fast bounds function is used to enable the paint to be culled early |