Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/core/SkReader32.h

Issue 1761793003: Revert of move annotations to canvas virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
1 /* 2 /*
2 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
3 * 4 *
4 * 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
5 * found in the LICENSE file. 6 * found in the LICENSE file.
6 */ 7 */
7 8
8 9
9 #ifndef SkReader32_DEFINED 10 #ifndef SkReader32_DEFINED
10 #define SkReader32_DEFINED 11 #define SkReader32_DEFINED
11 12
12 #include "SkData.h"
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 18
19 class SkString; 19 class SkString;
20 20
21 class SkReader32 : SkNoncopyable { 21 class SkReader32 : SkNoncopyable {
22 public: 22 public:
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 * string within the reader's buffer. 128 * string within the reader's buffer.
129 */ 129 */
130 const char* readString(size_t* len = nullptr); 130 const char* readString(size_t* len = nullptr);
131 131
132 /** 132 /**
133 * Read the string (written by SkWriter32::writeString) and return it in 133 * Read the string (written by SkWriter32::writeString) and return it in
134 * copy (if copy is not null). Return the length of the string. 134 * copy (if copy is not null). Return the length of the string.
135 */ 135 */
136 size_t readIntoString(SkString* copy); 136 size_t readIntoString(SkString* copy);
137 137
138 SkData* readData() {
139 uint32_t byteLength = this->readU32();
140 if (0 == byteLength) {
141 return SkData::NewEmpty();
142 }
143 return SkData::NewWithCopy(this->skip(byteLength), byteLength);
144 }
145
146 private: 138 private:
147 template <typename T> bool readObjectFromMemory(T* obj) { 139 template <typename T> bool readObjectFromMemory(T* obj) {
148 size_t size = obj->readFromMemory(this->peek(), this->available()); 140 size_t size = obj->readFromMemory(this->peek(), this->available());
149 // If readFromMemory() fails (which means that available() was too small ), it returns 0 141 // If readFromMemory() fails (which means that available() was too small ), it returns 0
150 bool success = (size > 0) && (size <= this->available()) && (SkAlign4(si ze) == size); 142 bool success = (size > 0) && (size <= this->available()) && (SkAlign4(si ze) == size);
151 // In case of failure, we want to skip to the end 143 // In case of failure, we want to skip to the end
152 (void)this->skip(success ? size : this->available()); 144 (void)this->skip(success ? size : this->available());
153 return success; 145 return success;
154 } 146 }
155 147
156 // these are always 4-byte aligned 148 // these are always 4-byte aligned
157 const char* fCurr; // current position within buffer 149 const char* fCurr; // current position within buffer
158 const char* fStop; // end of buffer 150 const char* fStop; // end of buffer
159 const char* fBase; // beginning of buffer 151 const char* fBase; // beginning of buffer
160 152
161 #ifdef SK_DEBUG 153 #ifdef SK_DEBUG
162 static bool ptr_align_4(const void* ptr) { 154 static bool ptr_align_4(const void* ptr) {
163 return (((const char*)ptr - (const char*)nullptr) & 3) == 0; 155 return (((const char*)ptr - (const char*)nullptr) & 3) == 0;
164 } 156 }
165 #endif 157 #endif
166 }; 158 };
167 159
168 #endif 160 #endif
OLDNEW
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698