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

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

Issue 1744103002: 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
2 /* 1 /*
3 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 8
10 #ifndef SkReader32_DEFINED 9 #ifndef SkReader32_DEFINED
11 #define SkReader32_DEFINED 10 #define SkReader32_DEFINED
12 11
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
138 private: 146 private:
139 template <typename T> bool readObjectFromMemory(T* obj) { 147 template <typename T> bool readObjectFromMemory(T* obj) {
140 size_t size = obj->readFromMemory(this->peek(), this->available()); 148 size_t size = obj->readFromMemory(this->peek(), this->available());
141 // If readFromMemory() fails (which means that available() was too small ), it returns 0 149 // If readFromMemory() fails (which means that available() was too small ), it returns 0
142 bool success = (size > 0) && (size <= this->available()) && (SkAlign4(si ze) == size); 150 bool success = (size > 0) && (size <= this->available()) && (SkAlign4(si ze) == size);
143 // In case of failure, we want to skip to the end 151 // In case of failure, we want to skip to the end
144 (void)this->skip(success ? size : this->available()); 152 (void)this->skip(success ? size : this->available());
145 return success; 153 return success;
146 } 154 }
147 155
148 // these are always 4-byte aligned 156 // these are always 4-byte aligned
149 const char* fCurr; // current position within buffer 157 const char* fCurr; // current position within buffer
150 const char* fStop; // end of buffer 158 const char* fStop; // end of buffer
151 const char* fBase; // beginning of buffer 159 const char* fBase; // beginning of buffer
152 160
153 #ifdef SK_DEBUG 161 #ifdef SK_DEBUG
154 static bool ptr_align_4(const void* ptr) { 162 static bool ptr_align_4(const void* ptr) {
155 return (((const char*)ptr - (const char*)nullptr) & 3) == 0; 163 return (((const char*)ptr - (const char*)nullptr) & 3) == 0;
156 } 164 }
157 #endif 165 #endif
158 }; 166 };
159 167
160 #endif 168 #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