OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkPicturePlayback.h" | 8 #include "SkPicturePlayback.h" |
9 #include "SkPictureRecord.h" | 9 #include "SkPictureRecord.h" |
10 #include "SkTypeface.h" | 10 #include "SkTypeface.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 SkBitmapHeap* heap = SkNEW(SkBitmapHeap); | 205 SkBitmapHeap* heap = SkNEW(SkBitmapHeap); |
206 deepCopyInfo->controller.setBitmapStorage(heap); | 206 deepCopyInfo->controller.setBitmapStorage(heap); |
207 heap->unref(); | 207 heap->unref(); |
208 } else { | 208 } else { |
209 deepCopyInfo->controller.setBitmapStorage(fBitmapHeap); | 209 deepCopyInfo->controller.setBitmapStorage(fBitmapHeap); |
210 } | 210 } |
211 | 211 |
212 SkDEBUGCODE(int heapSize = SafeCount(fBitmapHeap.get());) | 212 SkDEBUGCODE(int heapSize = SafeCount(fBitmapHeap.get());) |
213 for (int i = 0; i < paintCount; i++) { | 213 for (int i = 0; i < paintCount; i++) { |
214 if (needs_deep_copy(src.fPaints->at(i))) { | 214 if (needs_deep_copy(src.fPaints->at(i))) { |
215 deepCopyInfo->paintData[i] = SkFlatData::Create(&deepCopyInf
o->controller, | 215 deepCopyInfo->paintData[i] = |
216 &src.fPaints
->at(i), 0, | 216 SkFlatData::Create<SkPaintTraits>(&deepCopyInfo->control
ler, |
217 &SkFlattenOb
jectProc<SkPaint>); | 217 src.fPaints->at(i), 0)
; |
| 218 |
218 } else { | 219 } else { |
219 // this is our sentinel, which we use in the unflatten loop | 220 // this is our sentinel, which we use in the unflatten loop |
220 deepCopyInfo->paintData[i] = NULL; | 221 deepCopyInfo->paintData[i] = NULL; |
221 } | 222 } |
222 } | 223 } |
223 SkASSERT(SafeCount(fBitmapHeap.get()) == heapSize); | 224 SkASSERT(SafeCount(fBitmapHeap.get()) == heapSize); |
224 | 225 |
225 // needed to create typeface playback | 226 // needed to create typeface playback |
226 deepCopyInfo->controller.setupPlaybacks(); | 227 deepCopyInfo->controller.setupPlaybacks(); |
227 deepCopyInfo->initialized = true; | 228 deepCopyInfo->initialized = true; |
228 } | 229 } |
229 | 230 |
230 fPaints = SkTRefArray<SkPaint>::Create(paintCount); | 231 fPaints = SkTRefArray<SkPaint>::Create(paintCount); |
231 SkASSERT(deepCopyInfo->paintData.count() == paintCount); | 232 SkASSERT(deepCopyInfo->paintData.count() == paintCount); |
232 SkBitmapHeap* bmHeap = deepCopyInfo->controller.getBitmapHeap(); | 233 SkBitmapHeap* bmHeap = deepCopyInfo->controller.getBitmapHeap(); |
233 SkTypefacePlayback* tfPlayback = deepCopyInfo->controller.getTypefacePla
yback(); | 234 SkTypefacePlayback* tfPlayback = deepCopyInfo->controller.getTypefacePla
yback(); |
234 for (int i = 0; i < paintCount; i++) { | 235 for (int i = 0; i < paintCount; i++) { |
235 if (deepCopyInfo->paintData[i]) { | 236 if (deepCopyInfo->paintData[i]) { |
236 deepCopyInfo->paintData[i]->unflatten(&fPaints->writableAt(i), | 237 deepCopyInfo->paintData[i]->unflatten<SkPaintTraits>(&fPaints->w
ritableAt(i), |
237 &SkUnflattenObjectProc<SkP
aint>, | 238 bmHeap, tfP
layback); |
238 bmHeap, tfPlayback); | |
239 } else { | 239 } else { |
240 // needs_deep_copy was false, so just need to assign | 240 // needs_deep_copy was false, so just need to assign |
241 fPaints->writableAt(i) = src.fPaints->at(i); | 241 fPaints->writableAt(i) = src.fPaints->at(i); |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 } else { | 245 } else { |
246 fBitmaps = SkSafeRef(src.fBitmaps); | 246 fBitmaps = SkSafeRef(src.fBitmaps); |
247 fPaints = SkSafeRef(src.fPaints); | 247 fPaints = SkSafeRef(src.fPaints); |
248 } | 248 } |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 for (index = 0; index < fRegionCount; index++) | 1667 for (index = 0; index < fRegionCount; index++) |
1668 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), | 1668 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), |
1669 "region%p, ", &fRegions[index]); | 1669 "region%p, ", &fRegions[index]); |
1670 if (fRegionCount > 0) | 1670 if (fRegionCount > 0) |
1671 SkDebugf("%s0};\n", pBuffer); | 1671 SkDebugf("%s0};\n", pBuffer); |
1672 | 1672 |
1673 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1673 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
1674 } | 1674 } |
1675 | 1675 |
1676 #endif | 1676 #endif |
OLD | NEW |