aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkPathEffect.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-20 20:40:19 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-20 20:40:19 +0000
commit0a2bf90dccba3bde188e0386a7f0c60e6dde1ae9 (patch)
treeaa5c4198b4a200d6efe87d1a81964c8c219c1091 /include/core/SkPathEffect.h
parent4012ba51a218883daef6c9be142f970b8ef5d0d2 (diff)
Factory methods for heap-allocated SkPathEffect and SkXfermode objects.
This is part of an effort to ensure that all SkPaint effects can only be allocated on the heap. This patch makes the constructors of SkPathEffect, SkXfermode and their subclasses non-public and instead provides factory methods for creating these objects on the heap. We temporarily keep the constructors of the following classes public to not break Chrome/Blink: SkXfermode SkCornerPathEffect SkDashPathEffect BUG=skia:2187 R=scroggo@google.com, reed@google.com, mtklein@google.com, bungeman@google.com Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/166583002 git-svn-id: http://skia.googlecode.com/svn/trunk@13519 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkPathEffect.h')
-rw-r--r--include/core/SkPathEffect.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index 3f38f3a101..86ccf86a92 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -31,8 +31,6 @@ class SK_API SkPathEffect : public SkFlattenable {
public:
SK_DECLARE_INST_COUNT(SkPathEffect)
- SkPathEffect() {}
-
/**
* Given a src path (input) and a stroke-rec (input and output), apply
* this effect to the src path, returning the new path in dst, and return
@@ -109,6 +107,7 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
protected:
+ SkPathEffect() {}
SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
private:
@@ -127,10 +126,10 @@ private:
*/
class SkPairPathEffect : public SkPathEffect {
public:
- SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
virtual ~SkPairPathEffect();
protected:
+ SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
SkPairPathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
@@ -153,8 +152,9 @@ public:
The reference counts for outer and inner are both incremented in the constructor,
and decremented in the destructor.
*/
- SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
- : INHERITED(outer, inner) {}
+ static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
+ return SkNEW_ARGS(SkComposePathEffect, (outer, inner));
+ }
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -164,6 +164,12 @@ public:
protected:
SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
+ : INHERITED(outer, inner) {}
+
private:
// illegal
SkComposePathEffect(const SkComposePathEffect&);
@@ -184,8 +190,9 @@ public:
The reference counts for first and second are both incremented in the constructor,
and decremented in the destructor.
*/
- SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
- : INHERITED(first, second) {}
+ static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
+ return SkNEW_ARGS(SkSumPathEffect, (first, second));
+ }
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -195,6 +202,12 @@ public:
protected:
SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
+ : INHERITED(first, second) {}
+
private:
// illegal
SkSumPathEffect(const SkSumPathEffect&);