diff options
| author | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-26 17:57:35 +0000 |
|---|---|---|
| committer | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-26 17:57:35 +0000 |
| commit | ba28d03e94dc221d6a803bf2a84a420b9159255c (patch) | |
| tree | 1130187c2342abd92cc0782e724ad57fc551872a /samplecode/SampleText.cpp | |
| parent | d43b0a87f85ca26ec771e094c62df33b0537b563 (diff) | |
Create macro for registering classes for deserialization
Review URL: https://codereview.appspot.com/5909063
git-svn-id: http://skia.googlecode.com/svn/trunk@3494 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleText.cpp')
| -rw-r--r-- | samplecode/SampleText.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp index 6a0eba8f97..7ce1abe65c 100644 --- a/samplecode/SampleText.cpp +++ b/samplecode/SampleText.cpp @@ -54,12 +54,10 @@ public: // if (c < min) c = min; return c; } - virtual Factory getFactory() { return Create; } + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ReduceNoise) + private: ReduceNoise(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {} - static SkFlattenable* Create(SkFlattenableReadBuffer& rb) { - return new ReduceNoise(rb); - } }; class Darken : public SkKernel33ProcMaskFilter { @@ -78,12 +76,10 @@ public: SkASSERT(f >= 0 && f <= 1); return (int)(f * 255); } - virtual Factory getFactory() { return Create; } + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Darken) + private: Darken(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {} - static SkFlattenable* Create(SkFlattenableReadBuffer& rb) { - return new Darken(rb); - } }; static SkMaskFilter* makemf() { return new Darken(0x30); } @@ -136,11 +132,11 @@ public: typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); // overrides for SkFlattenable - virtual Factory getFactory() { return Create; } virtual void flatten(SkFlattenableWriteBuffer& b) { // this->INHERITED::flatten(b); How can we know if this is legal???? b.write32(SkScalarToFixed(fExp)); } + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPowerMode) private: SkScalar fExp; // user's value @@ -151,9 +147,6 @@ private: // read the exponent this->init(SkFixedToScalar(b.readS32())); } - static SkFlattenable* Create(SkFlattenableReadBuffer& b) { - return SkNEW_ARGS(SkPowerMode, (b)); - } typedef SkXfermode INHERITED; }; |
