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

Side by Side Diff: src/core/SkPicturePlayback.cpp

Issue 316063005: Fix error revealed by Android unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix typo Created 6 years, 6 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
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #endif 51 #endif
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 deepCopyOps)
62 : fPicture(picture) 63 : fPicture(picture)
63 , fInfo(info) { 64 , fInfo(info) {
64 #ifdef SK_DEBUG_SIZE 65 #ifdef SK_DEBUG_SIZE
65 size_t overallBytes, bitmapBytes, matricesBytes, 66 size_t overallBytes, bitmapBytes, matricesBytes,
66 paintBytes, pathBytes, pictureBytes, regionBytes; 67 paintBytes, pathBytes, pictureBytes, regionBytes;
67 int bitmaps = record.bitmaps(&bitmapBytes); 68 int bitmaps = record.bitmaps(&bitmapBytes);
68 int matrices = record.matrices(&matricesBytes); 69 int matrices = record.matrices(&matricesBytes);
69 int paints = record.paints(&paintBytes); 70 int paints = record.paints(&paintBytes);
70 int paths = record.paths(&pathBytes); 71 int paths = record.paths(&pathBytes);
71 int pictures = record.pictures(&pictureBytes); 72 int pictures = record.pictures(&pictureBytes);
(...skipping 27 matching lines...) Expand all
99 #endif 100 #endif
100 101
101 record.validate(record.writeStream().bytesWritten(), 0); 102 record.validate(record.writeStream().bytesWritten(), 0);
102 const SkWriter32& writer = record.writeStream(); 103 const SkWriter32& writer = record.writeStream();
103 this->init(); 104 this->init();
104 SkASSERT(!fOpData); 105 SkASSERT(!fOpData);
105 if (writer.bytesWritten() == 0) { 106 if (writer.bytesWritten() == 0) {
106 fOpData = SkData::NewEmpty(); 107 fOpData = SkData::NewEmpty();
107 return; 108 return;
108 } 109 }
109 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());
113 } else {
114 fOpData = writer.snapshotAsData();
115 }
110 116
111 fBoundingHierarchy = record.fBoundingHierarchy; 117 fBoundingHierarchy = record.fBoundingHierarchy;
112 fStateTree = record.fStateTree; 118 fStateTree = record.fStateTree;
113 119
114 SkSafeRef(fBoundingHierarchy); 120 SkSafeRef(fBoundingHierarchy);
115 SkSafeRef(fStateTree); 121 SkSafeRef(fStateTree);
116 122
117 if (NULL != fBoundingHierarchy) { 123 if (NULL != fBoundingHierarchy) {
118 fBoundingHierarchy->flushDeferredInserts(); 124 fBoundingHierarchy->flushDeferredInserts();
119 } 125 }
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 for (index = 0; index < fPictureCount; index++) 1839 for (index = 0; index < fPictureCount; index++)
1834 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1840 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1835 "picture%p, ", fPictureRefs[index]); 1841 "picture%p, ", fPictureRefs[index]);
1836 if (fPictureCount > 0) 1842 if (fPictureCount > 0)
1837 SkDebugf("%s0};\n", pBuffer); 1843 SkDebugf("%s0};\n", pBuffer);
1838 1844
1839 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1845 const_cast<SkPicturePlayback*>(this)->dumpStream();
1840 } 1846 }
1841 1847
1842 #endif 1848 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698