OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 #ifndef SkReadBuffer_DEFINED | 9 #ifndef SkReadBuffer_DEFINED |
10 #define SkReadBuffer_DEFINED | 10 #define SkReadBuffer_DEFINED |
(...skipping 23 matching lines...) Expand all Loading... |
34 #define DEBUG_NON_DETERMINISTIC_ASSERT | 34 #define DEBUG_NON_DETERMINISTIC_ASSERT |
35 #endif | 35 #endif |
36 | 36 |
37 class SkReadBuffer { | 37 class SkReadBuffer { |
38 public: | 38 public: |
39 SkReadBuffer(); | 39 SkReadBuffer(); |
40 SkReadBuffer(const void* data, size_t size); | 40 SkReadBuffer(const void* data, size_t size); |
41 SkReadBuffer(SkStream* stream); | 41 SkReadBuffer(SkStream* stream); |
42 virtual ~SkReadBuffer(); | 42 virtual ~SkReadBuffer(); |
43 | 43 |
| 44 /** Return the version of the serialized picture this buffer holds, or 0 if
unset. */ |
| 45 int pictureVersion() const { return fPictureVersion; } |
| 46 |
| 47 /** This may be called at most once; most clients of SkReadBuffer should not
mess with it. */ |
| 48 void setPictureVersion(int version) { |
| 49 SkASSERT(0 == fPictureVersion); |
| 50 fPictureVersion = version; |
| 51 } |
| 52 |
44 enum Flags { | 53 enum Flags { |
45 kCrossProcess_Flag = 1 << 0, | 54 kCrossProcess_Flag = 1 << 0, |
46 kScalarIsFloat_Flag = 1 << 1, | 55 kScalarIsFloat_Flag = 1 << 1, |
47 kPtrIs64Bit_Flag = 1 << 2, | 56 kPtrIs64Bit_Flag = 1 << 2, |
48 kValidation_Flag = 1 << 3, | 57 kValidation_Flag = 1 << 3, |
49 }; | 58 }; |
50 | 59 |
51 void setFlags(uint32_t flags) { fFlags = flags; } | 60 void setFlags(uint32_t flags) { fFlags = flags; } |
52 uint32_t getFlags() const { return fFlags; } | 61 uint32_t getFlags() const { return fFlags; } |
53 | 62 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 virtual bool isValid() const { return true; } | 186 virtual bool isValid() const { return true; } |
178 virtual bool validateAvailable(size_t size) { return true; } | 187 virtual bool validateAvailable(size_t size) { return true; } |
179 | 188 |
180 protected: | 189 protected: |
181 SkReader32 fReader; | 190 SkReader32 fReader; |
182 | 191 |
183 private: | 192 private: |
184 bool readArray(void* value, size_t size, size_t elementSize); | 193 bool readArray(void* value, size_t size, size_t elementSize); |
185 | 194 |
186 uint32_t fFlags; | 195 uint32_t fFlags; |
| 196 int fPictureVersion; |
187 | 197 |
188 void* fMemoryPtr; | 198 void* fMemoryPtr; |
189 | 199 |
190 SkBitmapHeapReader* fBitmapStorage; | 200 SkBitmapHeapReader* fBitmapStorage; |
191 SkTypeface** fTFArray; | 201 SkTypeface** fTFArray; |
192 int fTFCount; | 202 int fTFCount; |
193 | 203 |
194 SkTDArray<SkFlattenable::Factory>* fFactoryTDArray; | 204 SkTDArray<SkFlattenable::Factory>* fFactoryTDArray; |
195 SkFlattenable::Factory* fFactoryArray; | 205 SkFlattenable::Factory* fFactoryArray; |
196 int fFactoryCount; | 206 int fFactoryCount; |
197 | 207 |
198 SkPicture::InstallPixelRefProc fBitmapDecoder; | 208 SkPicture::InstallPixelRefProc fBitmapDecoder; |
199 | 209 |
200 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT | 210 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT |
201 // Debugging counter to keep track of how many bitmaps we | 211 // Debugging counter to keep track of how many bitmaps we |
202 // have decoded. | 212 // have decoded. |
203 int fDecodedBitmapIndex; | 213 int fDecodedBitmapIndex; |
204 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 214 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
205 }; | 215 }; |
206 | 216 |
207 #endif // SkReadBuffer_DEFINED | 217 #endif // SkReadBuffer_DEFINED |
OLD | NEW |