aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkStream.h
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2016-10-07 15:50:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-18 15:06:24 +0000
commit255ab8d9a55d68b7405280dae6b586d17e23cf71 (patch)
tree06625e0edb3314d6dff3d1cb2bf13d116b6cba3f /include/core/SkStream.h
parent8f8d481b44fc486e7190c6e2db8077226d53c969 (diff)
Make SkStream readers report failure.
This also fixes an issue noticed while making this change where SkFontDescriptor improperly round trips negative axis values. Change-Id: Iacc5929a185659dcacc18c802c4908e4f34c6899 Reviewed-on: https://skia-review.googlesource.com/128341 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/core/SkStream.h')
-rw-r--r--include/core/SkStream.h43
1 files changed, 24 insertions, 19 deletions
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 75fef125d9..2d9f9db120 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -83,17 +83,22 @@ public:
*/
virtual bool isAtEnd() const = 0;
- int8_t readS8();
- int16_t readS16();
- int32_t readS32();
-
- uint8_t readU8() { return (uint8_t)this->readS8(); }
- uint16_t readU16() { return (uint16_t)this->readS16(); }
- uint32_t readU32() { return (uint32_t)this->readS32(); }
-
- bool readBool() { return this->readU8() != 0; }
- SkScalar readScalar();
- size_t readPackedUInt();
+ bool SK_WARN_UNUSED_RESULT readS8(int8_t*);
+ bool SK_WARN_UNUSED_RESULT readS16(int16_t*);
+ bool SK_WARN_UNUSED_RESULT readS32(int32_t*);
+
+ bool SK_WARN_UNUSED_RESULT readU8(uint8_t* i) { return this->readS8((int8_t*)i); }
+ bool SK_WARN_UNUSED_RESULT readU16(uint16_t* i) { return this->readS16((int16_t*)i); }
+ bool SK_WARN_UNUSED_RESULT readU32(uint32_t* i) { return this->readS32((int32_t*)i); }
+
+ bool SK_WARN_UNUSED_RESULT readBool(bool* b) {
+ uint8_t i;
+ if (!this->readU8(&i)) { return false; }
+ *b = (i != 0);
+ return true;
+ }
+ bool SK_WARN_UNUSED_RESULT readScalar(SkScalar*);
+ bool SK_WARN_UNUSED_RESULT readPackedUInt(size_t*);
//SkStreamRewindable
/** Rewinds to the beginning of the stream. Returns true if the stream is known
@@ -247,16 +252,16 @@ public:
bool newline() { return this->write("\n", strlen("\n")); }
- bool writeDecAsText(int32_t);
- bool writeBigDecAsText(int64_t, int minDigits = 0);
- bool writeHexAsText(uint32_t, int minDigits = 0);
- bool writeScalarAsText(SkScalar);
+ bool writeDecAsText(int32_t);
+ bool writeBigDecAsText(int64_t, int minDigits = 0);
+ bool writeHexAsText(uint32_t, int minDigits = 0);
+ bool writeScalarAsText(SkScalar);
- bool writeBool(bool v) { return this->write8(v); }
- bool writeScalar(SkScalar);
- bool writePackedUInt(size_t);
+ bool writeBool(bool v) { return this->write8(v); }
+ bool writeScalar(SkScalar);
+ bool writePackedUInt(size_t);
- bool writeStream(SkStream* input, size_t length);
+ bool writeStream(SkStream* input, size_t length);
/**
* This returns the number of bytes in the stream required to store