aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-04 18:06:12 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-04 18:06:12 +0000
commiteb221268ab1067af7c48e04a75147d4bcca87191 (patch)
treea561113063c1019ef55fb03520ceac80ff8db1aa /include
parent305f78e8c18a26b7ead11758d6a4fa0519932cca (diff)
Revert r12114 due to https://code.google.com/p/skia/issues/detail?id=1794 ('Assertion failures on various buildbots as of r12114')
git-svn-id: http://skia.googlecode.com/svn/trunk@12115 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/core/SkMatrix.h13
-rw-r--r--include/core/SkPath.h15
-rw-r--r--include/core/SkRRect.h16
-rw-r--r--include/core/SkReader32.h32
-rw-r--r--include/core/SkRegion.h13
5 files changed, 34 insertions, 55 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index dad5ff92f5..b6856d103c 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -559,16 +559,9 @@ public:
kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t)
};
// return the number of bytes written, whether or not buffer is null
- size_t writeToMemory(void* buffer) const;
- /**
- * Reads data from the buffer parameter
- *
- * @param buffer Memory to read from
- * @param length Amount of memory available in the buffer
- * @return number of bytes read (must be a multiple of 4) or
- * 0 if there was not enough memory available
- */
- size_t readFromMemory(const void* buffer, size_t length);
+ uint32_t writeToMemory(void* buffer) const;
+ // return the number of bytes read
+ uint32_t readFromMemory(const void* buffer);
SkDEVCODE(void dump() const;)
SkDEVCODE(void toString(SkString*) const;)
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 2b111fe505..785eb7793f 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -899,19 +899,16 @@ public:
void dump() const;
/**
- * Write the path to the buffer, and return the number of bytes written.
+ * Write the region to the buffer, and return the number of bytes written.
* If buffer is NULL, it still returns the number of bytes.
*/
- size_t writeToMemory(void* buffer) const;
+ uint32_t writeToMemory(void* buffer) const;
+
/**
- * Initializes the path from the buffer
- *
- * @param buffer Memory to read from
- * @param length Amount of memory available in the buffer
- * @return number of bytes read (must be a multiple of 4) or
- * 0 if there was not enough memory available
+ * Initialized the region from the buffer, returning the number
+ * of bytes actually read.
*/
- size_t readFromMemory(const void* buffer, size_t length);
+ uint32_t readFromMemory(const void* buffer);
/** Returns a non-zero, globally unique value corresponding to the set of verbs
and points in the path (but not the fill type [except on Android skbug.com/1762]).
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 3c6386f1c6..402e6c6c4b 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -244,20 +244,14 @@ public:
* write kSizeInMemory bytes, and that value is guaranteed to always be
* a multiple of 4. Return kSizeInMemory.
*/
- size_t writeToMemory(void* buffer) const;
+ uint32_t writeToMemory(void* buffer) const;
/**
- * Reads the rrect from the specified buffer
- *
- * If the specified buffer is large enough, this will read kSizeInMemory bytes,
- * and that value is guaranteed to always be a multiple of 4.
- *
- * @param buffer Memory to read from
- * @param length Amount of memory available in the buffer
- * @return number of bytes read (must be a multiple of 4) or
- * 0 if there was not enough memory available
+ * Read the rrect from the specified buffer. This is guaranteed to always
+ * read kSizeInMemory bytes, and that value is guaranteed to always be
+ * a multiple of 4. Return kSizeInMemory.
*/
- size_t readFromMemory(const void* buffer, size_t length);
+ uint32_t readFromMemory(const void* buffer);
private:
SkRect fRect;
diff --git a/include/core/SkReader32.h b/include/core/SkReader32.h
index 40ae12ce23..7a8d22a80c 100644
--- a/include/core/SkReader32.h
+++ b/include/core/SkReader32.h
@@ -106,20 +106,27 @@ public:
int32_t readS32() { return this->readInt(); }
uint32_t readU32() { return this->readInt(); }
- bool readPath(SkPath* path) {
- return readObjectFromMemory(path);
+ void readPath(SkPath* path) {
+ size_t size = path->readFromMemory(this->peek());
+ SkASSERT(SkAlign4(size) == size);
+ (void)this->skip(size);
}
- bool readMatrix(SkMatrix* matrix) {
- return readObjectFromMemory(matrix);
+ void readMatrix(SkMatrix* matrix) {
+ size_t size = matrix->readFromMemory(this->peek());
+ SkASSERT(SkAlign4(size) == size);
+ (void)this->skip(size);
}
- bool readRRect(SkRRect* rrect) {
- return readObjectFromMemory(rrect);
+ SkRRect* readRRect(SkRRect* rrect) {
+ rrect->readFromMemory(this->skip(SkRRect::kSizeInMemory));
+ return rrect;
}
- bool readRegion(SkRegion* rgn) {
- return readObjectFromMemory(rgn);
+ void readRegion(SkRegion* rgn) {
+ size_t size = rgn->readFromMemory(this->peek());
+ SkASSERT(SkAlign4(size) == size);
+ (void)this->skip(size);
}
/**
@@ -136,15 +143,6 @@ public:
size_t readIntoString(SkString* copy);
private:
- template <typename T> bool readObjectFromMemory(T* obj) {
- size_t size = obj->readFromMemory(this->peek(), this->available());
- // If readFromMemory() fails (which means that available() was too small), it returns 0
- bool success = (size > 0) && (size <= this->available()) && (SkAlign4(size) == size);
- // In case of failure, we want to skip to the end
- (void)this->skip(success ? size : this->available());
- return success;
- }
-
// these are always 4-byte aligned
const char* fCurr; // current position within buffer
const char* fStop; // end of buffer
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index c9aa8daf88..a088d54620 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -361,16 +361,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.
*/
- size_t writeToMemory(void* buffer) const;
+ uint32_t writeToMemory(void* buffer) const;
+
/**
- * Initializes the region from the buffer
- *
- * @param buffer Memory to read from
- * @param length Amount of memory available in the buffer
- * @return number of bytes read (must be a multiple of 4) or
- * 0 if there was not enough memory available
+ * Initialized the region from the buffer, returning the number
+ * of bytes actually read.
*/
- size_t readFromMemory(const void* buffer, size_t length);
+ uint32_t readFromMemory(const void* buffer);
/**
* Returns a reference to a global empty region. Just a convenience for