diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-29 15:20:16 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-29 15:20:16 +0000 |
commit | 2ac53399eefe1dbb8d43741ac7d89bda07bc70b2 (patch) | |
tree | 122d23f1df83ea1236c3a8d4818df7e4930dd45c | |
parent | 0e69b9ce679b69d9e870c993ecddc2c0cd06e496 (diff) | |
download | include-2ac53399eefe1dbb8d43741ac7d89bda07bc70b2.tar.gz |
add asAShadowBlur for android to drawlooper
BUG=skia:
R=djsollen@google.com, scroggo@google.com
Review URL: https://codereview.chromium.org/253633003
git-svn-id: http://skia.googlecode.com/svn/trunk/include@14431 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | core/SkDrawLooper.h | 21 | ||||
-rw-r--r-- | core/SkMaskFilter.h | 13 | ||||
-rw-r--r-- | effects/SkBlurDrawLooper.h | 5 | ||||
-rw-r--r-- | effects/SkEmbossMaskFilter.h | 4 | ||||
-rw-r--r-- | effects/SkLayerDrawLooper.h | 2 |
5 files changed, 41 insertions, 4 deletions
diff --git a/core/SkDrawLooper.h b/core/SkDrawLooper.h index cc42952..b92bacc 100644 --- a/core/SkDrawLooper.h +++ b/core/SkDrawLooper.h @@ -10,7 +10,10 @@ #ifndef SkDrawLooper_DEFINED #define SkDrawLooper_DEFINED +#include "SkBlurTypes.h" #include "SkFlattenable.h" +#include "SkPoint.h" +#include "SkColor.h" class SkCanvas; class SkPaint; @@ -88,6 +91,24 @@ public: virtual void computeFastBounds(const SkPaint& paint, const SkRect& src, SkRect* dst) const; + struct BlurShadowRec { + SkScalar fSigma; + SkVector fOffset; + SkColor fColor; + SkBlurStyle fStyle; + SkBlurQuality fQuality; + }; + /** + * If this looper can be interpreted as having two layers, such that + * 1. The first layer (bottom most) just has a blur and translate + * 2. The second layer has no modifications to either paint or canvas + * 3. No other layers. + * then return true, and if not null, fill out the BlurShadowRec). + * + * If any of the above are not met, return false and ignore the BlurShadowRec parameter. + */ + virtual bool asABlurShadow(BlurShadowRec*) const; + SK_TO_STRING_PUREVIRT() SK_DEFINE_FLATTENABLE_TYPE(SkDrawLooper) diff --git a/core/SkMaskFilter.h b/core/SkMaskFilter.h index 3113c93..8051e7d 100644 --- a/core/SkMaskFilter.h +++ b/core/SkMaskFilter.h @@ -10,6 +10,7 @@ #ifndef SkMaskFilter_DEFINED #define SkMaskFilter_DEFINED +#include "SkBlurTypes.h" #include "SkFlattenable.h" #include "SkMask.h" #include "SkPaint.h" @@ -138,6 +139,18 @@ public: */ virtual void computeFastBounds(const SkRect& src, SkRect* dest) const; + struct BlurRec { + SkScalar fSigma; + SkBlurStyle fStyle; + SkBlurQuality fQuality; + }; + /** + * If this filter can be represented by a BlurRec, return true and (if not null) fill in the + * provided BlurRec parameter. If this effect cannot be represented as a BlurRec, return false + * and ignore the BlurRec parameter. + */ + virtual bool asABlur(BlurRec*) const; + SK_TO_STRING_PUREVIRT() SK_DEFINE_FLATTENABLE_TYPE(SkMaskFilter) diff --git a/effects/SkBlurDrawLooper.h b/effects/SkBlurDrawLooper.h index fe945c3..75ed80e 100644 --- a/effects/SkBlurDrawLooper.h +++ b/effects/SkBlurDrawLooper.h @@ -61,10 +61,12 @@ protected: SkBlurDrawLooper(SkReadBuffer&); virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; + virtual bool asABlurShadow(BlurShadowRec*) const SK_OVERRIDE; + private: SkMaskFilter* fBlur; SkColorFilter* fColorFilter; - SkScalar fDx, fDy; + SkScalar fDx, fDy, fSigma; SkColor fBlurColor; uint32_t fBlurFlags; @@ -86,6 +88,7 @@ private: }; void init(SkScalar sigma, SkScalar dx, SkScalar dy, SkColor color, uint32_t flags); + void initEffects(); typedef SkDrawLooper INHERITED; }; diff --git a/effects/SkEmbossMaskFilter.h b/effects/SkEmbossMaskFilter.h index eb8f811..65dbbe7 100644 --- a/effects/SkEmbossMaskFilter.h +++ b/effects/SkEmbossMaskFilter.h @@ -23,9 +23,7 @@ public: uint8_t fSpecular; // exponent, 4.4 right now }; - static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light) { - return SkNEW_ARGS(SkEmbossMaskFilter, (blurSigma, light)); - } + static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light); // overrides from SkMaskFilter // This method is not exported to java. diff --git a/effects/SkLayerDrawLooper.h b/effects/SkLayerDrawLooper.h index fe660a8..ac56e28 100644 --- a/effects/SkLayerDrawLooper.h +++ b/effects/SkLayerDrawLooper.h @@ -77,6 +77,8 @@ public: virtual size_t contextSize() const SK_OVERRIDE { return sizeof(LayerDrawLooperContext); } + virtual bool asABlurShadow(BlurShadowRec* rec) const SK_OVERRIDE; + SK_TO_STRING_OVERRIDE() /// Implements Flattenable. |