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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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.cpp ('k') | src/core/SkRecordDraw.h » ('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 /*
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 18
19 class SkString; 19 class SkString;
20 20
21 class SkReader32 : SkNoncopyable { 21 class SkReader32 : SkNoncopyable {
22 public: 22 public:
23 SkReader32() : fCurr(NULL), fStop(NULL), fBase(NULL) {} 23 SkReader32() : fCurr(nullptr), fStop(nullptr), fBase(nullptr) {}
24 SkReader32(const void* data, size_t size) { 24 SkReader32(const void* data, size_t size) {
25 this->setMemory(data, size); 25 this->setMemory(data, size);
26 } 26 }
27 27
28 void setMemory(const void* data, size_t size) { 28 void setMemory(const void* data, size_t size) {
29 SkASSERT(ptr_align_4(data)); 29 SkASSERT(ptr_align_4(data));
30 SkASSERT(SkAlign4(size) == size); 30 SkASSERT(SkAlign4(size) == size);
31 31
32 fBase = fCurr = (const char*)data; 32 fBase = fCurr = (const char*)data;
33 fStop = (const char*)data + size; 33 fStop = (const char*)data + size;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 SkASSERT(fCurr <= fStop); 87 SkASSERT(fCurr <= fStop);
88 return addr; 88 return addr;
89 } 89 }
90 90
91 template <typename T> const T& skipT() { 91 template <typename T> const T& skipT() {
92 SkASSERT(SkAlign4(sizeof(T)) == sizeof(T)); 92 SkASSERT(SkAlign4(sizeof(T)) == sizeof(T));
93 return *(const T*)this->skip(sizeof(T)); 93 return *(const T*)this->skip(sizeof(T));
94 } 94 }
95 95
96 void read(void* dst, size_t size) { 96 void read(void* dst, size_t size) {
97 SkASSERT(0 == size || dst != NULL); 97 SkASSERT(0 == size || dst != nullptr);
98 SkASSERT(ptr_align_4(fCurr)); 98 SkASSERT(ptr_align_4(fCurr));
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 bool readPath(SkPath* path) { 109 bool readPath(SkPath* path) {
110 return this->readObjectFromMemory(path); 110 return this->readObjectFromMemory(path);
111 } 111 }
112 112
113 bool readMatrix(SkMatrix* matrix) { 113 bool readMatrix(SkMatrix* matrix) {
114 return this->readObjectFromMemory(matrix); 114 return this->readObjectFromMemory(matrix);
115 } 115 }
116 116
117 bool readRRect(SkRRect* rrect) { 117 bool readRRect(SkRRect* rrect) {
118 return this->readObjectFromMemory(rrect); 118 return this->readObjectFromMemory(rrect);
119 } 119 }
120 120
121 bool readRegion(SkRegion* rgn) { 121 bool readRegion(SkRegion* rgn) {
122 return this->readObjectFromMemory(rgn); 122 return this->readObjectFromMemory(rgn);
123 } 123 }
124 124
125 /** 125 /**
126 * Read the length of a string (written by SkWriter32::writeString) into 126 * 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 127 * len (if len is not nullptr) and return the null-ternimated address of th e
128 * string within the reader's buffer. 128 * string within the reader's buffer.
129 */ 129 */
130 const char* readString(size_t* len = NULL); 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 private: 138 private:
139 template <typename T> bool readObjectFromMemory(T* obj) { 139 template <typename T> bool readObjectFromMemory(T* obj) {
140 size_t size = obj->readFromMemory(this->peek(), this->available()); 140 size_t size = obj->readFromMemory(this->peek(), this->available());
141 // 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
142 bool success = (size > 0) && (size <= this->available()) && (SkAlign4(si ze) == size); 142 bool success = (size > 0) && (size <= this->available()) && (SkAlign4(si ze) == size);
143 // In case of failure, we want to skip to the end 143 // In case of failure, we want to skip to the end
144 (void)this->skip(success ? size : this->available()); 144 (void)this->skip(success ? size : this->available());
145 return success; 145 return success;
146 } 146 }
147 147
148 // these are always 4-byte aligned 148 // these are always 4-byte aligned
149 const char* fCurr; // current position within buffer 149 const char* fCurr; // current position within buffer
150 const char* fStop; // end of buffer 150 const char* fStop; // end of buffer
151 const char* fBase; // beginning of buffer 151 const char* fBase; // beginning of buffer
152 152
153 #ifdef SK_DEBUG 153 #ifdef SK_DEBUG
154 static bool ptr_align_4(const void* ptr) { 154 static bool ptr_align_4(const void* ptr) {
155 return (((const char*)ptr - (const char*)NULL) & 3) == 0; 155 return (((const char*)ptr - (const char*)nullptr) & 3) == 0;
156 } 156 }
157 #endif 157 #endif
158 }; 158 };
159 159
160 #endif 160 #endif
OLDNEW
« no previous file with comments | « src/core/SkReadBuffer.cpp ('k') | src/core/SkRecordDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698