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