Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: src/core/SkPictureData.h

Issue 1837913003: Add support for serializing/deserializing of SkDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add ability to specify custom flattenable factories on SkReadBuffer Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int index = reader->readInt() - 1; 103 int index = reader->readInt() - 1;
102 return fPaths[index]; 104 return fPaths[index];
103 } 105 }
104 106
105 const SkPicture* getPicture(SkReader32* reader) const { 107 const SkPicture* getPicture(SkReader32* reader) const {
106 int index = reader->readInt(); 108 int index = reader->readInt();
107 SkASSERT(index > 0 && index <= fPictureCount); 109 SkASSERT(index > 0 && index <= fPictureCount);
108 return fPictureRefs[index - 1]; 110 return fPictureRefs[index - 1];
109 } 111 }
110 112
113 SkDrawable* getDrawable(SkReader32* reader) const {
114 int index = reader->readInt();
115 SkASSERT(index > 0 && index <= fDrawableCount);
116 return fDrawableRefs[index - 1];
117 }
118
111 const SkPaint* getPaint(SkReader32* reader) const { 119 const SkPaint* getPaint(SkReader32* reader) const {
112 int index = reader->readInt(); 120 int index = reader->readInt();
113 if (index == 0) { 121 if (index == 0) {
114 return nullptr; 122 return nullptr;
115 } 123 }
116 return &fPaints[index - 1]; 124 return &fPaints[index - 1];
117 } 125 }
118 126
119 const SkTextBlob* getTextBlob(SkReader32* reader) const { 127 const SkTextBlob* getTextBlob(SkReader32* reader) const {
120 int index = reader->readInt(); 128 int index = reader->readInt();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 SkBitmap fBadBitmap; 163 SkBitmap fBadBitmap;
156 164
157 SkTArray<SkBitmap> fBitmaps; 165 SkTArray<SkBitmap> fBitmaps;
158 SkTArray<SkPaint> fPaints; 166 SkTArray<SkPaint> fPaints;
159 SkTArray<SkPath> fPaths; 167 SkTArray<SkPath> fPaths;
160 168
161 sk_sp<SkData> fOpData; // opcodes and parameters 169 sk_sp<SkData> fOpData; // opcodes and parameters
162 170
163 const SkPicture** fPictureRefs; 171 const SkPicture** fPictureRefs;
164 int fPictureCount; 172 int fPictureCount;
173 SkDrawable** fDrawableRefs;
174 int fDrawableCount;
165 const SkTextBlob** fTextBlobRefs; 175 const SkTextBlob** fTextBlobRefs;
166 int fTextBlobCount; 176 int fTextBlobCount;
167 const SkImage** fImageRefs; 177 const SkImage** fImageRefs;
168 int fImageCount; 178 int fImageCount;
169 179
170 SkPictureContentInfo fContentInfo; 180 SkPictureContentInfo fContentInfo;
171 181
172 SkTypefacePlayback fTFPlayback; 182 SkTypefacePlayback fTFPlayback;
173 SkFactoryPlayback* fFactoryPlayback; 183 SkFactoryPlayback* fFactoryPlayback;
174 184
175 const SkPictInfo fInfo; 185 const SkPictInfo fInfo;
176 186
177 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); 187 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec);
178 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); 188 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec);
179 189
180 void initForPlayback() const; 190 void initForPlayback() const;
181 }; 191 };
182 192
183 #endif 193 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698