| 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 "SkDrawable.h" |
| 12 #include "SkPicture.h" | 13 #include "SkPicture.h" |
| 13 #include "SkPictureContentInfo.h" | 14 #include "SkPictureContentInfo.h" |
| 14 #include "SkPictureFlat.h" | 15 #include "SkPictureFlat.h" |
| 15 | 16 |
| 16 class SkData; | 17 class SkData; |
| 17 class SkPictureRecord; | 18 class SkPictureRecord; |
| 18 class SkPixelSerializer; | 19 class SkPixelSerializer; |
| 19 class SkReader32; | 20 class SkReader32; |
| 20 class SkStream; | 21 class SkStream; |
| 21 class SkWStream; | 22 class SkWStream; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 char fMagic[8]; | 37 char fMagic[8]; |
| 37 uint32_t fVersion; | 38 uint32_t fVersion; |
| 38 SkRect fCullRect; | 39 SkRect fCullRect; |
| 39 uint32_t fFlags; | 40 uint32_t fFlags; |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 #define SK_PICT_READER_TAG SkSetFourByteTag('r', 'e', 'a', 'd') | 43 #define SK_PICT_READER_TAG SkSetFourByteTag('r', 'e', 'a', 'd') |
| 43 #define SK_PICT_FACTORY_TAG SkSetFourByteTag('f', 'a', 'c', 't') | 44 #define SK_PICT_FACTORY_TAG SkSetFourByteTag('f', 'a', 'c', 't') |
| 44 #define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c') | 45 #define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c') |
| 45 #define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r') | 46 #define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r') |
| 47 #define SK_PICT_DRAWABLE_TAG SkSetFourByteTag('d', 'r', 'a', 'w') |
| 46 | 48 |
| 47 // This tag specifies the size of the ReadBuffer, needed for the following tags | 49 // 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') | 50 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') |
| 49 // these are all inside the ARRAYS tag | 51 // these are all inside the ARRAYS tag |
| 50 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') | 52 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') |
| 51 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') | 53 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') |
| 52 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') | 54 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') |
| 53 #define SK_PICT_TEXTBLOB_BUFFER_TAG SkSetFourByteTag('b', 'l', 'o', 'b') | 55 #define SK_PICT_TEXTBLOB_BUFFER_TAG SkSetFourByteTag('b', 'l', 'o', 'b') |
| 54 #define SK_PICT_IMAGE_BUFFER_TAG SkSetFourByteTag('i', 'm', 'a', 'g') | 56 #define SK_PICT_IMAGE_BUFFER_TAG SkSetFourByteTag('i', 'm', 'a', 'g') |
| 55 | 57 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 const SkPath& getPath(SkReadBuffer* reader) const { | 102 const SkPath& getPath(SkReadBuffer* reader) const { |
| 101 const int index = reader->readInt() - 1; | 103 const int index = reader->readInt() - 1; |
| 102 return reader->validateIndex(index, fPaths.count()) ? fPaths[index] : fE
mptyPath; | 104 return reader->validateIndex(index, fPaths.count()) ? fPaths[index] : fE
mptyPath; |
| 103 } | 105 } |
| 104 | 106 |
| 105 const SkPicture* getPicture(SkReadBuffer* reader) const { | 107 const SkPicture* getPicture(SkReadBuffer* reader) const { |
| 106 const int index = reader->readInt() - 1; | 108 const int index = reader->readInt() - 1; |
| 107 return reader->validateIndex(index, fPictureCount) ? fPictureRefs[index]
: nullptr; | 109 return reader->validateIndex(index, fPictureCount) ? fPictureRefs[index]
: nullptr; |
| 108 } | 110 } |
| 109 | 111 |
| 112 SkDrawable* getDrawable(SkReadBuffer* reader) const { |
| 113 int index = reader->readInt(); |
| 114 SkASSERT(index > 0 && index <= fDrawableCount); |
| 115 return fDrawableRefs[index - 1]; |
| 116 } |
| 117 |
| 110 const SkPaint* getPaint(SkReadBuffer* reader) const { | 118 const SkPaint* getPaint(SkReadBuffer* reader) const { |
| 111 const int index = reader->readInt() - 1; | 119 const int index = reader->readInt() - 1; |
| 112 return reader->validateIndex(index, fPaints.count()) ? &fPaints[index] :
nullptr; | 120 return reader->validateIndex(index, fPaints.count()) ? &fPaints[index] :
nullptr; |
| 113 } | 121 } |
| 114 | 122 |
| 115 const SkTextBlob* getTextBlob(SkReadBuffer* reader) const { | 123 const SkTextBlob* getTextBlob(SkReadBuffer* reader) const { |
| 116 const int index = reader->readInt() - 1; | 124 const int index = reader->readInt() - 1; |
| 117 return reader->validateIndex(index, fTextBlobCount) ? fTextBlobRefs[inde
x] : nullptr; | 125 return reader->validateIndex(index, fTextBlobCount) ? fTextBlobRefs[inde
x] : nullptr; |
| 118 } | 126 } |
| 119 | 127 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 SkTArray<SkPaint> fPaints; | 161 SkTArray<SkPaint> fPaints; |
| 154 SkTArray<SkPath> fPaths; | 162 SkTArray<SkPath> fPaths; |
| 155 | 163 |
| 156 sk_sp<SkData> fOpData; // opcodes and parameters | 164 sk_sp<SkData> fOpData; // opcodes and parameters |
| 157 | 165 |
| 158 const SkPath fEmptyPath; | 166 const SkPath fEmptyPath; |
| 159 const SkBitmap fEmptyBitmap; | 167 const SkBitmap fEmptyBitmap; |
| 160 | 168 |
| 161 const SkPicture** fPictureRefs; | 169 const SkPicture** fPictureRefs; |
| 162 int fPictureCount; | 170 int fPictureCount; |
| 171 SkDrawable** fDrawableRefs; |
| 172 int fDrawableCount; |
| 163 const SkTextBlob** fTextBlobRefs; | 173 const SkTextBlob** fTextBlobRefs; |
| 164 int fTextBlobCount; | 174 int fTextBlobCount; |
| 165 const SkImage** fImageRefs; | 175 const SkImage** fImageRefs; |
| 166 int fImageCount; | 176 int fImageCount; |
| 167 | 177 |
| 168 SkPictureContentInfo fContentInfo; | 178 SkPictureContentInfo fContentInfo; |
| 169 | 179 |
| 170 SkTypefacePlayback fTFPlayback; | 180 SkTypefacePlayback fTFPlayback; |
| 171 SkFactoryPlayback* fFactoryPlayback; | 181 SkFactoryPlayback* fFactoryPlayback; |
| 172 | 182 |
| 173 const SkPictInfo fInfo; | 183 const SkPictInfo fInfo; |
| 174 | 184 |
| 175 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 185 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
| 176 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 186 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
| 177 | 187 |
| 178 void initForPlayback() const; | 188 void initForPlayback() const; |
| 179 }; | 189 }; |
| 180 | 190 |
| 181 #endif | 191 #endif |
| OLD | NEW |