| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 virtual uint32_t readUInt(); | 116 virtual uint32_t readUInt(); |
| 117 virtual int32_t read32(); | 117 virtual int32_t read32(); |
| 118 | 118 |
| 119 // peek | 119 // peek |
| 120 virtual uint8_t peekByte(); | 120 virtual uint8_t peekByte(); |
| 121 | 121 |
| 122 // strings -- the caller is responsible for freeing the string contents | 122 // strings -- the caller is responsible for freeing the string contents |
| 123 virtual void readString(SkString* string); | 123 virtual void readString(SkString* string); |
| 124 | 124 |
| 125 // common data structures | 125 // common data structures |
| 126 virtual void readColor4f(SkColor4f* color); |
| 126 virtual void readPoint(SkPoint* point); | 127 virtual void readPoint(SkPoint* point); |
| 127 SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } | 128 SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } |
| 128 virtual void readMatrix(SkMatrix* matrix); | 129 virtual void readMatrix(SkMatrix* matrix); |
| 129 virtual void readIRect(SkIRect* rect); | 130 virtual void readIRect(SkIRect* rect); |
| 130 virtual void readRect(SkRect* rect); | 131 virtual void readRect(SkRect* rect); |
| 131 virtual void readRRect(SkRRect* rrect); | 132 virtual void readRRect(SkRRect* rrect); |
| 132 virtual void readRegion(SkRegion* region); | 133 virtual void readRegion(SkRegion* region); |
| 133 | 134 |
| 134 virtual void readPath(SkPath* path); | 135 virtual void readPath(SkPath* path); |
| 135 virtual void readPaint(SkPaint* paint) { paint->unflatten(*this); } | 136 virtual void readPaint(SkPaint* paint) { paint->unflatten(*this); } |
| 136 | 137 |
| 137 virtual SkFlattenable* readFlattenable(SkFlattenable::Type); | 138 virtual SkFlattenable* readFlattenable(SkFlattenable::Type); |
| 138 template <typename T> sk_sp<T> readFlattenable() { | 139 template <typename T> sk_sp<T> readFlattenable() { |
| 139 return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType())); | 140 return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType())); |
| 140 } | 141 } |
| 141 sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColo
rFilter>(); } | 142 sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColo
rFilter>(); } |
| 142 sk_sp<SkDrawLooper> readDrawLooper() { return this->readFlattenable<SkDrawLo
oper>(); } | 143 sk_sp<SkDrawLooper> readDrawLooper() { return this->readFlattenable<SkDrawLo
oper>(); } |
| 143 sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImag
eFilter>(); } | 144 sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImag
eFilter>(); } |
| 144 sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFi
lter>(); } | 145 sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFi
lter>(); } |
| 145 sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEf
fect>(); } | 146 sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEf
fect>(); } |
| 146 sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRaster
izer>(); } | 147 sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRaster
izer>(); } |
| 147 sk_sp<SkShader> readShader() { return this->readFlattenable<SkShader>(); } | 148 sk_sp<SkShader> readShader() { return this->readFlattenable<SkShader>(); } |
| 148 sk_sp<SkXfermode> readXfermode() { return this->readFlattenable<SkXfermode>(
); } | 149 sk_sp<SkXfermode> readXfermode() { return this->readFlattenable<SkXfermode>(
); } |
| 149 | 150 |
| 150 // binary data and arrays | 151 // binary data and arrays |
| 151 virtual bool readByteArray(void* value, size_t size); | 152 virtual bool readByteArray(void* value, size_t size); |
| 152 virtual bool readColorArray(SkColor* colors, size_t size); | 153 virtual bool readColorArray(SkColor* colors, size_t size); |
| 154 virtual bool readColor4fArray(SkColor4f* colors, size_t size); |
| 153 virtual bool readIntArray(int32_t* values, size_t size); | 155 virtual bool readIntArray(int32_t* values, size_t size); |
| 154 virtual bool readPointArray(SkPoint* points, size_t size); | 156 virtual bool readPointArray(SkPoint* points, size_t size); |
| 155 virtual bool readScalarArray(SkScalar* values, size_t size); | 157 virtual bool readScalarArray(SkScalar* values, size_t size); |
| 156 | 158 |
| 157 sk_sp<SkData> readByteArrayAsData() { | 159 sk_sp<SkData> readByteArrayAsData() { |
| 158 size_t len = this->getArrayCount(); | 160 size_t len = this->getArrayCount(); |
| 159 if (!this->validateAvailable(len)) { | 161 if (!this->validateAvailable(len)) { |
| 160 return SkData::MakeEmpty(); | 162 return SkData::MakeEmpty(); |
| 161 } | 163 } |
| 162 void* buffer = sk_malloc_throw(len); | 164 void* buffer = sk_malloc_throw(len); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT | 262 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT |
| 261 // Debugging counter to keep track of how many bitmaps we | 263 // Debugging counter to keep track of how many bitmaps we |
| 262 // have decoded. | 264 // have decoded. |
| 263 int fDecodedBitmapIndex; | 265 int fDecodedBitmapIndex; |
| 264 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 266 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
| 265 | 267 |
| 266 SkInflator* fInflator = nullptr; | 268 SkInflator* fInflator = nullptr; |
| 267 }; | 269 }; |
| 268 | 270 |
| 269 #endif // SkReadBuffer_DEFINED | 271 #endif // SkReadBuffer_DEFINED |
| OLD | NEW |