diff options
author | 2014-04-15 15:48:36 +0000 | |
---|---|---|
committer | 2014-04-15 15:48:36 +0000 | |
commit | 73cb15351f33459e0c861a96135c634dec77ef9d (patch) | |
tree | cf521a48286c5cd88354056e65a933cc63f8fbe1 /include/effects | |
parent | beb8b3a4da83ce30e313e72ae0e444870acecb7e (diff) |
Make sure SkDrawLooper objects can only be allocated on the heap.
Make constructors of SkLayerDrawLooper and SkBlurDrawLooper non-public.
Remove addLayer* methods from SkLayerDrawLooper. SkLayerDrawLooper::Builder is
used to create new objects.
Provide factory method for creating SkBlurDrawLooper.
BUG=2141
R=scroggo@google.com, reed@google.com, djsollen@google.com
Author: dominikg@chromium.org
Review URL: https://codereview.chromium.org/232913003
git-svn-id: http://skia.googlecode.com/svn/trunk@14200 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects')
-rw-r--r-- | include/effects/SkBlurDrawLooper.h | 13 | ||||
-rw-r--r-- | include/effects/SkLayerDrawLooper.h | 23 |
2 files changed, 12 insertions, 24 deletions
diff --git a/include/effects/SkBlurDrawLooper.h b/include/effects/SkBlurDrawLooper.h index 5469e2cf02..fe945c3801 100644 --- a/include/effects/SkBlurDrawLooper.h +++ b/include/effects/SkBlurDrawLooper.h @@ -35,12 +35,16 @@ public: kAll_BlurFlag = 0x07 }; - SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, - uint32_t flags = kNone_BlurFlag); + static SkBlurDrawLooper* Create(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, + uint32_t flags = kNone_BlurFlag) { + return SkNEW_ARGS(SkBlurDrawLooper, (color, sigma, dx, dy, flags)); + } -// SK_ATTR_DEPRECATED("use sigma version") +#ifdef SK_SUPPORT_LEGACY_BLURDRAWLOOPERCONSTRUCTORS SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color, uint32_t flags = kNone_BlurFlag); +#endif + virtual ~SkBlurDrawLooper(); virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVERRIDE; @@ -51,6 +55,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper) protected: + SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, + uint32_t flags); + SkBlurDrawLooper(SkReadBuffer&); virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index 1e76ce21e5..fe660a8aae 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -17,7 +17,6 @@ class SK_API SkLayerDrawLooper : public SkDrawLooper { public: SK_DECLARE_INST_COUNT(SkLayerDrawLooper) - SkLayerDrawLooper(); virtual ~SkLayerDrawLooper(); /** @@ -74,26 +73,6 @@ public: LayerInfo(); }; - /** - * Call for each layer you want to add (from top to bottom). - * This returns a paint you can modify, but that ptr is only valid until - * the next call made to addLayer(). - */ - SkPaint* addLayer(const LayerInfo&); - - /** - * This layer will draw with the original paint, at the specified offset - */ - void addLayer(SkScalar dx, SkScalar dy); - - /** - * This layer will with the original paint and no offset. - */ - void addLayer() { this->addLayer(0, 0); } - - /// Similar to addLayer, but adds a layer to the top. - SkPaint* addLayerOnTop(const LayerInfo&); - virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE { return sizeof(LayerDrawLooperContext); } @@ -105,6 +84,8 @@ public: static SkFlattenable* CreateProc(SkReadBuffer& buffer); protected: + SkLayerDrawLooper(); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: |