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 "SkBitmapHeap.h" | 11 #include "SkBitmapHeap.h" |
12 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkDrawLooper.h" | 14 #include "SkDrawLooper.h" |
15 #include "SkImageFilter.h" | 15 #include "SkImageFilter.h" |
16 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
17 #include "SkPath.h" | 17 #include "SkPath.h" |
18 #include "SkPathEffect.h" | 18 #include "SkPathEffect.h" |
19 #include "SkPicture.h" | 19 #include "SkPicture.h" |
20 #include "SkPixelRef.h" | 20 #include "SkPixelRef.h" |
21 #include "SkRasterizer.h" | 21 #include "SkRasterizer.h" |
22 #include "SkReadBuffer.h" | 22 #include "SkReadBuffer.h" |
23 #include "SkReader32.h" | 23 #include "SkReader32.h" |
24 #include "SkRefCnt.h" | 24 #include "SkRefCnt.h" |
25 #include "SkShader.h" | 25 #include "SkShader.h" |
26 #include "SkUnitMapper.h" | |
27 #include "SkWriteBuffer.h" | 26 #include "SkWriteBuffer.h" |
28 #include "SkXfermode.h" | 27 #include "SkXfermode.h" |
29 | 28 |
30 class SkBitmap; | 29 class SkBitmap; |
31 | 30 |
32 #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC) | 31 #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC) |
33 #define DEBUG_NON_DETERMINISTIC_ASSERT | 32 #define DEBUG_NON_DETERMINISTIC_ASSERT |
34 #endif | 33 #endif |
35 | 34 |
36 class SkReadBuffer { | 35 class SkReadBuffer { |
37 public: | 36 public: |
38 SkReadBuffer(); | 37 SkReadBuffer(); |
39 SkReadBuffer(const void* data, size_t size); | 38 SkReadBuffer(const void* data, size_t size); |
40 SkReadBuffer(SkStream* stream); | 39 SkReadBuffer(SkStream* stream); |
41 virtual ~SkReadBuffer(); | 40 virtual ~SkReadBuffer(); |
42 | 41 |
43 enum Version { | 42 enum Version { |
44 kFilterLevelIsEnum_Version = 23, | 43 kFilterLevelIsEnum_Version = 23, |
45 kGradientFlippedFlag_Version = 24, | 44 kGradientFlippedFlag_Version = 24, |
46 kDashWritesPhaseIntervals_Version = 25, | 45 kDashWritesPhaseIntervals_Version = 25, |
47 kColorShaderNoBool_Version = 26, | 46 kColorShaderNoBool_Version = 26, |
| 47 kNoUnitMappers_Version = 27, |
48 }; | 48 }; |
49 | 49 |
50 /** | 50 /** |
51 * Returns true IFF the version is older than the specified version. | 51 * Returns true IFF the version is older than the specified version. |
52 */ | 52 */ |
53 bool isVersionLT(Version targetVersion) const { | 53 bool isVersionLT(Version targetVersion) const { |
54 SkASSERT(targetVersion > 0); | 54 SkASSERT(targetVersion > 0); |
55 return fVersion > 0 && fVersion < targetVersion; | 55 return fVersion > 0 && fVersion < targetVersion; |
56 } | 56 } |
57 | 57 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return (T*) this->readFlattenable(T::GetFlattenableType()); | 114 return (T*) this->readFlattenable(T::GetFlattenableType()); |
115 } | 115 } |
116 SkColorFilter* readColorFilter() { return this->readFlattenable<SkColorFilte
r>(); } | 116 SkColorFilter* readColorFilter() { return this->readFlattenable<SkColorFilte
r>(); } |
117 SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper
>(); } | 117 SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper
>(); } |
118 SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilte
r>(); } | 118 SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilte
r>(); } |
119 SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter
>(); } | 119 SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter
>(); } |
120 SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect
>(); } | 120 SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect
>(); } |
121 SkPixelRef* readPixelRef() { return this->readFlattenable<SkPixelRef>(
); } | 121 SkPixelRef* readPixelRef() { return this->readFlattenable<SkPixelRef>(
); } |
122 SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer
>(); } | 122 SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer
>(); } |
123 SkShader* readShader() { return this->readFlattenable<SkShader>();
} | 123 SkShader* readShader() { return this->readFlattenable<SkShader>();
} |
124 SkUnitMapper* readUnitMapper() { return this->readFlattenable<SkUnitMapper
>(); } | |
125 SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(
); } | 124 SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(
); } |
126 | 125 |
| 126 /** |
| 127 * Like readFlattenable() but explicitly just skips the data that was writt
en for the |
| 128 * flattenable (or the sentinel that there wasn't one). |
| 129 */ |
| 130 virtual void skipFlattenable(); |
127 | 131 |
128 // binary data and arrays | 132 // binary data and arrays |
129 virtual bool readByteArray(void* value, size_t size); | 133 virtual bool readByteArray(void* value, size_t size); |
130 virtual bool readColorArray(SkColor* colors, size_t size); | 134 virtual bool readColorArray(SkColor* colors, size_t size); |
131 virtual bool readIntArray(int32_t* values, size_t size); | 135 virtual bool readIntArray(int32_t* values, size_t size); |
132 virtual bool readPointArray(SkPoint* points, size_t size); | 136 virtual bool readPointArray(SkPoint* points, size_t size); |
133 virtual bool readScalarArray(SkScalar* values, size_t size); | 137 virtual bool readScalarArray(SkScalar* values, size_t size); |
134 | 138 |
135 SkData* readByteArrayAsData() { | 139 SkData* readByteArrayAsData() { |
136 size_t len = this->getArrayCount(); | 140 size_t len = this->getArrayCount(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 SkPicture::InstallPixelRefProc fBitmapDecoder; | 218 SkPicture::InstallPixelRefProc fBitmapDecoder; |
215 | 219 |
216 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT | 220 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT |
217 // Debugging counter to keep track of how many bitmaps we | 221 // Debugging counter to keep track of how many bitmaps we |
218 // have decoded. | 222 // have decoded. |
219 int fDecodedBitmapIndex; | 223 int fDecodedBitmapIndex; |
220 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 224 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
221 }; | 225 }; |
222 | 226 |
223 #endif // SkReadBuffer_DEFINED | 227 #endif // SkReadBuffer_DEFINED |
OLD | NEW |