diff options
author | 2012-06-08 18:30:46 +0000 | |
---|---|---|
committer | 2012-06-08 18:30:46 +0000 | |
commit | 94e75ee46a569cbcdf61fb7f04ee3a69d3ca0896 (patch) | |
tree | 69459ed6333c977be86dd36e503593a44a067e94 /include/core | |
parent | 97caebc7462c202ab0ec5cce4eb26a616930813e (diff) |
Rename the existing flatten(void*) methods.
This change avoids naminc confusion with the SkFlattenable flatten methods and
also changes SkPath to use the void* model instead of taking a SkReader32.
Review URL: https://codereview.appspot.com/6299062
git-svn-id: http://skia.googlecode.com/svn/trunk@4215 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkMatrix.h | 6 | ||||
-rw-r--r-- | include/core/SkOrderedReadBuffer.h | 3 | ||||
-rw-r--r-- | include/core/SkOrderedWriteBuffer.h | 2 | ||||
-rw-r--r-- | include/core/SkPath.h | 12 | ||||
-rw-r--r-- | include/core/SkReader32.h | 11 | ||||
-rw-r--r-- | include/core/SkRegion.h | 4 | ||||
-rw-r--r-- | include/core/SkWriter32.h | 15 |
7 files changed, 38 insertions, 15 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index 0f148a71d2..05fd132a29 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -507,13 +507,13 @@ public: } enum { - // flatten/unflatten will never return a value larger than this + // writeTo/readFromMemory will never return a value larger than this kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t) }; // return the number of bytes written, whether or not buffer is null - uint32_t flatten(void* buffer) const; + uint32_t writeToMemory(void* buffer) const; // return the number of bytes read - uint32_t unflatten(const void* buffer); + uint32_t readFromMemory(const void* buffer); void dump() const; void toDumpString(SkString*) const; diff --git a/include/core/SkOrderedReadBuffer.h b/include/core/SkOrderedReadBuffer.h index c1dbc7e251..12b74d1cdc 100644 --- a/include/core/SkOrderedReadBuffer.h +++ b/include/core/SkOrderedReadBuffer.h @@ -40,7 +40,8 @@ public: virtual const void* skip(size_t size) { return fReader.skip(size); } virtual void readMatrix(SkMatrix* m) { fReader.readMatrix(m); } - virtual void readPath(SkPath* p) { p->unflatten(fReader); } + virtual void readPath(SkPath* p) { fReader.readPath(p); } + virtual void readPoint(SkPoint* p) { p->fX = fReader.readScalar(); p->fY = fReader.readScalar(); diff --git a/include/core/SkOrderedWriteBuffer.h b/include/core/SkOrderedWriteBuffer.h index 947877ba4e..64687197cf 100644 --- a/include/core/SkOrderedWriteBuffer.h +++ b/include/core/SkOrderedWriteBuffer.h @@ -41,7 +41,7 @@ public: virtual size_t readFromStream(SkStream* s, size_t length) { return fWriter.readFromStream(s, length); } virtual void writeMatrix(const SkMatrix& matrix) { fWriter.writeMatrix(matrix); } - virtual void writePath(const SkPath& path) { path.flatten(fWriter); }; + virtual void writePath(const SkPath& path) { fWriter.writePath(path); }; virtual void writePoint(const SkPoint& point) { fWriter.writeScalar(point.fX); fWriter.writeScalar(point.fY); diff --git a/include/core/SkPath.h b/include/core/SkPath.h index e6989f2838..8440df3f02 100644 --- a/include/core/SkPath.h +++ b/include/core/SkPath.h @@ -784,8 +784,16 @@ public: void dump(bool forceClose, const char title[] = NULL) const; void dump() const; - void flatten(SkWriter32&) const; - void unflatten(SkReader32&); + /** + * Write the region to the buffer, and return the number of bytes written. + * If buffer is NULL, it still returns the number of bytes. + */ + uint32_t writeToMemory(void* buffer) const; + /** + * Initialized the region from the buffer, returning the number + * of bytes actually read. + */ + uint32_t readFromMemory(const void* buffer); #ifdef SK_BUILD_FOR_ANDROID uint32_t getGenerationID() const; diff --git a/include/core/SkReader32.h b/include/core/SkReader32.h index 98385e430a..9e25e84a55 100644 --- a/include/core/SkReader32.h +++ b/include/core/SkReader32.h @@ -11,6 +11,7 @@ #define SkReader32_DEFINED #include "SkMatrix.h" +#include "SkPath.h" #include "SkRegion.h" #include "SkScalar.h" @@ -92,14 +93,20 @@ public: int32_t readS32() { return this->readInt(); } uint32_t readU32() { return this->readInt(); } + void readPath(SkPath* path) { + size_t size = path->readFromMemory(this->peek()); + SkASSERT(SkAlign4(size) == size); + (void)this->skip(size); + } + void readMatrix(SkMatrix* matrix) { - size_t size = matrix->unflatten(this->peek()); + size_t size = matrix->readFromMemory(this->peek()); SkASSERT(SkAlign4(size) == size); (void)this->skip(size); } void readRegion(SkRegion* rgn) { - size_t size = rgn->unflatten(this->peek()); + size_t size = rgn->readFromMemory(this->peek()); SkASSERT(SkAlign4(size) == size); (void)this->skip(size); } diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h index e83e19782f..2aab42385b 100644 --- a/include/core/SkRegion.h +++ b/include/core/SkRegion.h @@ -351,13 +351,13 @@ public: * Write the region to the buffer, and return the number of bytes written. * If buffer is NULL, it still returns the number of bytes. */ - uint32_t flatten(void* buffer) const; + uint32_t writeToMemory(void* buffer) const; /** * Initialized the region from the buffer, returning the number * of bytes actually read. */ - uint32_t unflatten(const void* buffer); + uint32_t readFromMemory(const void* buffer); /** * Returns a reference to a global empty region. Just a convenience for diff --git a/include/core/SkWriter32.h b/include/core/SkWriter32.h index c140850b9c..9abaa467d2 100644 --- a/include/core/SkWriter32.h +++ b/include/core/SkWriter32.h @@ -13,6 +13,7 @@ #include "SkTypes.h" #include "SkScalar.h" +#include "SkPath.h" #include "SkPoint.h" #include "SkRect.h" #include "SkMatrix.h" @@ -88,16 +89,22 @@ public: *(SkRect*)this->reserve(sizeof(rect)) = rect; } + void writePath(const SkPath& path) { + size_t size = path.writeToMemory(NULL); + SkASSERT(SkAlign4(size) == size); + path.writeToMemory(this->reserve(size)); + } + void writeMatrix(const SkMatrix& matrix) { - size_t size = matrix.flatten(NULL); + size_t size = matrix.writeToMemory(NULL); SkASSERT(SkAlign4(size) == size); - matrix.flatten(this->reserve(size)); + matrix.writeToMemory(this->reserve(size)); } void writeRegion(const SkRegion& rgn) { - size_t size = rgn.flatten(NULL); + size_t size = rgn.writeToMemory(NULL); SkASSERT(SkAlign4(size) == size); - rgn.flatten(this->reserve(size)); + rgn.writeToMemory(this->reserve(size)); } // write count bytes (must be a multiple of 4) |