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 #include <new> | 7 #include <new> |
8 #include "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkPicturePlayback.h" | 9 #include "SkPicturePlayback.h" |
10 #include "SkPictureRecord.h" | 10 #include "SkPictureRecord.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // copy over the refcnt dictionary to our reader | 122 // copy over the refcnt dictionary to our reader |
123 record.fFlattenableHeap.setupPlaybacks(); | 123 record.fFlattenableHeap.setupPlaybacks(); |
124 | 124 |
125 fBitmaps = record.fBitmapHeap->extractBitmaps(); | 125 fBitmaps = record.fBitmapHeap->extractBitmaps(); |
126 fPaints = record.fPaints.unflattenToArray(); | 126 fPaints = record.fPaints.unflattenToArray(); |
127 | 127 |
128 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); | 128 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); |
129 | 129 |
130 picture->initForPlayback(); | 130 picture->initForPlayback(); |
131 | 131 |
132 const SkTDArray<SkPicture* >& pictures = record.getPictureRefs(); | 132 const SkTDArray<const SkPicture* >& pictures = record.getPictureRefs(); |
133 fPictureCount = pictures.count(); | 133 fPictureCount = pictures.count(); |
134 if (fPictureCount > 0) { | 134 if (fPictureCount > 0) { |
135 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount); | 135 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); |
136 for (int i = 0; i < fPictureCount; i++) { | 136 for (int i = 0; i < fPictureCount; i++) { |
137 if (deepCopy) { | 137 if (deepCopy) { |
138 fPictureRefs[i] = pictures[i]->clone(); | 138 fPictureRefs[i] = pictures[i]->clone(); |
139 } else { | 139 } else { |
140 fPictureRefs[i] = pictures[i]; | 140 fPictureRefs[i] = pictures[i]; |
141 fPictureRefs[i]->ref(); | 141 fPictureRefs[i]->ref(); |
142 } | 142 } |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 fPaints->writableAt(i) = src.fPaints->at(i); | 203 fPaints->writableAt(i) = src.fPaints->at(i); |
204 } | 204 } |
205 } | 205 } |
206 | 206 |
207 } else { | 207 } else { |
208 fBitmaps = SkSafeRef(src.fBitmaps); | 208 fBitmaps = SkSafeRef(src.fBitmaps); |
209 fPaints = SkSafeRef(src.fPaints); | 209 fPaints = SkSafeRef(src.fPaints); |
210 } | 210 } |
211 | 211 |
212 fPictureCount = src.fPictureCount; | 212 fPictureCount = src.fPictureCount; |
213 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount); | 213 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); |
214 for (int i = 0; i < fPictureCount; i++) { | 214 for (int i = 0; i < fPictureCount; i++) { |
215 if (deepCopyInfo) { | 215 if (deepCopyInfo) { |
216 fPictureRefs[i] = src.fPictureRefs[i]->clone(); | 216 fPictureRefs[i] = src.fPictureRefs[i]->clone(); |
217 } else { | 217 } else { |
218 fPictureRefs[i] = src.fPictureRefs[i]; | 218 fPictureRefs[i] = src.fPictureRefs[i]; |
219 fPictureRefs[i]->ref(); | 219 fPictureRefs[i]->ref(); |
220 } | 220 } |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 if (!tf.get()) { // failed to deserialize | 498 if (!tf.get()) { // failed to deserialize |
499 // fTFPlayback asserts it never has a null, so we plop in | 499 // fTFPlayback asserts it never has a null, so we plop in |
500 // the default here. | 500 // the default here. |
501 tf.reset(SkTypeface::RefDefault()); | 501 tf.reset(SkTypeface::RefDefault()); |
502 } | 502 } |
503 fTFPlayback.set(i, tf); | 503 fTFPlayback.set(i, tf); |
504 } | 504 } |
505 } break; | 505 } break; |
506 case SK_PICT_PICTURE_TAG: { | 506 case SK_PICT_PICTURE_TAG: { |
507 fPictureCount = size; | 507 fPictureCount = size; |
508 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount); | 508 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); |
509 bool success = true; | 509 bool success = true; |
510 int i = 0; | 510 int i = 0; |
511 for ( ; i < fPictureCount; i++) { | 511 for ( ; i < fPictureCount; i++) { |
512 fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc); | 512 fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc); |
513 if (NULL == fPictureRefs[i]) { | 513 if (NULL == fPictureRefs[i]) { |
514 success = false; | 514 success = false; |
515 break; | 515 break; |
516 } | 516 } |
517 } | 517 } |
518 if (!success) { | 518 if (!success) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 return false; | 583 return false; |
584 } | 584 } |
585 SkASSERT(NULL == fOpData); | 585 SkASSERT(NULL == fOpData); |
586 fOpData = SkData::NewFromMalloc(storage.detach(), size); | 586 fOpData = SkData::NewFromMalloc(storage.detach(), size); |
587 } break; | 587 } break; |
588 case SK_PICT_PICTURE_TAG: { | 588 case SK_PICT_PICTURE_TAG: { |
589 if (!buffer.validate((0 == fPictureCount) && (NULL == fPictureRefs))
) { | 589 if (!buffer.validate((0 == fPictureCount) && (NULL == fPictureRefs))
) { |
590 return false; | 590 return false; |
591 } | 591 } |
592 fPictureCount = size; | 592 fPictureCount = size; |
593 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount); | 593 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); |
594 bool success = true; | 594 bool success = true; |
595 int i = 0; | 595 int i = 0; |
596 for ( ; i < fPictureCount; i++) { | 596 for ( ; i < fPictureCount; i++) { |
597 fPictureRefs[i] = SkPicture::CreateFromBuffer(buffer); | 597 fPictureRefs[i] = SkPicture::CreateFromBuffer(buffer); |
598 if (NULL == fPictureRefs[i]) { | 598 if (NULL == fPictureRefs[i]) { |
599 success = false; | 599 success = false; |
600 break; | 600 break; |
601 } | 601 } |
602 } | 602 } |
603 if (!success) { | 603 if (!success) { |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 for (index = 0; index < fPictureCount; index++) | 1838 for (index = 0; index < fPictureCount; index++) |
1839 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), | 1839 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), |
1840 "picture%p, ", fPictureRefs[index]); | 1840 "picture%p, ", fPictureRefs[index]); |
1841 if (fPictureCount > 0) | 1841 if (fPictureCount > 0) |
1842 SkDebugf("%s0};\n", pBuffer); | 1842 SkDebugf("%s0};\n", pBuffer); |
1843 | 1843 |
1844 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1844 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
1845 } | 1845 } |
1846 | 1846 |
1847 #endif | 1847 #endif |
OLD | NEW |