| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Always write this guy last (with no length field afterwards) | 56 // Always write this guy last (with no length field afterwards) |
| 57 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') | 57 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') |
| 58 | 58 |
| 59 class SkPictureData { | 59 class SkPictureData { |
| 60 public: | 60 public: |
| 61 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); | 61 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); |
| 62 // Does not affect ownership of SkStream. | 62 // Does not affect ownership of SkStream. |
| 63 static SkPictureData* CreateFromStream(SkStream*, | 63 static SkPictureData* CreateFromStream(SkStream*, |
| 64 const SkPictInfo&, | 64 const SkPictInfo&, |
| 65 SkPicture::InstallPixelRefProc); | 65 SkPicture::InstallPixelRefProc, |
| 66 SkTypefacePlayback*); |
| 66 static SkPictureData* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&); | 67 static SkPictureData* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&); |
| 67 | 68 |
| 68 virtual ~SkPictureData(); | 69 virtual ~SkPictureData(); |
| 69 | 70 |
| 70 void serialize(SkWStream*, SkPixelSerializer*) const; | 71 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet*) const; |
| 71 void flatten(SkWriteBuffer&) const; | 72 void flatten(SkWriteBuffer&) const; |
| 72 | 73 |
| 73 bool containsBitmaps() const; | 74 bool containsBitmaps() const; |
| 74 | 75 |
| 75 bool hasText() const { return fContentInfo.hasText(); } | 76 bool hasText() const { return fContentInfo.hasText(); } |
| 76 | 77 |
| 77 int opCount() const { return fContentInfo.numOperations(); } | 78 int opCount() const { return fContentInfo.numOperations(); } |
| 78 | 79 |
| 79 const SkData* opData() const { return fOpData; } | 80 const SkData* opData() const { return fOpData; } |
| 80 | 81 |
| 81 protected: | 82 protected: |
| 82 explicit SkPictureData(const SkPictInfo& info); | 83 explicit SkPictureData(const SkPictInfo& info); |
| 83 | 84 |
| 84 // Does not affect ownership of SkStream. | 85 // Does not affect ownership of SkStream. |
| 85 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); | 86 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc, SkTypefacePlayba
ck*); |
| 86 bool parseBuffer(SkReadBuffer& buffer); | 87 bool parseBuffer(SkReadBuffer& buffer); |
| 87 | 88 |
| 88 public: | 89 public: |
| 89 const SkBitmap& getBitmap(SkReader32* reader) const { | 90 const SkBitmap& getBitmap(SkReader32* reader) const { |
| 90 const int index = reader->readInt(); | 91 const int index = reader->readInt(); |
| 91 return fBitmaps[index]; | 92 return fBitmaps[index]; |
| 92 } | 93 } |
| 93 | 94 |
| 94 const SkImage* getImage(SkReader32* reader) const { | 95 const SkImage* getImage(SkReader32* reader) const { |
| 95 const int index = reader->readInt(); | 96 const int index = reader->readInt(); |
| 96 return fImageRefs[index]; | 97 return fImageRefs[index]; |
| 97 } | 98 } |
| 98 | 99 |
| 99 const SkPath& getPath(SkReader32* reader) const { | 100 const SkPath& getPath(SkReader32* reader) const { |
| 100 int index = reader->readInt() - 1; | 101 int index = reader->readInt() - 1; |
| 101 return fPaths[index]; | 102 return fPaths[index]; |
| 102 } | 103 } |
| 103 | 104 |
| 104 const SkPicture* getPicture(SkReader32* reader) const { | 105 const SkPicture* getPicture(SkReader32* reader) const { |
| 105 int index = reader->readInt(); | 106 int index = reader->readInt(); |
| 106 SkASSERT(index > 0 && index <= fPictureCount); | 107 SkASSERT(index > 0 && index <= fPictureCount); |
| 107 return fPictureRefs[index - 1]; | 108 return fPictureRefs[index - 1]; |
| 108 } | 109 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 137 GrPixelConfig config, SkScalar dpi) const; | 138 GrPixelConfig config, SkScalar dpi) const; |
| 138 | 139 |
| 139 bool suitableForLayerOptimization() const; | 140 bool suitableForLayerOptimization() const; |
| 140 #endif | 141 #endif |
| 141 | 142 |
| 142 private: | 143 private: |
| 143 void init(); | 144 void init(); |
| 144 | 145 |
| 145 // these help us with reading/writing | 146 // these help us with reading/writing |
| 146 // Does not affect ownership of SkStream. | 147 // Does not affect ownership of SkStream. |
| 147 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta
llPixelRefProc); | 148 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, |
| 149 SkPicture::InstallPixelRefProc, SkTypefacePlayback*); |
| 148 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); | 150 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); |
| 149 void flattenToBuffer(SkWriteBuffer&) const; | 151 void flattenToBuffer(SkWriteBuffer&) const; |
| 150 | 152 |
| 151 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_
SLOT. This empty | 153 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_
SLOT. This empty |
| 152 // bitmap allows playback to draw nothing and move on. | 154 // bitmap allows playback to draw nothing and move on. |
| 153 SkBitmap fBadBitmap; | 155 SkBitmap fBadBitmap; |
| 154 | 156 |
| 155 SkTArray<SkBitmap> fBitmaps; | 157 SkTArray<SkBitmap> fBitmaps; |
| 156 SkTArray<SkPaint> fPaints; | 158 SkTArray<SkPaint> fPaints; |
| 157 SkTArray<SkPath> fPaths; | 159 SkTArray<SkPath> fPaths; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 172 | 174 |
| 173 const SkPictInfo fInfo; | 175 const SkPictInfo fInfo; |
| 174 | 176 |
| 175 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 177 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
| 176 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 178 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
| 177 | 179 |
| 178 void initForPlayback() const; | 180 void initForPlayback() const; |
| 179 }; | 181 }; |
| 180 | 182 |
| 181 #endif | 183 #endif |
| OLD | NEW |