aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-01-07 09:06:08 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-07 09:06:08 -0800
commit7e44bb191633e225fd0455c267dbf67f9ee8633e (patch)
tree72f17ea3dcd93cd246d1f436317c8131cd69ec69
parent152f524fd325b7776b01f84afbfe2fa071648a05 (diff)
Remove macros that make it look like it's a good idea to not be able to flatten.
There are only a handful of SkFlattenables that are not flattenable. That there are any seems highly illogical. To make this look less like a normal thing, this removes both macros that marked SkFlattenables as non-flattenable (in slightly different ways). The handful of SkFlattenables in our codebase that can't be flattened now assert violently that they can't be flattened. They're internal or part of animator... places where we'll never actually flatten them. TestLooper and DummyRasterizer were so trivial that I just made them flattenable. BUG=skia: Review URL: https://codereview.chromium.org/841753002
-rw-r--r--include/core/SkFlattenable.h12
-rw-r--r--include/effects/Sk2DPathEffect.h2
-rw-r--r--src/animator/SkDrawExtraPathEffect.cpp6
-rw-r--r--src/core/SkDraw.cpp4
-rw-r--r--tests/LayerRasterizerTest.cpp6
-rw-r--r--tests/QuickRejectTest.cpp6
6 files changed, 17 insertions, 19 deletions
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index 3cfa85af48..e45627dbcc 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -40,9 +40,6 @@ class SkWriteBuffer;
#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
}
-#define SK_DECLARE_UNFLATTENABLE_OBJECT() \
- virtual Factory getFactory() const SK_OVERRIDE { return NULL; }
-
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
flattenable::GetFlattenableType());
@@ -54,10 +51,6 @@ class SkWriteBuffer;
public: \
virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; }
-// If your subclass will *never* need to be unflattened, declare this.
-#define SK_DECLARE_NOT_FLATTENABLE_PROCS(flattenable) \
- virtual Factory getFactory() const SK_OVERRIDE { return ReturnNullCreateProc; }
-
/** For SkFlattenable derived objects with a valid type
This macro should only be used in base class objects in core
*/
@@ -122,11 +115,6 @@ public:
*/
virtual void flatten(SkWriteBuffer&) const {}
-protected:
- static SkFlattenable* ReturnNullCreateProc(SkReadBuffer&) {
- return NULL;
- }
-
private:
static void InitializeFlattenablesIfNeeded();
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index 97c86ec7f2..404bf0aa6a 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -16,8 +16,6 @@ class SK_API Sk2DPathEffect : public SkPathEffect {
public:
virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
- SK_DECLARE_UNFLATTENABLE_OBJECT()
-
protected:
/** New virtual, to be overridden by subclasses.
This is called once from filterPath, and provides the
diff --git a/src/animator/SkDrawExtraPathEffect.cpp b/src/animator/SkDrawExtraPathEffect.cpp
index cc097d0a9e..dc586055a7 100644
--- a/src/animator/SkDrawExtraPathEffect.cpp
+++ b/src/animator/SkDrawExtraPathEffect.cpp
@@ -89,7 +89,8 @@ public:
fDraw(draw), fMaker(maker) {
}
- SK_DECLARE_UNFLATTENABLE_OBJECT()
+ // For serialization. This will never be called.
+ Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; }
protected:
virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE {
@@ -228,6 +229,9 @@ public:
const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(maker) {
}
+ // For serialization. This will never be called.
+ Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; }
+
protected:
virtual void begin(const SkIRect& uvBounds, SkPath*) const SK_OVERRIDE {
const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds);
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 0a6365c335..1e1ce07631 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -2035,7 +2035,9 @@ public:
};
SK_TO_STRING_OVERRIDE()
- SK_DECLARE_NOT_FLATTENABLE_PROCS(SkTriColorShader)
+
+ // For serialization. This will never be called.
+ Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; }
protected:
virtual Context* onCreateContext(const ContextRec& rec, void* storage) const SK_OVERRIDE {
diff --git a/tests/LayerRasterizerTest.cpp b/tests/LayerRasterizerTest.cpp
index 4b236acd52..b4edc14adc 100644
--- a/tests/LayerRasterizerTest.cpp
+++ b/tests/LayerRasterizerTest.cpp
@@ -33,7 +33,7 @@ public:
static int GetCount() { return gCount; }
- SK_DECLARE_NOT_FLATTENABLE_PROCS(DummyRasterizer)
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyRasterizer);
private:
static int gCount;
@@ -43,6 +43,10 @@ private:
int DummyRasterizer::gCount;
+SkFlattenable* DummyRasterizer::CreateProc(SkReadBuffer&) {
+ return SkNEW(DummyRasterizer);
+}
+
// Check to make sure that the SkPaint in the layer has its destructor called.
DEF_TEST(LayerRasterizer_destructor, reporter) {
{
diff --git a/tests/QuickRejectTest.cpp b/tests/QuickRejectTest.cpp
index 8f4357e0b0..77bcd3c9b1 100644
--- a/tests/QuickRejectTest.cpp
+++ b/tests/QuickRejectTest.cpp
@@ -28,6 +28,8 @@ public:
}
#endif
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestLooper);
+
private:
class TestDrawLooperContext : public SkDrawLooper::Context {
public:
@@ -45,10 +47,10 @@ private:
private:
bool fOnce;
};
-
- SK_DECLARE_UNFLATTENABLE_OBJECT()
};
+SkFlattenable* TestLooper::CreateProc(SkReadBuffer&) { return SkNEW(TestLooper); }
+
static void test_drawBitmap(skiatest::Reporter* reporter) {
SkBitmap src;
src.allocN32Pixels(10, 10);