| 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 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c') | 44 #define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c') |
| 45 #define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r') | 45 #define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r') |
| 46 | 46 |
| 47 // This tag specifies the size of the ReadBuffer, needed for the following tags | 47 // This tag specifies the size of the ReadBuffer, needed for the following tags |
| 48 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') | 48 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') |
| 49 // these are all inside the ARRAYS tag | 49 // these are all inside the ARRAYS tag |
| 50 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') | 50 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') |
| 51 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') | 51 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') |
| 52 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') | 52 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') |
| 53 #define SK_PICT_TEXTBLOB_BUFFER_TAG SkSetFourByteTag('b', 'l', 'o', 'b') | 53 #define SK_PICT_TEXTBLOB_BUFFER_TAG SkSetFourByteTag('b', 'l', 'o', 'b') |
| 54 #define SK_PICT_IMAGE_BUFFER_TAG SkSetFourByteTag('i', 'm', 'a', 'g') |
| 54 | 55 |
| 55 // Always write this guy last (with no length field afterwards) | 56 // Always write this guy last (with no length field afterwards) |
| 56 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') | 57 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') |
| 57 | 58 |
| 58 class SkPictureData { | 59 class SkPictureData { |
| 59 public: | 60 public: |
| 60 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); | 61 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); |
| 61 // Does not affect ownership of SkStream. | 62 // Does not affect ownership of SkStream. |
| 62 static SkPictureData* CreateFromStream(SkStream*, | 63 static SkPictureData* CreateFromStream(SkStream*, |
| 63 const SkPictInfo&, | 64 const SkPictInfo&, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 83 // Does not affect ownership of SkStream. | 84 // Does not affect ownership of SkStream. |
| 84 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); | 85 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); |
| 85 bool parseBuffer(SkReadBuffer& buffer); | 86 bool parseBuffer(SkReadBuffer& buffer); |
| 86 | 87 |
| 87 public: | 88 public: |
| 88 const SkBitmap& getBitmap(SkReader32* reader) const { | 89 const SkBitmap& getBitmap(SkReader32* reader) const { |
| 89 const int index = reader->readInt(); | 90 const int index = reader->readInt(); |
| 90 return fBitmaps[index]; | 91 return fBitmaps[index]; |
| 91 } | 92 } |
| 92 | 93 |
| 94 const SkImage* getImage(SkReader32* reader) const { |
| 95 const int index = reader->readInt(); |
| 96 return fImageRefs[index]; |
| 97 } |
| 98 |
| 93 const SkPath& getPath(SkReader32* reader) const { | 99 const SkPath& getPath(SkReader32* reader) const { |
| 94 int index = reader->readInt() - 1; | 100 int index = reader->readInt() - 1; |
| 95 return fPaths[index]; | 101 return fPaths[index]; |
| 96 } | 102 } |
| 97 | 103 |
| 98 const SkPicture* getPicture(SkReader32* reader) const { | 104 const SkPicture* getPicture(SkReader32* reader) const { |
| 99 int index = reader->readInt(); | 105 int index = reader->readInt(); |
| 100 SkASSERT(index > 0 && index <= fPictureCount); | 106 SkASSERT(index > 0 && index <= fPictureCount); |
| 101 return fPictureRefs[index - 1]; | 107 return fPictureRefs[index - 1]; |
| 102 } | 108 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 SkTArray<SkBitmap> fBitmaps; | 155 SkTArray<SkBitmap> fBitmaps; |
| 150 SkTArray<SkPaint> fPaints; | 156 SkTArray<SkPaint> fPaints; |
| 151 SkTArray<SkPath> fPaths; | 157 SkTArray<SkPath> fPaths; |
| 152 | 158 |
| 153 SkData* fOpData; // opcodes and parameters | 159 SkData* fOpData; // opcodes and parameters |
| 154 | 160 |
| 155 const SkPicture** fPictureRefs; | 161 const SkPicture** fPictureRefs; |
| 156 int fPictureCount; | 162 int fPictureCount; |
| 157 const SkTextBlob** fTextBlobRefs; | 163 const SkTextBlob** fTextBlobRefs; |
| 158 int fTextBlobCount; | 164 int fTextBlobCount; |
| 165 const SkImage** fImageRefs; |
| 166 int fImageCount; |
| 159 | 167 |
| 160 SkPictureContentInfo fContentInfo; | 168 SkPictureContentInfo fContentInfo; |
| 161 | 169 |
| 162 SkTypefacePlayback fTFPlayback; | 170 SkTypefacePlayback fTFPlayback; |
| 163 SkFactoryPlayback* fFactoryPlayback; | 171 SkFactoryPlayback* fFactoryPlayback; |
| 164 | 172 |
| 165 const SkPictInfo fInfo; | 173 const SkPictInfo fInfo; |
| 166 | 174 |
| 167 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 175 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
| 168 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 176 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
| 169 | 177 |
| 170 void initForPlayback() const; | 178 void initForPlayback() const; |
| 171 }; | 179 }; |
| 172 | 180 |
| 173 #endif | 181 #endif |
| OLD | NEW |