Chromium Code Reviews| 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 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 memcpy(dst, fCurr, size); | 99 memcpy(dst, fCurr, size); |
| 100 fCurr += SkAlign4(size); | 100 fCurr += SkAlign4(size); |
| 101 SkASSERT(fCurr <= fStop); | 101 SkASSERT(fCurr <= fStop); |
| 102 } | 102 } |
| 103 | 103 |
| 104 uint8_t readU8() { return (uint8_t)this->readInt(); } | 104 uint8_t readU8() { return (uint8_t)this->readInt(); } |
| 105 uint16_t readU16() { return (uint16_t)this->readInt(); } | 105 uint16_t readU16() { return (uint16_t)this->readInt(); } |
| 106 int32_t readS32() { return this->readInt(); } | 106 int32_t readS32() { return this->readInt(); } |
| 107 uint32_t readU32() { return this->readInt(); } | 107 uint32_t readU32() { return this->readInt(); } |
| 108 | 108 |
| 109 void readPath(SkPath* path) { | 109 void readPath(SkPath* path) { |
|
reed1
2013/10/30 15:37:07
now it seems that all of these read-helpers must r
sugoi1
2013/10/30 18:07:03
Done.
| |
| 110 size_t size = path->readFromMemory(this->peek()); | 110 size_t size = path->readFromMemory(this->peek(), this->available()); |
| 111 SkASSERT(SkAlign4(size) == size); | 111 SkASSERT(SkAlign4(size) == size); |
| 112 (void)this->skip(size); | 112 (void)this->skip(size > 0 ? size : this->available()); |
|
reed1
2013/10/30 15:37:07
I think a quick comment in the code would help her
sugoi1
2013/10/30 18:07:03
Done.
| |
| 113 } | 113 } |
| 114 | 114 |
| 115 void readMatrix(SkMatrix* matrix) { | 115 void readMatrix(SkMatrix* matrix) { |
| 116 size_t size = matrix->readFromMemory(this->peek()); | 116 size_t size = matrix->readFromMemory(this->peek(), this->available()); |
| 117 SkASSERT(SkAlign4(size) == size); | 117 SkASSERT(SkAlign4(size) == size); |
| 118 (void)this->skip(size); | 118 (void)this->skip(size > 0 ? size : this->available()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 SkRRect* readRRect(SkRRect* rrect) { | 121 SkRRect* readRRect(SkRRect* rrect) { |
| 122 rrect->readFromMemory(this->skip(SkRRect::kSizeInMemory)); | 122 size_t size = rrect->readFromMemory(this->peek(), this->available()); |
| 123 SkASSERT(SkAlign4(size) == size); | |
| 124 (void)this->skip(size > 0 ? size : this->available()); | |
| 123 return rrect; | 125 return rrect; |
| 124 } | 126 } |
| 125 | 127 |
| 126 void readRegion(SkRegion* rgn) { | 128 void readRegion(SkRegion* rgn) { |
| 127 size_t size = rgn->readFromMemory(this->peek()); | 129 size_t size = rgn->readFromMemory(this->peek(), this->available()); |
| 128 SkASSERT(SkAlign4(size) == size); | 130 SkASSERT(SkAlign4(size) == size); |
| 129 (void)this->skip(size); | 131 (void)this->skip(size > 0 ? size : this->available()); |
| 130 } | 132 } |
| 131 | 133 |
| 132 /** | 134 /** |
| 133 * Read the length of a string (written by SkWriter32::writeString) into | 135 * Read the length of a string (written by SkWriter32::writeString) into |
| 134 * len (if len is not NULL) and return the null-ternimated address of the | 136 * len (if len is not NULL) and return the null-ternimated address of the |
| 135 * string within the reader's buffer. | 137 * string within the reader's buffer. |
| 136 */ | 138 */ |
| 137 const char* readString(size_t* len = NULL); | 139 const char* readString(size_t* len = NULL); |
| 138 | 140 |
| 139 /** | 141 /** |
| 140 * Read the string (written by SkWriter32::writeString) and return it in | 142 * Read the string (written by SkWriter32::writeString) and return it in |
| 141 * copy (if copy is not null). Return the length of the string. | 143 * copy (if copy is not null). Return the length of the string. |
| 142 */ | 144 */ |
| 143 size_t readIntoString(SkString* copy); | 145 size_t readIntoString(SkString* copy); |
| 144 | 146 |
| 145 private: | 147 private: |
| 146 // these are always 4-byte aligned | 148 // these are always 4-byte aligned |
| 147 const char* fCurr; // current position within buffer | 149 const char* fCurr; // current position within buffer |
| 148 const char* fStop; // end of buffer | 150 const char* fStop; // end of buffer |
| 149 const char* fBase; // beginning of buffer | 151 const char* fBase; // beginning of buffer |
| 150 | 152 |
| 151 #ifdef SK_DEBUG | 153 #ifdef SK_DEBUG |
| 152 static bool ptr_align_4(const void* ptr) { | 154 static bool ptr_align_4(const void* ptr) { |
| 153 return (((const char*)ptr - (const char*)NULL) & 3) == 0; | 155 return (((const char*)ptr - (const char*)NULL) & 3) == 0; |
| 154 } | 156 } |
| 155 #endif | 157 #endif |
| 156 }; | 158 }; |
| 157 | 159 |
| 158 #endif | 160 #endif |
| OLD | NEW |