| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkMaskFilter_DEFINED | 10 #ifndef SkMaskFilter_DEFINED |
| 11 #define SkMaskFilter_DEFINED | 11 #define SkMaskFilter_DEFINED |
| 12 | 12 |
| 13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
| 14 #include "SkMask.h" | 14 #include "SkMask.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 | 16 |
| 17 class SkBitmap; |
| 17 class SkBlitter; | 18 class SkBlitter; |
| 18 class SkBounder; | 19 class SkBounder; |
| 19 class SkMatrix; | 20 class SkMatrix; |
| 20 class SkPath; | 21 class SkPath; |
| 21 class SkRasterClip; | 22 class SkRasterClip; |
| 22 | 23 |
| 23 /** \class SkMaskFilter | 24 /** \class SkMaskFilter |
| 24 | 25 |
| 25 SkMaskFilter is the base class for object that perform transformations on | 26 SkMaskFilter is the base class for object that perform transformations on |
| 26 an alpha-channel mask before drawing it. A subclass of SkMaskFilter may be | 27 an alpha-channel mask before drawing it. A subclass of SkMaskFilter may be |
| (...skipping 24 matching lines...) Expand all Loading... |
| 51 @param src the original image to be filtered. | 52 @param src the original image to be filtered. |
| 52 @param matrix the CTM | 53 @param matrix the CTM |
| 53 @param margin if not null, return the buffer dx/dy need when calculati
ng the effect. Used when | 54 @param margin if not null, return the buffer dx/dy need when calculati
ng the effect. Used when |
| 54 drawing a clipped object to know how much larger to allo
cate the src before | 55 drawing a clipped object to know how much larger to allo
cate the src before |
| 55 applying the filter. If returning false, ignore this par
ameter. | 56 applying the filter. If returning false, ignore this par
ameter. |
| 56 @return true if the dst mask was correctly created. | 57 @return true if the dst mask was correctly created. |
| 57 */ | 58 */ |
| 58 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, | 59 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, |
| 59 SkIPoint* margin) const; | 60 SkIPoint* margin) const; |
| 60 | 61 |
| 61 enum BlurType { | 62 #if SK_SUPPORT_GPU |
| 62 kNone_BlurType, //!< this maskfilter is not a blur | 63 /** |
| 63 kNormal_BlurType, //!< fuzzy inside and outside | 64 * Returns true if the filter can be expressed a single-pass |
| 64 kSolid_BlurType, //!< solid inside, fuzzy outside | 65 * GrEffect, used to process this filter on the GPU, or false if |
| 65 kOuter_BlurType, //!< nothing inside, fuzzy outside | 66 * not. |
| 66 kInner_BlurType //!< fuzzy inside, nothing outside | 67 * |
| 67 }; | 68 * If effect is non-NULL, a new GrEffect instance is stored |
| 68 | 69 * in it. The caller assumes ownership of the stage, and it is up to the |
| 69 struct BlurInfo { | 70 * caller to unref it. |
| 70 SkScalar fRadius; | 71 */ |
| 71 bool fIgnoreTransform; | 72 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const; |
| 72 bool fHighQuality; | |
| 73 }; | |
| 74 | 73 |
| 75 /** | 74 /** |
| 76 * Optional method for maskfilters that can be described as a blur. If so, | 75 * Returns true if the filter can be processed on the GPU. This is most |
| 77 * they return the corresponding BlurType and set the fields in BlurInfo | 76 * often used for multi-pass effects, where intermediate results must be |
| 78 * (if not null). If they cannot be described as a blur, they return | 77 * rendered to textures. For single-pass effects, use asNewEffect(). |
| 79 * kNone_BlurType and ignore the info parameter. | 78 * |
| 79 * 'maskRect' returns the device space portion of the mask the the filter |
| 80 * needs. The mask passed into 'filterMaskGPU' should have the same extent |
| 81 * as 'maskRect' but be translated to the upper-left corner of the mask |
| 82 * (i.e., (maskRect.fLeft, maskRect.fTop) appears at (0, 0) in the mask). |
| 80 */ | 83 */ |
| 81 virtual BlurType asABlur(BlurInfo*) const; | 84 virtual bool canFilterMaskGPU(const SkRect& devBounds, |
| 85 const SkIRect& clipBounds, |
| 86 const SkMatrix& ctm, |
| 87 SkRect* maskRect) const; |
| 88 |
| 89 /** |
| 90 * Perform this mask filter on the GPU. This is most often used for |
| 91 * multi-pass effects, where intermediate results must be rendered to |
| 92 * textures. For single-pass effects, use asNewEffect(). 'src' is the |
| 93 * source image for processing, as a texture-backed bitmap. 'result' is |
| 94 * the destination bitmap, which should contain a texture-backed pixelref |
| 95 * on success. 'maskRect' should be the rect returned from canFilterMaskGPU
. |
| 96 */ |
| 97 bool filterMaskGPU(GrContext* context, |
| 98 const SkBitmap& src, |
| 99 const SkRect& maskRect, |
| 100 SkBitmap* result) const; |
| 101 |
| 102 /** |
| 103 * This flavor of 'filterMaskGPU' provides a more direct means of accessing |
| 104 * the filtering capabilities. Setting 'canOverwriteSrc' can allow some |
| 105 * filters to skip the allocation of an additional texture. |
| 106 */ |
| 107 virtual bool filterMaskGPU(GrTexture* src, |
| 108 const SkRect& maskRect, |
| 109 GrTexture** result, |
| 110 bool canOverwriteSrc) const; |
| 111 #endif |
| 82 | 112 |
| 83 /** | 113 /** |
| 84 * The fast bounds function is used to enable the paint to be culled early | 114 * The fast bounds function is used to enable the paint to be culled early |
| 85 * in the drawing pipeline. This function accepts the current bounds of the | 115 * in the drawing pipeline. This function accepts the current bounds of the |
| 86 * paint as its src param and the filter adjust those bounds using its | 116 * paint as its src param and the filter adjust those bounds using its |
| 87 * current mask and returns the result using the dest param. Callers are | 117 * current mask and returns the result using the dest param. Callers are |
| 88 * allowed to provide the same struct for both src and dest so each | 118 * allowed to provide the same struct for both src and dest so each |
| 89 * implementation must accomodate that behavior. | 119 * implementation must accomodate that behavior. |
| 90 * | 120 * |
| 91 * The default impl calls filterMask with the src mask having no image, | 121 * The default impl calls filterMask with the src mask having no image, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 This method is not exported to java. | 170 This method is not exported to java. |
| 141 */ | 171 */ |
| 142 bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix, | 172 bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix, |
| 143 const SkRasterClip&, SkBounder*, SkBlitter* blitter, | 173 const SkRasterClip&, SkBounder*, SkBlitter* blitter, |
| 144 SkPaint::Style style) const; | 174 SkPaint::Style style) const; |
| 145 | 175 |
| 146 typedef SkFlattenable INHERITED; | 176 typedef SkFlattenable INHERITED; |
| 147 }; | 177 }; |
| 148 | 178 |
| 149 #endif | 179 #endif |
| OLD | NEW |