| 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 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 @param margin if not null, return the buffer dx/dy need when calculati
ng the effect. Used when | 56 @param margin if not null, return the buffer dx/dy need when calculati
ng the effect. Used when |
| 57 drawing a clipped object to know how much larger to allo
cate the src before | 57 drawing a clipped object to know how much larger to allo
cate the src before |
| 58 applying the filter. If returning false, ignore this par
ameter. | 58 applying the filter. If returning false, ignore this par
ameter. |
| 59 @return true if the dst mask was correctly created. | 59 @return true if the dst mask was correctly created. |
| 60 */ | 60 */ |
| 61 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, | 61 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, |
| 62 SkIPoint* margin) const; | 62 SkIPoint* margin) const; |
| 63 | 63 |
| 64 #if SK_SUPPORT_GPU | 64 #if SK_SUPPORT_GPU |
| 65 /** | 65 /** |
| 66 * Returns true if the filter can be expressed a single-pass | 66 * Returns true if the filter can be expressed a single-pass GrEffect witho
ut requiring an |
| 67 * GrEffect, used to process this filter on the GPU, or false if | 67 * explicit input mask. Per-pixel, the effect receives the incoming mask's
coverage as |
| 68 * not. | 68 * the input color and outputs the filtered covereage value. This means tha
t each pixel's |
| 69 * filtered coverage must only depend on the unfiltered mask value for that
pixel and not on |
| 70 * surrounding values. |
| 69 * | 71 * |
| 70 * If effect is non-NULL, a new GrEffect instance is stored | 72 * If effect is non-NULL, a new GrEffect instance is stored in it. The calle
r assumes ownership |
| 71 * in it. The caller assumes ownership of the stage, and it is up to the | 73 * of the effect and must unref it. |
| 72 * caller to unref it. | |
| 73 */ | 74 */ |
| 74 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const; | 75 virtual bool asNewEffect(GrEffectRef** effect, |
| 76 GrTexture*, |
| 77 const SkMatrix& ctm) const; |
| 75 | 78 |
| 76 /** | 79 /** |
| 77 * Returns true if the filter can be processed on the GPU. This is most | 80 * If asNewEffect() fails the filter may be implemented on the GPU by a sub
class overriding |
| 78 * often used for multi-pass effects, where intermediate results must be | 81 * filterMaskGPU (declared below). That code path requires constructing a s
rc mask as input. |
| 79 * rendered to textures. For single-pass effects, use asNewEffect(). | 82 * Since that is a potentially expensive operation, the subclass must also
override this |
| 83 * function to indicate whether filterTextureMaskGPU would succeeed if the
mask were to be |
| 84 * created. |
| 80 * | 85 * |
| 81 * 'maskRect' returns the device space portion of the mask the the filter | 86 * 'maskRect' returns the device space portion of the mask that the filter
needs. The mask |
| 82 * needs. The mask passed into 'filterMaskGPU' should have the same extent | 87 * passed into 'filterMaskGPU' should have the same extent as 'maskRect' bu
t be translated |
| 83 * as 'maskRect' but be translated to the upper-left corner of the mask | 88 * to the upper-left corner of the mask (i.e., (maskRect.fLeft, maskRect.fT
op) appears at |
| 84 * (i.e., (maskRect.fLeft, maskRect.fTop) appears at (0, 0) in the mask). | 89 * (0, 0) in the mask). |
| 85 */ | 90 */ |
| 86 virtual bool canFilterMaskGPU(const SkRect& devBounds, | 91 virtual bool canFilterMaskGPU(const SkRect& devBounds, |
| 87 const SkIRect& clipBounds, | 92 const SkIRect& clipBounds, |
| 88 const SkMatrix& ctm, | 93 const SkMatrix& ctm, |
| 89 SkRect* maskRect) const; | 94 SkRect* maskRect) const; |
| 90 | 95 |
| 91 /** | 96 /** |
| 92 * Perform this mask filter on the GPU. This is most often used for | 97 * This function is used to implement filters that require an explicit src m
ask. It should only |
| 93 * multi-pass effects, where intermediate results must be rendered to | 98 * be called if canFilterMaskGPU returned true and the maskRect param should
be the output from |
| 94 * textures. For single-pass effects, use asNewEffect(). 'src' is the | 99 * that call. canOverwriteSrc indicates whether the implementation may treat
src as a scratch |
| 95 * source image for processing, as a texture-backed bitmap. 'result' is | 100 * texture and overwrite its contents. When true it is also legal to return
src as the result. |
| 96 * the destination bitmap, which should contain a texture-backed pixelref | 101 * Implementations are free to get the GrContext from the src texture in ord
er to create |
| 97 * on success. 'maskRect' should be the rect returned from canFilterMaskGPU
. | 102 * additional textures and perform multiple passes. |
| 98 */ | |
| 99 bool filterMaskGPU(GrContext* context, | |
| 100 const SkBitmap& src, | |
| 101 const SkRect& maskRect, | |
| 102 SkBitmap* result) const; | |
| 103 | |
| 104 /** | |
| 105 * This flavor of 'filterMaskGPU' provides a more direct means of accessing | |
| 106 * the filtering capabilities. Setting 'canOverwriteSrc' can allow some | |
| 107 * filters to skip the allocation of an additional texture. | |
| 108 */ | 103 */ |
| 109 virtual bool filterMaskGPU(GrTexture* src, | 104 virtual bool filterMaskGPU(GrTexture* src, |
| 105 const SkMatrix& ctm, |
| 110 const SkRect& maskRect, | 106 const SkRect& maskRect, |
| 111 GrTexture** result, | 107 GrTexture** result, |
| 112 bool canOverwriteSrc) const; | 108 bool canOverwriteSrc) const; |
| 113 #endif | 109 #endif |
| 114 | 110 |
| 115 /** | 111 /** |
| 116 * The fast bounds function is used to enable the paint to be culled early | 112 * The fast bounds function is used to enable the paint to be culled early |
| 117 * in the drawing pipeline. This function accepts the current bounds of the | 113 * in the drawing pipeline. This function accepts the current bounds of the |
| 118 * paint as its src param and the filter adjust those bounds using its | 114 * paint as its src param and the filter adjust those bounds using its |
| 119 * current mask and returns the result using the dest param. Callers are | 115 * current mask and returns the result using the dest param. Callers are |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 to render that mask. Returns false if filterMask() returned false. | 183 to render that mask. Returns false if filterMask() returned false. |
| 188 */ | 184 */ |
| 189 bool filterRRect(const SkRRect& devRRect, const SkMatrix& devMatrix, | 185 bool filterRRect(const SkRRect& devRRect, const SkMatrix& devMatrix, |
| 190 const SkRasterClip&, SkBounder*, SkBlitter* blitter, | 186 const SkRasterClip&, SkBounder*, SkBlitter* blitter, |
| 191 SkPaint::Style style) const; | 187 SkPaint::Style style) const; |
| 192 | 188 |
| 193 typedef SkFlattenable INHERITED; | 189 typedef SkFlattenable INHERITED; |
| 194 }; | 190 }; |
| 195 | 191 |
| 196 #endif | 192 #endif |
| OLD | NEW |