22 SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
60 record.validate();
61 const SkWriter32& writer = record.writeStream();
62 init();
63 if (writer.size() == 0)
64 return;
65
66 {
67 size_t size = writer.size();
68 void* buffer = sk_malloc_throw(size);
69 writer.flatten(buffer);
70 fReader.setMemory(buffer, size);
71 }
72
73
74
75 fRCPlayback.reset(&record.fRCSet); <================
76 fRCPlayback.setupBuffer(fReader);
77
78 fTFPlayback.reset(&record.fTFSet);
79 fTFPlayback.setupBuffer(fReader);
80
81 const SkTDArray<const SkFlatBitmap* >& bitmaps = record.getBitmaps();
82 fBitmapCount = bitmaps.count();
83 if (fBitmapCount > 0) {
84 fBitmaps = SkNEW_ARRAY(SkBitmap, fBitmapCount);
85 for (const SkFlatBitmap** flatBitmapPtr = bitmaps.begin();
86 flatBitmapPtr != bitmaps.end(); flatBitmapPtr++) {
87 const SkFlatBitmap* flatBitmap = *flatBitmapPtr;
88 int index = flatBitmap->index() - 1;
89 flatBitmap->unflatten(&fBitmaps[index], &fRCPlayback);
90 }
91 }
92
93 const SkTDArray<const SkFlatMatrix* >& matrices = record.getMatrices();
94 fMatrixCount = matrices.count();
95 if (fMatrixCount > 0) {
96 fMatrices = SkNEW_ARRAY(SkMatrix, fMatrixCount);
97 for (const SkFlatMatrix** matrixPtr = matrices.begin();
98 matrixPtr != matrices.end(); matrixPtr++) {
99 const SkFlatMatrix* flatMatrix = *matrixPtr;
100 flatMatrix->unflatten(&fMatrices[flatMatrix->index() - 1]);
101 }
102 }
103
104 const SkTDArray<const SkFlatPaint* >& paints = record.getPaints();
105 fPaintCount = paints.count();
106 if (fPaintCount > 0) {
107 fPaints = SkNEW_ARRAY(SkPaint, fPaintCount);
108 for (const SkFlatPaint** flatPaintPtr = paints.begin();
109 flatPaintPtr != paints.end(); flatPaintPtr++) {
110 const SkFlatPaint* flatPaint = *flatPaintPtr;
111 int index = flatPaint->index() - 1;
112 SkASSERT((unsigned)index < (unsigned)fPaintCount);
113 flatPaint->unflatten(&fPaints[index], &fRCPlayback, &fTFPlayback);
114 }
115 }
116
117 fPathHeap = record.fPathHeap;
118 SkSafeRef(fPathHeap);
119
120 const SkTDArray<SkPicture* >& pictures = record.getPictureRefs();
121 fPictureCount = pictures.count();
122 if (fPictureCount > 0) {
123 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
124 for (int i = 0; i < fPictureCount; i++) {
125 fPictureRefs[i] = pictures[i];
126 fPictureRefs[i]->ref();
127 }
128 }
129
130 const SkTDArray<const SkFlatRegion* >& regions = record.getRegions();
131 fRegionCount = regions.count();
132 if (fRegionCount > 0) {
133 fRegions = SkNEW_ARRAY(SkRegion, fRegionCount);
134 for (const SkFlatRegion** flatRegionPtr = regions.begin();
135 flatRegionPtr != regions.end(); flatRegionPtr++) {
136 const SkFlatRegion* flatRegion = *flatRegionPtr;
137 flatRegion->unflatten(&fRegions[flatRegion->index() - 1]);
138 }
139 }
140
161 }
30 class SkPicturePlayback {
159 private:
160 SkPathHeap* fPathHeap;
161 SkBitmap* fBitmaps;
162 int fBitmapCount;
163 SkMatrix* fMatrices;
164 int fMatrixCount;
165 SkPaint* fPaints;
166 int fPaintCount;
167 SkRegion* fRegions;
168 int fRegionCount;
169 mutable SkFlattenableReadBuffer fReader;
170
171 SkPicture** fPictureRefs;
172 int fPictureCount;
173
174 SkRefCntPlayback fRCPlayback; <===========
175 SkTypefacePlayback fTFPlayback;
176 SkFactoryPlayback* fFactoryPlayback;
177 #ifdef SK_BUILD_FOR_ANDROID
178 SkMutex fDrawMutex;
179 #endif
180 };