aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-26 17:57:35 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-26 17:57:35 +0000
commitba28d03e94dc221d6a803bf2a84a420b9159255c (patch)
tree1130187c2342abd92cc0782e724ad57fc551872a /src/core
parentd43b0a87f85ca26ec771e094c62df33b0537b563 (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 'src/core')
-rw-r--r--src/core/SkBitmapProcShader.h6
-rw-r--r--src/core/SkBlitter.cpp10
-rw-r--r--src/core/SkDraw.cpp7
-rw-r--r--src/core/SkPathEffect.cpp8
-rw-r--r--src/core/SkShader.cpp10
-rw-r--r--src/core/SkShape.cpp8
-rw-r--r--src/core/SkXfermode.cpp25
7 files changed, 10 insertions, 64 deletions
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index cd702793d1..6140259e6e 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -30,17 +30,13 @@ public:
static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkBitmapProcShader, (buffer));
- }
-
// override from flattenable
virtual bool toDumpString(SkString* str) const;
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
protected:
SkBitmapProcShader(SkFlattenableReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer& );
- virtual Factory getFactory() { return CreateProc; }
SkBitmap fRawBitmap; // experimental for RLE encoding
SkBitmapProcState fState;
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index df25b7c557..2ce0197d24 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -656,6 +656,8 @@ public:
this->INHERITED::endSession();
}
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
+
protected:
Sk3DShader(SkFlattenableReadBuffer& buffer) :
INHERITED(buffer) {
@@ -670,15 +672,7 @@ protected:
buffer.write32(fPMColor);
}
- virtual Factory getFactory() {
- return CreateProc;
- }
-
private:
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(Sk3DShader, (buffer));
- }
-
SkShader* fProxy;
SkPMColor fPMColor;
const SkMask* fMask;
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index c118d1e757..74d10b6891 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -2212,18 +2212,15 @@ public:
virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader)
+
protected:
SkTriColorShader(SkFlattenableReadBuffer& buffer) : SkShader(buffer) {}
- virtual Factory getFactory() { return CreateProc; }
-
private:
SkMatrix fDstToUnit;
SkPMColor fColors[3];
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkTriColorShader, (buffer));
- }
typedef SkShader INHERITED;
};
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index 852c25f9da..0c0143da46 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -108,14 +108,6 @@ bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src,
return true;
}
-SkFlattenable::Factory SkStrokePathEffect::getFactory() {
- return CreateProc;
-}
-
-SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkStrokePathEffect, (buffer));
-}
-
void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.writeScalar(fWidth);
buffer.writeScalar(fMiter);
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 618b8d2745..a3b3b6a216 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -247,14 +247,6 @@ void SkColorShader::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.write32(fColor);
}
-SkFlattenable* SkColorShader::CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkColorShader, (buffer));
-}
-
-SkFlattenable::Factory SkColorShader::getFactory() {
- return CreateProc;
-}
-
uint32_t SkColorShader::getFlags() {
return fFlags;
}
@@ -359,8 +351,6 @@ void SkEmptyShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
SkDEBUGFAIL("should never get called, since setContext() returned false");
}
-SkFlattenable::Factory SkEmptyShader::getFactory() { return NULL; }
-
void SkEmptyShader::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
}
diff --git a/src/core/SkShape.cpp b/src/core/SkShape.cpp
index 339601af5f..0c4907e0e0 100644
--- a/src/core/SkShape.cpp
+++ b/src/core/SkShape.cpp
@@ -60,14 +60,6 @@ SkShape::SkShape(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
inc_shape(this);
}
-SkFlattenable* SkShape::CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkShape, (buffer));
-}
-
-SkFlattenable::Factory SkShape::getFactory() {
- return CreateProc;
-}
-
void SkShape::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
}
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index 952e0f2f20..bcb721d35f 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -729,15 +729,12 @@ public:
return true;
}
- virtual Factory getFactory() { return CreateProc; }
virtual void flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
buffer.write32(fMode);
}
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkProcCoeffXfermode, (buffer));
- }
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
protected:
SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer)
@@ -768,11 +765,8 @@ public:
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) SK_OVERRIDE;
virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) SK_OVERRIDE;
- virtual Factory getFactory() SK_OVERRIDE { return CreateProc; }
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkClearXfermode, (buffer));
- }
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode)
private:
SkClearXfermode(SkFlattenableReadBuffer& buffer)
@@ -825,11 +819,8 @@ public:
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) SK_OVERRIDE;
virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) SK_OVERRIDE;
- virtual Factory getFactory() SK_OVERRIDE { return CreateProc; }
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkSrcXfermode, (buffer));
- }
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode)
private:
SkSrcXfermode(SkFlattenableReadBuffer& buffer)
@@ -887,11 +878,8 @@ public:
SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) SK_OVERRIDE;
- virtual Factory getFactory() SK_OVERRIDE { return CreateProc; }
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkDstInXfermode, (buffer));
- }
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode)
private:
SkDstInXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
@@ -926,11 +914,8 @@ public:
SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) SK_OVERRIDE;
- virtual Factory getFactory() SK_OVERRIDE { return CreateProc; }
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkDstOutXfermode, (buffer));
- }
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode)
private:
SkDstOutXfermode(SkFlattenableReadBuffer& buffer)