| 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 SkPictureData_DEFINED | 8 #ifndef SkPictureData_DEFINED |
| 9 #define SkPictureData_DEFINED | 9 #define SkPictureData_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkPathHeap.h" | 12 #include "SkPathHeap.h" |
| 13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
| 14 #include "SkPictureContentInfo.h" | 14 #include "SkPictureContentInfo.h" |
| 15 #include "SkPictureFlat.h" | 15 #include "SkPictureFlat.h" |
| 16 #include "SkPictureStateTree.h" | 16 #include "SkPictureStateTree.h" |
| 17 | 17 |
| 18 class SkData; | 18 class SkData; |
| 19 class SkPictureRecord; | 19 class SkPictureRecord; |
| 20 class SkReader32; | 20 class SkReader32; |
| 21 class SkStream; | 21 class SkStream; |
| 22 class SkWStream; | 22 class SkWStream; |
| 23 class SkBBoxHierarchy; | 23 class SkBBoxHierarchy; |
| 24 class SkMatrix; | 24 class SkMatrix; |
| 25 class SkPaint; | 25 class SkPaint; |
| 26 class SkPath; | 26 class SkPath; |
| 27 class SkPictureStateTree; | 27 class SkPictureStateTree; |
| 28 class SkReadBuffer; | 28 class SkReadBuffer; |
| 29 class SkTextBlob; |
| 29 | 30 |
| 30 struct SkPictInfo { | 31 struct SkPictInfo { |
| 31 enum Flags { | 32 enum Flags { |
| 32 kCrossProcess_Flag = 1 << 0, | 33 kCrossProcess_Flag = 1 << 0, |
| 33 kScalarIsFloat_Flag = 1 << 1, | 34 kScalarIsFloat_Flag = 1 << 1, |
| 34 kPtrIs64Bit_Flag = 1 << 2, | 35 kPtrIs64Bit_Flag = 1 << 2, |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 char fMagic[8]; | 38 char fMagic[8]; |
| 38 uint32_t fVersion; | 39 uint32_t fVersion; |
| 39 uint32_t fWidth; | 40 uint32_t fWidth; |
| 40 uint32_t fHeight; | 41 uint32_t fHeight; |
| 41 uint32_t fFlags; | 42 uint32_t fFlags; |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 #define SK_PICT_READER_TAG SkSetFourByteTag('r', 'e', 'a', 'd') | 45 #define SK_PICT_READER_TAG SkSetFourByteTag('r', 'e', 'a', 'd') |
| 45 #define SK_PICT_FACTORY_TAG SkSetFourByteTag('f', 'a', 'c', 't') | 46 #define SK_PICT_FACTORY_TAG SkSetFourByteTag('f', 'a', 'c', 't') |
| 46 #define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c') | 47 #define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c') |
| 47 #define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r') | 48 #define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r') |
| 48 | 49 |
| 49 // This tag specifies the size of the ReadBuffer, needed for the following tags | 50 // This tag specifies the size of the ReadBuffer, needed for the following tags |
| 50 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') | 51 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') |
| 51 // these are all inside the ARRAYS tag | 52 // these are all inside the ARRAYS tag |
| 52 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') | 53 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') |
| 53 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') | 54 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') |
| 54 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') | 55 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') |
| 56 #define SK_PICT_TEXTBLOB_BUFFER_TAG SkSetFourByteTag('b', 'l', 'o', 'b') |
| 55 | 57 |
| 56 // Always write this guy last (with no length field afterwards) | 58 // Always write this guy last (with no length field afterwards) |
| 57 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') | 59 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') |
| 58 | 60 |
| 59 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 61 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
| 60 /** | 62 /** |
| 61 * Container for data that is needed to deep copy a SkPicture. The container | 63 * Container for data that is needed to deep copy a SkPicture. The container |
| 62 * enables the data to be generated once and reused for subsequent copies. | 64 * enables the data to be generated once and reused for subsequent copies. |
| 63 */ | 65 */ |
| 64 struct SkPictCopyInfo { | 66 struct SkPictCopyInfo { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 127 } |
| 126 | 128 |
| 127 const SkPaint* getPaint(SkReader32* reader) const { | 129 const SkPaint* getPaint(SkReader32* reader) const { |
| 128 int index = reader->readInt(); | 130 int index = reader->readInt(); |
| 129 if (index == 0) { | 131 if (index == 0) { |
| 130 return NULL; | 132 return NULL; |
| 131 } | 133 } |
| 132 return &(*fPaints)[index - 1]; | 134 return &(*fPaints)[index - 1]; |
| 133 } | 135 } |
| 134 | 136 |
| 137 const SkTextBlob* getTextBlob(SkReader32* reader) const { |
| 138 int index = reader->readInt(); |
| 139 SkASSERT(index > 0 && index <= fTextBlobCount); |
| 140 return fTextBlobRefs[index - 1]; |
| 141 } |
| 142 |
| 135 void initIterator(SkPictureStateTree::Iterator* iter, | 143 void initIterator(SkPictureStateTree::Iterator* iter, |
| 136 const SkTDArray<void*>& draws, | 144 const SkTDArray<void*>& draws, |
| 137 SkCanvas* canvas) const { | 145 SkCanvas* canvas) const { |
| 138 if (NULL != fStateTree) { | 146 if (NULL != fStateTree) { |
| 139 fStateTree->initIterator(iter, draws, canvas); | 147 fStateTree->initIterator(iter, draws, canvas); |
| 140 } | 148 } |
| 141 } | 149 } |
| 142 | 150 |
| 143 #if SK_SUPPORT_GPU | 151 #if SK_SUPPORT_GPU |
| 144 /** | 152 /** |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 184 |
| 177 SkTRefArray<SkBitmap>* fBitmaps; | 185 SkTRefArray<SkBitmap>* fBitmaps; |
| 178 SkTRefArray<SkPaint>* fPaints; | 186 SkTRefArray<SkPaint>* fPaints; |
| 179 | 187 |
| 180 SkData* fOpData; // opcodes and parameters | 188 SkData* fOpData; // opcodes and parameters |
| 181 | 189 |
| 182 SkAutoTUnref<const SkPathHeap> fPathHeap; // reference counted | 190 SkAutoTUnref<const SkPathHeap> fPathHeap; // reference counted |
| 183 | 191 |
| 184 const SkPicture** fPictureRefs; | 192 const SkPicture** fPictureRefs; |
| 185 int fPictureCount; | 193 int fPictureCount; |
| 194 const SkTextBlob** fTextBlobRefs; |
| 195 int fTextBlobCount; |
| 186 | 196 |
| 187 SkBBoxHierarchy* fBoundingHierarchy; | 197 SkBBoxHierarchy* fBoundingHierarchy; |
| 188 SkPictureStateTree* fStateTree; | 198 SkPictureStateTree* fStateTree; |
| 189 | 199 |
| 190 SkPictureContentInfo fContentInfo; | 200 SkPictureContentInfo fContentInfo; |
| 191 | 201 |
| 192 SkTypefacePlayback fTFPlayback; | 202 SkTypefacePlayback fTFPlayback; |
| 193 SkFactoryPlayback* fFactoryPlayback; | 203 SkFactoryPlayback* fFactoryPlayback; |
| 194 | 204 |
| 195 const SkPictInfo fInfo; | 205 const SkPictInfo fInfo; |
| 196 | 206 |
| 197 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 207 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
| 198 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 208 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
| 199 | 209 |
| 200 void initForPlayback() const; | 210 void initForPlayback() const; |
| 201 }; | 211 }; |
| 202 | 212 |
| 203 #endif | 213 #endif |
| OLD | NEW |