Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: include/core/SkMaskFilter.h

Issue 18110012: Add canFilterMaskGPU & filterMaskGPU to SkMaskFilter (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: added comments & fixed nits Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkMaskFilter.cpp » ('j') | src/core/SkMaskFilter.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkMaskFilter.h
===================================================================
--- include/core/SkMaskFilter.h (revision 9883)
+++ 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,29 +59,58 @@
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;
- 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.
*/
- virtual BlurType asABlur(BlurInfo*) const;
+ bool filterMaskGPU(GrContext* context,
+ const SkBitmap& src,
+ const SkRect& maskRect,
+ SkBitmap* result) const;
/**
+ * This flavor of 'filterMaskGPU' provides a more direct means of accessing
+ * the filtering capabilities. Setting 'canOverwriteSrc' can allow some
+ * filters to skip the allocation of an additional texture.
+ */
+ virtual bool filterMaskGPU(GrTexture* src,
+ const SkRect& maskRect,
+ GrTexture** result,
+ bool canOverwriteSrc) const;
+#endif
+
+ /**
* The fast bounds function is used to enable the paint to be culled early
* in the drawing pipeline. This function accepts the current bounds of the
* paint as its src param and the filter adjust those bounds using its
« no previous file with comments | « no previous file | src/core/SkMaskFilter.cpp » ('j') | src/core/SkMaskFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698