OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkReadBuffer_DEFINED | 8 #ifndef SkReadBuffer_DEFINED |
9 #define SkReadBuffer_DEFINED | 9 #define SkReadBuffer_DEFINED |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); } | 94 bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); } |
95 bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); } | 95 bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); } |
96 bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } | 96 bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } |
97 | 97 |
98 SkReader32* getReader32() { return &fReader; } | 98 SkReader32* getReader32() { return &fReader; } |
99 | 99 |
100 size_t size() { return fReader.size(); } | 100 size_t size() { return fReader.size(); } |
101 size_t offset() { return fReader.offset(); } | 101 size_t offset() { return fReader.offset(); } |
102 bool eof() { return fReader.eof(); } | 102 bool eof() { return fReader.eof(); } |
103 virtual const void* skip(size_t size) { return fReader.skip(size); } | 103 virtual const void* skip(size_t size) { return fReader.skip(size); } |
104 | |
105 void setOffset(size_t offset) { fReader.setOffset(offset); } | |
106 | |
104 void* readFunctionPtr() { return fReader.readPtr(); } | 107 void* readFunctionPtr() { return fReader.readPtr(); } |
105 | 108 |
106 // primitives | 109 // primitives |
107 virtual bool readBool(); | 110 virtual bool readBool(); |
108 virtual SkColor readColor(); | 111 virtual SkColor readColor(); |
109 virtual int32_t readInt(); | 112 virtual int32_t readInt(); |
110 virtual SkScalar readScalar(); | 113 virtual SkScalar readScalar(); |
111 virtual uint32_t readUInt(); | 114 virtual uint32_t readUInt(); |
112 virtual int32_t read32(); | 115 virtual int32_t read32(); |
113 | 116 |
114 // strings -- the caller is responsible for freeing the string contents | 117 // strings -- the caller is responsible for freeing the string contents |
115 virtual void readString(SkString* string); | 118 virtual void readString(SkString* string); |
116 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng); | 119 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng); |
117 | 120 |
118 // common data structures | 121 // common data structures |
119 virtual void readPoint(SkPoint* point); | 122 virtual void readPoint(SkPoint* point); |
120 SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } | 123 SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } |
121 virtual void readMatrix(SkMatrix* matrix); | 124 virtual void readMatrix(SkMatrix* matrix); |
122 virtual void readIRect(SkIRect* rect); | 125 virtual void readIRect(SkIRect* rect); |
123 virtual void readRect(SkRect* rect); | 126 virtual void readRect(SkRect* rect); |
127 virtual void readRRect(SkRRect* rrect); | |
124 virtual void readRegion(SkRegion* region); | 128 virtual void readRegion(SkRegion* region); |
125 | 129 |
126 virtual void readPath(SkPath* path); | 130 virtual void readPath(SkPath* path); |
127 void readPaint(SkPaint* paint) { paint->unflatten(*this); } | 131 void readPaint(SkPaint* paint) { paint->unflatten(*this); } |
128 | 132 |
129 virtual SkFlattenable* readFlattenable(SkFlattenable::Type); | 133 virtual SkFlattenable* readFlattenable(SkFlattenable::Type); |
130 template <typename T> sk_sp<T> readFlattenable() { | 134 template <typename T> sk_sp<T> readFlattenable() { |
131 return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType())); | 135 return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType())); |
132 } | 136 } |
133 sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColo rFilter>(); } | 137 sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColo rFilter>(); } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the | 202 * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the |
199 * appropriate size will be used. | 203 * appropriate size will be used. |
200 */ | 204 */ |
201 void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { | 205 void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { |
202 fBitmapDecoder = bitmapDecoder; | 206 fBitmapDecoder = bitmapDecoder; |
203 } | 207 } |
204 | 208 |
205 // Default impelementations don't check anything. | 209 // Default impelementations don't check anything. |
206 virtual bool validate(bool isValid) { return true; } | 210 virtual bool validate(bool isValid) { return true; } |
207 virtual bool isValid() const { return true; } | 211 virtual bool isValid() const { return true; } |
212 virtual void makeInvalid() { } | |
reed1
2016/04/19 12:54:11
is this still needed?
robertphillips
2016/04/19 14:34:42
Done.
| |
208 virtual bool validateAvailable(size_t size) { return true; } | 213 virtual bool validateAvailable(size_t size) { return true; } |
209 | 214 |
210 protected: | 215 protected: |
211 SkReader32 fReader; | 216 SkReader32 fReader; |
212 | 217 |
213 private: | 218 private: |
214 bool readArray(void* value, size_t size, size_t elementSize); | 219 bool readArray(void* value, size_t size, size_t elementSize); |
215 | 220 |
216 uint32_t fFlags; | 221 uint32_t fFlags; |
217 int fVersion; | 222 int fVersion; |
(...skipping 10 matching lines...) Expand all Loading... | |
228 SkPicture::InstallPixelRefProc fBitmapDecoder; | 233 SkPicture::InstallPixelRefProc fBitmapDecoder; |
229 | 234 |
230 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT | 235 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT |
231 // Debugging counter to keep track of how many bitmaps we | 236 // Debugging counter to keep track of how many bitmaps we |
232 // have decoded. | 237 // have decoded. |
233 int fDecodedBitmapIndex; | 238 int fDecodedBitmapIndex; |
234 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 239 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
235 }; | 240 }; |
236 | 241 |
237 #endif // SkReadBuffer_DEFINED | 242 #endif // SkReadBuffer_DEFINED |
OLD | NEW |