aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-28 20:47:01 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-28 20:47:01 +0000
commit5370cd969d8f3957e4306068e6195ac1bca3d6cd (patch)
treecf1639cfb2dcc013e992f75b86056455bbe8ad18 /include/core
parenta728e35edcffd99216e3965a4b908ad0df7f69c2 (diff)
Consolidate PixelRef flattables with the standard impl
The flatten method on these functions can no longer be const as SkFlattenables declaration is not const and would result in the const methods only being called when the reference to the object was const. Review URL: https://codereview.appspot.com/5941043 git-svn-id: http://skia.googlecode.com/svn/trunk@3533 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkMallocPixelRef.h12
-rw-r--r--include/core/SkPixelRef.h46
2 files changed, 7 insertions, 51 deletions
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index 903bad334d..cdfec75873 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -29,15 +29,9 @@ public:
void* getAddr() const { return fStorage; }
// overrides from SkPixelRef
- virtual void flatten(SkFlattenableWriteBuffer&) const;
- virtual Factory getFactory() const {
- return Create;
- }
- static SkPixelRef* Create(SkFlattenableReadBuffer& buffer) {
- return SkNEW_ARGS(SkMallocPixelRef, (buffer));
- }
-
- SK_DECLARE_PIXEL_REF_REGISTRAR()
+ virtual void flatten(SkFlattenableWriteBuffer&);
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef)
+
protected:
// overrides from SkPixelRef
virtual void* onLockPixels(SkColorTable**);
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index d5f6ab2b6e..d84c285877 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -13,35 +13,15 @@
#include "SkBitmap.h"
#include "SkRefCnt.h"
#include "SkString.h"
+#include "SkFlattenable.h"
class SkColorTable;
struct SkIRect;
class SkMutex;
-class SkFlattenableReadBuffer;
-class SkFlattenableWriteBuffer;
// this is an opaque class, not interpreted by skia
class SkGpuTexture;
-#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-
-#define SK_DECLARE_PIXEL_REF_REGISTRAR()
-
-#define SK_DEFINE_PIXEL_REF_REGISTRAR(pixelRef) \
- static SkPixelRef::Registrar g##pixelRef##Reg(#pixelRef, \
- pixelRef::Create);
-
-#else
-
-#define SK_DECLARE_PIXEL_REF_REGISTRAR() static void Init();
-
-#define SK_DEFINE_PIXEL_REF_REGISTRAR(pixelRef) \
- void pixelRef::Init() { \
- SkPixelRef::Registrar(#pixelRef, Create); \
- }
-
-#endif
-
/** \class SkPixelRef
This class is the smart container for pixel memory, and is used with
@@ -50,7 +30,7 @@ class SkGpuTexture;
This class can be shared/accessed between multiple threads.
*/
-class SK_API SkPixelRef : public SkRefCnt {
+class SK_API SkPixelRef : public SkFlattenable {
public:
explicit SkPixelRef(SkBaseMutex* mutex = NULL);
@@ -143,11 +123,7 @@ public:
virtual SkPixelRef* deepCopy(SkBitmap::Config config) { return NULL; }
// serialization
-
- typedef SkPixelRef* (*Factory)(SkFlattenableReadBuffer&);
-
- virtual Factory getFactory() const { return NULL; }
- virtual void flatten(SkFlattenableWriteBuffer&) const;
+ virtual void flatten(SkFlattenableWriteBuffer&);
#ifdef SK_BUILD_FOR_ANDROID
/**
@@ -165,17 +141,6 @@ public:
virtual void globalUnref();
#endif
- static Factory NameToFactory(const char name[]);
- static const char* FactoryToName(Factory);
- static void Register(const char name[], Factory);
-
- class Registrar {
- public:
- Registrar(const char name[], Factory factory) {
- SkPixelRef::Register(name, factory);
- }
- };
-
protected:
/** Called when the lockCount goes from 0 to 1. The caller will have already
acquire a mutex for thread safety, so this method need not do that.
@@ -206,9 +171,6 @@ protected:
SkPixelRef(SkFlattenableReadBuffer&, SkBaseMutex*);
private:
-#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
- static void InitializeFlattenables();
-#endif
SkBaseMutex* fMutex; // must remain in scope for the life of this object
void* fPixels;
@@ -222,7 +184,7 @@ private:
// can go from false to true, but never from true to false
bool fIsImmutable;
- friend class SkGraphics;
+ typedef SkFlattenable INHERITED;
};
#endif