| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 54 |
| 55 // Always write this guy last (with no length field afterwards) | 55 // Always write this guy last (with no length field afterwards) |
| 56 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') | 56 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') |
| 57 | 57 |
| 58 class SkPictureData { | 58 class SkPictureData { |
| 59 public: | 59 public: |
| 60 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); | 60 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); |
| 61 // Does not affect ownership of SkStream. |
| 61 static SkPictureData* CreateFromStream(SkStream*, | 62 static SkPictureData* CreateFromStream(SkStream*, |
| 62 const SkPictInfo&, | 63 const SkPictInfo&, |
| 63 SkPicture::InstallPixelRefProc); | 64 SkPicture::InstallPixelRefProc); |
| 64 static SkPictureData* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&); | 65 static SkPictureData* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&); |
| 65 | 66 |
| 66 virtual ~SkPictureData(); | 67 virtual ~SkPictureData(); |
| 67 | 68 |
| 68 void serialize(SkWStream*, SkPixelSerializer*) const; | 69 void serialize(SkWStream*, SkPixelSerializer*) const; |
| 69 void flatten(SkWriteBuffer&) const; | 70 void flatten(SkWriteBuffer&) const; |
| 70 | 71 |
| 71 bool containsBitmaps() const; | 72 bool containsBitmaps() const; |
| 72 | 73 |
| 73 bool hasText() const { return fContentInfo.hasText(); } | 74 bool hasText() const { return fContentInfo.hasText(); } |
| 74 | 75 |
| 75 int opCount() const { return fContentInfo.numOperations(); } | 76 int opCount() const { return fContentInfo.numOperations(); } |
| 76 | 77 |
| 77 const SkData* opData() const { return fOpData; } | 78 const SkData* opData() const { return fOpData; } |
| 78 | 79 |
| 79 protected: | 80 protected: |
| 80 explicit SkPictureData(const SkPictInfo& info); | 81 explicit SkPictureData(const SkPictInfo& info); |
| 81 | 82 |
| 83 // Does not affect ownership of SkStream. |
| 82 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); | 84 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); |
| 83 bool parseBuffer(SkReadBuffer& buffer); | 85 bool parseBuffer(SkReadBuffer& buffer); |
| 84 | 86 |
| 85 public: | 87 public: |
| 86 const SkBitmap& getBitmap(SkReader32* reader) const { | 88 const SkBitmap& getBitmap(SkReader32* reader) const { |
| 87 const int index = reader->readInt(); | 89 const int index = reader->readInt(); |
| 88 return fBitmaps[index]; | 90 return fBitmaps[index]; |
| 89 } | 91 } |
| 90 | 92 |
| 91 const SkPath& getPath(SkReader32* reader) const { | 93 const SkPath& getPath(SkReader32* reader) const { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 bool suitableForGpuRasterization(GrContext* context, const char **reason, | 130 bool suitableForGpuRasterization(GrContext* context, const char **reason, |
| 129 GrPixelConfig config, SkScalar dpi) const; | 131 GrPixelConfig config, SkScalar dpi) const; |
| 130 | 132 |
| 131 bool suitableForLayerOptimization() const; | 133 bool suitableForLayerOptimization() const; |
| 132 #endif | 134 #endif |
| 133 | 135 |
| 134 private: | 136 private: |
| 135 void init(); | 137 void init(); |
| 136 | 138 |
| 137 // these help us with reading/writing | 139 // these help us with reading/writing |
| 140 // Does not affect ownership of SkStream. |
| 138 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta
llPixelRefProc); | 141 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta
llPixelRefProc); |
| 139 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); | 142 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); |
| 140 void flattenToBuffer(SkWriteBuffer&) const; | 143 void flattenToBuffer(SkWriteBuffer&) const; |
| 141 | 144 |
| 142 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_
SLOT. This empty | 145 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_
SLOT. This empty |
| 143 // bitmap allows playback to draw nothing and move on. | 146 // bitmap allows playback to draw nothing and move on. |
| 144 SkBitmap fBadBitmap; | 147 SkBitmap fBadBitmap; |
| 145 | 148 |
| 146 SkTArray<SkBitmap> fBitmaps; | 149 SkTArray<SkBitmap> fBitmaps; |
| 147 SkTArray<SkPaint> fPaints; | 150 SkTArray<SkPaint> fPaints; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 161 | 164 |
| 162 const SkPictInfo fInfo; | 165 const SkPictInfo fInfo; |
| 163 | 166 |
| 164 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 167 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
| 165 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 168 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
| 166 | 169 |
| 167 void initForPlayback() const; | 170 void initForPlayback() const; |
| 168 }; | 171 }; |
| 169 | 172 |
| 170 #endif | 173 #endif |
| OLD | NEW |