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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 | 52 |
53 SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, const SkPictInfo& info) | 53 SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, const SkPictInfo& info) |
54 : fPicture(picture) | 54 : fPicture(picture) |
55 , fInfo(info) { | 55 , fInfo(info) { |
56 this->init(); | 56 this->init(); |
57 } | 57 } |
58 | 58 |
59 SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, | 59 SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, |
60 const SkPictureRecord& record, | 60 const SkPictureRecord& record, |
61 const SkPictInfo& info, | 61 const SkPictInfo& info, |
62 bool deepCopy) | 62 bool deepCopyOps) |
63 : fPicture(picture) | 63 : fPicture(picture) |
64 , fInfo(info) { | 64 , fInfo(info) { |
65 #ifdef SK_DEBUG_SIZE | 65 #ifdef SK_DEBUG_SIZE |
66 size_t overallBytes, bitmapBytes, matricesBytes, | 66 size_t overallBytes, bitmapBytes, matricesBytes, |
67 paintBytes, pathBytes, pictureBytes, regionBytes; | 67 paintBytes, pathBytes, pictureBytes, regionBytes; |
68 int bitmaps = record.bitmaps(&bitmapBytes); | 68 int bitmaps = record.bitmaps(&bitmapBytes); |
69 int matrices = record.matrices(&matricesBytes); | 69 int matrices = record.matrices(&matricesBytes); |
70 int paints = record.paints(&paintBytes); | 70 int paints = record.paints(&paintBytes); |
71 int paths = record.paths(&pathBytes); | 71 int paths = record.paths(&pathBytes); |
72 int pictures = record.pictures(&pictureBytes); | 72 int pictures = record.pictures(&pictureBytes); |
(...skipping 27 matching lines...) Expand all Loading... | |
100 #endif | 100 #endif |
101 | 101 |
102 record.validate(record.writeStream().bytesWritten(), 0); | 102 record.validate(record.writeStream().bytesWritten(), 0); |
103 const SkWriter32& writer = record.writeStream(); | 103 const SkWriter32& writer = record.writeStream(); |
104 this->init(); | 104 this->init(); |
105 SkASSERT(!fOpData); | 105 SkASSERT(!fOpData); |
106 if (writer.bytesWritten() == 0) { | 106 if (writer.bytesWritten() == 0) { |
107 fOpData = SkData::NewEmpty(); | 107 fOpData = SkData::NewEmpty(); |
108 return; | 108 return; |
109 } | 109 } |
110 fOpData = writer.snapshotAsData(); | 110 if (deepCopyOps) { |
111 // Don't try to do anything clever w.r.t. copy on write | |
112 fOpData = SkData::NewWithCopy(writer.contiguousArray(), writer.bytesWrit ten()); | |
reed1
2014/06/10 12:29:03
I presume this continuousArray() call can mutate t
robertphillips
2014/06/10 17:26:28
Right now SkWriter32 does store its data contiguou
| |
113 } else { | |
114 fOpData = writer.snapshotAsData(); | |
115 } | |
111 | 116 |
112 fBoundingHierarchy = record.fBoundingHierarchy; | 117 fBoundingHierarchy = record.fBoundingHierarchy; |
113 fStateTree = record.fStateTree; | 118 fStateTree = record.fStateTree; |
114 | 119 |
115 SkSafeRef(fBoundingHierarchy); | 120 SkSafeRef(fBoundingHierarchy); |
116 SkSafeRef(fStateTree); | 121 SkSafeRef(fStateTree); |
117 | 122 |
118 if (NULL != fBoundingHierarchy) { | 123 if (NULL != fBoundingHierarchy) { |
119 fBoundingHierarchy->flushDeferredInserts(); | 124 fBoundingHierarchy->flushDeferredInserts(); |
120 } | 125 } |
121 | 126 |
122 // copy over the refcnt dictionary to our reader | 127 // copy over the refcnt dictionary to our reader |
123 record.fFlattenableHeap.setupPlaybacks(); | 128 record.fFlattenableHeap.setupPlaybacks(); |
124 | 129 |
125 fBitmaps = record.fBitmapHeap->extractBitmaps(); | 130 fBitmaps = record.fBitmapHeap->extractBitmaps(); |
126 fPaints = record.fPaints.unflattenToArray(); | 131 fPaints = record.fPaints.unflattenToArray(); |
127 | 132 |
128 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); | 133 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); |
129 | 134 |
130 picture->initForPlayback(); | 135 picture->initForPlayback(); |
131 | 136 |
132 const SkTDArray<const SkPicture* >& pictures = record.getPictureRefs(); | 137 const SkTDArray<const SkPicture* >& pictures = record.getPictureRefs(); |
133 fPictureCount = pictures.count(); | 138 fPictureCount = pictures.count(); |
134 if (fPictureCount > 0) { | 139 if (fPictureCount > 0) { |
135 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); | 140 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); |
136 for (int i = 0; i < fPictureCount; i++) { | 141 for (int i = 0; i < fPictureCount; i++) { |
137 if (deepCopy) { | 142 fPictureRefs[i] = pictures[i]; |
138 fPictureRefs[i] = pictures[i]->clone(); | 143 fPictureRefs[i]->ref(); |
scroggo
2014/06/10 13:31:25
Why this change? deepCopy is used when we are clon
robertphillips
2014/06/10 17:26:28
TL;DR - this change has been split off into: (Remo
| |
139 } else { | |
140 fPictureRefs[i] = pictures[i]; | |
141 fPictureRefs[i]->ref(); | |
142 } | |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
146 #ifdef SK_DEBUG_SIZE | 147 #ifdef SK_DEBUG_SIZE |
147 int overall = fPlayback->size(&overallBytes); | 148 int overall = fPlayback->size(&overallBytes); |
148 bitmaps = fPlayback->bitmaps(&bitmapBytes); | 149 bitmaps = fPlayback->bitmaps(&bitmapBytes); |
149 paints = fPlayback->paints(&paintBytes); | 150 paints = fPlayback->paints(&paintBytes); |
150 paths = fPlayback->paths(&pathBytes); | 151 paths = fPlayback->paths(&pathBytes); |
151 pictures = fPlayback->pictures(&pictureBytes); | 152 pictures = fPlayback->pictures(&pictureBytes); |
152 regions = fPlayback->regions(®ionBytes); | 153 regions = fPlayback->regions(®ionBytes); |
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1838 for (index = 0; index < fPictureCount; index++) | 1839 for (index = 0; index < fPictureCount; index++) |
1839 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), | 1840 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), |
1840 "picture%p, ", fPictureRefs[index]); | 1841 "picture%p, ", fPictureRefs[index]); |
1841 if (fPictureCount > 0) | 1842 if (fPictureCount > 0) |
1842 SkDebugf("%s0};\n", pBuffer); | 1843 SkDebugf("%s0};\n", pBuffer); |
1843 | 1844 |
1844 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1845 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
1845 } | 1846 } |
1846 | 1847 |
1847 #endif | 1848 #endif |
OLD | NEW |