| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkReader32_DEFINED | 10 #ifndef SkReader32_DEFINED |
| 11 #define SkReader32_DEFINED | 11 #define SkReader32_DEFINED |
| 12 | 12 |
| 13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
| 14 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkRegion.h" | 15 #include "SkRegion.h" |
| 16 #include "SkRRect.h" | 16 #include "SkRRect.h" |
| 17 #include "SkScalar.h" | 17 #include "SkScalar.h" |
| 18 #include "SkPatch.h" |
| 18 | 19 |
| 19 class SkString; | 20 class SkString; |
| 20 | 21 |
| 21 class SkReader32 : SkNoncopyable { | 22 class SkReader32 : SkNoncopyable { |
| 22 public: | 23 public: |
| 23 SkReader32() : fCurr(NULL), fStop(NULL), fBase(NULL) {} | 24 SkReader32() : fCurr(NULL), fStop(NULL), fBase(NULL) {} |
| 24 SkReader32(const void* data, size_t size) { | 25 SkReader32(const void* data, size_t size) { |
| 25 this->setMemory(data, size); | 26 this->setMemory(data, size); |
| 26 } | 27 } |
| 27 | 28 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 SkASSERT(ptr_align_4(fCurr)); | 99 SkASSERT(ptr_align_4(fCurr)); |
| 99 memcpy(dst, fCurr, size); | 100 memcpy(dst, fCurr, size); |
| 100 fCurr += SkAlign4(size); | 101 fCurr += SkAlign4(size); |
| 101 SkASSERT(fCurr <= fStop); | 102 SkASSERT(fCurr <= fStop); |
| 102 } | 103 } |
| 103 | 104 |
| 104 uint8_t readU8() { return (uint8_t)this->readInt(); } | 105 uint8_t readU8() { return (uint8_t)this->readInt(); } |
| 105 uint16_t readU16() { return (uint16_t)this->readInt(); } | 106 uint16_t readU16() { return (uint16_t)this->readInt(); } |
| 106 int32_t readS32() { return this->readInt(); } | 107 int32_t readS32() { return this->readInt(); } |
| 107 uint32_t readU32() { return this->readInt(); } | 108 uint32_t readU32() { return this->readInt(); } |
| 109 |
| 110 bool readPatch(SkPatch* patch) { |
| 111 return this->readObjectFromMemory(patch); |
| 112 } |
| 108 | 113 |
| 109 bool readPath(SkPath* path) { | 114 bool readPath(SkPath* path) { |
| 110 return readObjectFromMemory(path); | 115 return this->readObjectFromMemory(path); |
| 111 } | 116 } |
| 112 | 117 |
| 113 bool readMatrix(SkMatrix* matrix) { | 118 bool readMatrix(SkMatrix* matrix) { |
| 114 return readObjectFromMemory(matrix); | 119 return this->readObjectFromMemory(matrix); |
| 115 } | 120 } |
| 116 | 121 |
| 117 bool readRRect(SkRRect* rrect) { | 122 bool readRRect(SkRRect* rrect) { |
| 118 return readObjectFromMemory(rrect); | 123 return this->readObjectFromMemory(rrect); |
| 119 } | 124 } |
| 120 | 125 |
| 121 bool readRegion(SkRegion* rgn) { | 126 bool readRegion(SkRegion* rgn) { |
| 122 return readObjectFromMemory(rgn); | 127 return this->readObjectFromMemory(rgn); |
| 123 } | 128 } |
| 124 | 129 |
| 125 /** | 130 /** |
| 126 * Read the length of a string (written by SkWriter32::writeString) into | 131 * Read the length of a string (written by SkWriter32::writeString) into |
| 127 * len (if len is not NULL) and return the null-ternimated address of the | 132 * len (if len is not NULL) and return the null-ternimated address of the |
| 128 * string within the reader's buffer. | 133 * string within the reader's buffer. |
| 129 */ | 134 */ |
| 130 const char* readString(size_t* len = NULL); | 135 const char* readString(size_t* len = NULL); |
| 131 | 136 |
| 132 /** | 137 /** |
| (...skipping 18 matching lines...) Expand all Loading... |
| 151 const char* fBase; // beginning of buffer | 156 const char* fBase; // beginning of buffer |
| 152 | 157 |
| 153 #ifdef SK_DEBUG | 158 #ifdef SK_DEBUG |
| 154 static bool ptr_align_4(const void* ptr) { | 159 static bool ptr_align_4(const void* ptr) { |
| 155 return (((const char*)ptr - (const char*)NULL) & 3) == 0; | 160 return (((const char*)ptr - (const char*)NULL) & 3) == 0; |
| 156 } | 161 } |
| 157 #endif | 162 #endif |
| 158 }; | 163 }; |
| 159 | 164 |
| 160 #endif | 165 #endif |
| OLD | NEW |