aboutsummaryrefslogtreecommitdiffstats
path: root/include/core/SkFlattenable.h
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-05-16 13:07:43 -0400
committerDerek Sollenberger <djsollen@google.com>2011-05-17 07:52:26 -0400
commit35e2e62b55598210f6999fc2ea26ff8f41446ffe (patch)
tree4fca2ca7d02d58e56d9b146b770ecb1e8da8d8af /include/core/SkFlattenable.h
parentf173507281c41ccde5f0ef849cd720639d7e25d0 (diff)
downloadexternal_skia-35e2e62b55598210f6999fc2ea26ff8f41446ffe.zip
external_skia-35e2e62b55598210f6999fc2ea26ff8f41446ffe.tar.gz
external_skia-35e2e62b55598210f6999fc2ea26ff8f41446ffe.tar.bz2
Skia Merge (revision 1327)
Change-Id: I46f41274d07a3d7bac4728f8841c7f5e89dc9181
Diffstat (limited to 'include/core/SkFlattenable.h')
-rw-r--r--include/core/SkFlattenable.h74
1 files changed, 29 insertions, 45 deletions
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index ad4062f..03bcab8 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -70,6 +70,16 @@ protected:
SkFlattenable(SkFlattenableReadBuffer&) {}
};
+// helpers for matrix and region
+
+class SkMatrix;
+extern void SkReadMatrix(SkReader32*, SkMatrix*);
+extern void SkWriteMatrix(SkWriter32*, const SkMatrix&);
+
+class SkRegion;
+extern void SkReadRegion(SkReader32*, SkRegion*);
+extern void SkWriteRegion(SkWriter32*, const SkRegion&);
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -118,48 +128,22 @@ private:
#include "SkPtrRecorder.h"
-class SkRefCntRecorder : public SkPtrRecorder {
+/**
+ * Subclass of SkTPtrSet specialed to call ref() and unref() when the
+ * base class's incPtr() and decPtr() are called. This makes it a valid owner
+ * of each ptr, which is released when the set is reset or destroyed.
+ */
+class SkRefCntSet : public SkTPtrSet<SkRefCnt*> {
public:
- virtual ~SkRefCntRecorder();
-
- /** Add a refcnt object to the set and ref it if not already present,
- or if it is already present, do nothing. Either way, returns 0 if obj
- is null, or a base-1 index if obj is not null.
- */
- uint32_t record(SkRefCnt* ref) {
- return this->recordPtr(ref);
- }
-
- // This does not change the owner counts on the objects
- void get(SkRefCnt* array[]) const {
- this->getPtrs((void**)array);
- }
-
+ virtual ~SkRefCntSet();
+
protected:
// overrides
virtual void incPtr(void*);
virtual void decPtr(void*);
-
-private:
- typedef SkPtrRecorder INHERITED;
};
-class SkFactoryRecorder : public SkPtrRecorder {
-public:
- /** Add a factory to the set. If it is null return 0, otherwise return a
- base-1 index for the factory.
- */
- uint32_t record(SkFlattenable::Factory fact) {
- return this->recordPtr((void*)fact);
- }
-
- void get(SkFlattenable::Factory array[]) const {
- this->getPtrs((void**)array);
- }
-
-private:
- typedef SkPtrRecorder INHERITED;
-};
+class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> {};
class SkFlattenableWriteBuffer : public SkWriter32 {
public:
@@ -171,14 +155,14 @@ public:
void writeFunctionPtr(void*);
void writeFlattenable(SkFlattenable* flattenable);
- SkRefCntRecorder* getTypefaceRecorder() const { return fTFRecorder; }
- SkRefCntRecorder* setTypefaceRecorder(SkRefCntRecorder*);
+ SkRefCntSet* getTypefaceRecorder() const { return fTFSet; }
+ SkRefCntSet* setTypefaceRecorder(SkRefCntSet*);
- SkRefCntRecorder* getRefCntRecorder() const { return fRCRecorder; }
- SkRefCntRecorder* setRefCntRecorder(SkRefCntRecorder*);
+ SkRefCntSet* getRefCntRecorder() const { return fRCSet; }
+ SkRefCntSet* setRefCntRecorder(SkRefCntSet*);
- SkFactoryRecorder* getFactoryRecorder() const { return fFactoryRecorder; }
- SkFactoryRecorder* setFactoryRecorder(SkFactoryRecorder*);
+ SkFactorySet* getFactoryRecorder() const { return fFactorySet; }
+ SkFactorySet* setFactoryRecorder(SkFactorySet*);
enum Flags {
kCrossProcess_Flag = 0x01
@@ -195,10 +179,10 @@ public:
bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
private:
- Flags fFlags;
- SkRefCntRecorder* fTFRecorder;
- SkRefCntRecorder* fRCRecorder;
- SkFactoryRecorder* fFactoryRecorder;
+ Flags fFlags;
+ SkRefCntSet* fTFSet;
+ SkRefCntSet* fRCSet;
+ SkFactorySet* fFactorySet;
typedef SkWriter32 INHERITED;
};