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 |
11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
12 #include "SkData.h" | 12 #include "SkData.h" |
13 #include "SkDrawLooper.h" | 13 #include "SkDrawLooper.h" |
14 #include "SkImageFilter.h" | 14 #include "SkImageFilter.h" |
15 #include "SkMaskFilter.h" | 15 #include "SkMaskFilter.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkPathEffect.h" | 17 #include "SkPathEffect.h" |
18 #include "SkPicture.h" | 18 #include "SkPicture.h" |
19 #include "SkRasterizer.h" | 19 #include "SkRasterizer.h" |
20 #include "SkReadBuffer.h" | 20 #include "SkReadBuffer.h" |
21 #include "SkReader32.h" | 21 #include "SkReader32.h" |
22 #include "SkRefCnt.h" | 22 #include "SkRefCnt.h" |
23 #include "SkShader.h" | 23 #include "SkShader.h" |
24 #include "SkTHash.h" | 24 #include "SkTHash.h" |
25 #include "SkWriteBuffer.h" | 25 #include "SkWriteBuffer.h" |
26 #include "SkXfermode.h" | 26 #include "SkXfermode.h" |
27 | 27 |
28 class SkBitmap; | 28 class SkBitmap; |
29 class SkImage; | 29 class SkImage; |
30 class SkInflator; | |
30 | 31 |
31 #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC) | 32 #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC) |
32 #define DEBUG_NON_DETERMINISTIC_ASSERT | 33 #define DEBUG_NON_DETERMINISTIC_ASSERT |
33 #endif | 34 #endif |
34 | 35 |
35 class SkReadBuffer { | 36 class SkReadBuffer { |
36 public: | 37 public: |
37 SkReadBuffer(); | 38 SkReadBuffer(); |
38 SkReadBuffer(const void* data, size_t size); | 39 SkReadBuffer(const void* data, size_t size); |
39 SkReadBuffer(SkStream* stream); | 40 SkReadBuffer(SkStream* stream); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 // common data structures | 125 // common data structures |
125 virtual void readPoint(SkPoint* point); | 126 virtual void readPoint(SkPoint* point); |
126 SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } | 127 SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } |
127 virtual void readMatrix(SkMatrix* matrix); | 128 virtual void readMatrix(SkMatrix* matrix); |
128 virtual void readIRect(SkIRect* rect); | 129 virtual void readIRect(SkIRect* rect); |
129 virtual void readRect(SkRect* rect); | 130 virtual void readRect(SkRect* rect); |
130 virtual void readRRect(SkRRect* rrect); | 131 virtual void readRRect(SkRRect* rrect); |
131 virtual void readRegion(SkRegion* region); | 132 virtual void readRegion(SkRegion* region); |
132 | 133 |
133 virtual void readPath(SkPath* path); | 134 virtual void readPath(SkPath* path); |
134 void readPaint(SkPaint* paint) { paint->unflatten(*this); } | 135 virtual void readPaint(SkPaint* paint) { paint->unflatten(*this); } |
135 | 136 |
136 virtual SkFlattenable* readFlattenable(SkFlattenable::Type); | 137 virtual SkFlattenable* readFlattenable(SkFlattenable::Type); |
137 template <typename T> sk_sp<T> readFlattenable() { | 138 template <typename T> sk_sp<T> readFlattenable() { |
138 return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType())); | 139 return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType())); |
139 } | 140 } |
140 sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColo rFilter>(); } | 141 sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColo rFilter>(); } |
141 sk_sp<SkDrawLooper> readDrawLooper() { return this->readFlattenable<SkDrawLo oper>(); } | 142 sk_sp<SkDrawLooper> readDrawLooper() { return this->readFlattenable<SkDrawLo oper>(); } |
142 sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImag eFilter>(); } | 143 sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImag eFilter>(); } |
143 sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFi lter>(); } | 144 sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFi lter>(); } |
144 sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEf fect>(); } | 145 sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEf fect>(); } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 void setImageDeserializer(SkImageDeserializer* factory); | 209 void setImageDeserializer(SkImageDeserializer* factory); |
209 | 210 |
210 // Default impelementations don't check anything. | 211 // Default impelementations don't check anything. |
211 virtual bool validate(bool isValid) { return isValid; } | 212 virtual bool validate(bool isValid) { return isValid; } |
212 virtual bool isValid() const { return true; } | 213 virtual bool isValid() const { return true; } |
213 virtual bool validateAvailable(size_t size) { return true; } | 214 virtual bool validateAvailable(size_t size) { return true; } |
214 bool validateIndex(int index, int count) { | 215 bool validateIndex(int index, int count) { |
215 return this->validate(index >= 0 && index < count); | 216 return this->validate(index >= 0 && index < count); |
216 } | 217 } |
217 | 218 |
219 SkInflator* getInflator() const { return fInflator; } | |
220 void setInflator(SkInflator* inf) { fInflator = inf; } | |
221 | |
222 sk_sp<SkImage> inflateImage(); | |
mtklein
2016/08/26 18:43:23
Is this implemented? Is it different than readIma
reed1
2016/08/27 14:14:54
Gone. Was not implemented or called.
| |
223 | |
218 protected: | 224 protected: |
219 /** | 225 /** |
220 * Allows subclass to check if we are using factories for expansion | 226 * Allows subclass to check if we are using factories for expansion |
221 * of flattenables. | 227 * of flattenables. |
222 */ | 228 */ |
223 int factoryCount() { return fFactoryCount; } | 229 int factoryCount() { return fFactoryCount; } |
224 | 230 |
225 /** | 231 /** |
226 * Checks if a custom factory has been set for a given flattenable. | 232 * Checks if a custom factory has been set for a given flattenable. |
227 * Returns the custom factory if it exists, or nullptr otherwise. | 233 * Returns the custom factory if it exists, or nullptr otherwise. |
(...skipping 26 matching lines...) Expand all Loading... | |
254 SkTHashMap<SkString, SkFlattenable::Factory> fCustomFactory; | 260 SkTHashMap<SkString, SkFlattenable::Factory> fCustomFactory; |
255 | 261 |
256 // We do not own this ptr, we just use it (guaranteed to never be null) | 262 // We do not own this ptr, we just use it (guaranteed to never be null) |
257 SkImageDeserializer* fImageDeserializer; | 263 SkImageDeserializer* fImageDeserializer; |
258 | 264 |
259 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT | 265 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT |
260 // Debugging counter to keep track of how many bitmaps we | 266 // Debugging counter to keep track of how many bitmaps we |
261 // have decoded. | 267 // have decoded. |
262 int fDecodedBitmapIndex; | 268 int fDecodedBitmapIndex; |
263 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 269 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
270 | |
271 SkInflator* fInflator = nullptr; | |
264 }; | 272 }; |
265 | 273 |
266 #endif // SkReadBuffer_DEFINED | 274 #endif // SkReadBuffer_DEFINED |
OLD | NEW |