| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 /* Define this to spew out a debug statement whenever we skip the remainder of | 22 /* Define this to spew out a debug statement whenever we skip the remainder of |
| 23 a save/restore block because a clip... command returned false (empty). | 23 a save/restore block because a clip... command returned false (empty). |
| 24 */ | 24 */ |
| 25 #define SPEW_CLIP_SKIPPINGx | 25 #define SPEW_CLIP_SKIPPINGx |
| 26 | 26 |
| 27 SkPicturePlayback::SkPicturePlayback() { | 27 SkPicturePlayback::SkPicturePlayback() { |
| 28 this->init(); | 28 this->init(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record, bool deepCop
y) { | 31 SkPicturePlayback::SkPicturePlayback(SkPictureRecord& record, bool deepCopy) { |
| 32 #ifdef SK_DEBUG_SIZE | 32 #ifdef SK_DEBUG_SIZE |
| 33 size_t overallBytes, bitmapBytes, matricesBytes, | 33 size_t overallBytes, bitmapBytes, matricesBytes, |
| 34 paintBytes, pathBytes, pictureBytes, regionBytes; | 34 paintBytes, pathBytes, pictureBytes, regionBytes; |
| 35 int bitmaps = record.bitmaps(&bitmapBytes); | 35 int bitmaps = record.bitmaps(&bitmapBytes); |
| 36 int matrices = record.matrices(&matricesBytes); | 36 int matrices = record.matrices(&matricesBytes); |
| 37 int paints = record.paints(&paintBytes); | 37 int paints = record.paints(&paintBytes); |
| 38 int paths = record.paths(&pathBytes); | 38 int paths = record.paths(&pathBytes); |
| 39 int pictures = record.pictures(&pictureBytes); | 39 int pictures = record.pictures(&pictureBytes); |
| 40 int regions = record.regions(®ionBytes); | 40 int regions = record.regions(®ionBytes); |
| 41 SkDebugf("picture record mem used %zd (stream %zd) ", record.size(), | 41 SkDebugf("picture record mem used %zd (stream %zd) ", record.size(), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 SkDebugf("text size %zd (text strings:%d) ", record.fTextBytes, record.f
TextWrites); | 60 SkDebugf("text size %zd (text strings:%d) ", record.fTextBytes, record.f
TextWrites); |
| 61 | 61 |
| 62 SkDebugf("\n"); | 62 SkDebugf("\n"); |
| 63 #endif | 63 #endif |
| 64 #ifdef SK_DEBUG_DUMP | 64 #ifdef SK_DEBUG_DUMP |
| 65 record.dumpMatrices(); | 65 record.dumpMatrices(); |
| 66 record.dumpPaints(); | 66 record.dumpPaints(); |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 record.validate(record.writeStream().bytesWritten(), 0); | 69 record.validate(record.writeStream().bytesWritten(), 0); |
| 70 const SkWriter32& writer = record.writeStream(); | 70 SkWriter32& writer = record.writeStream(); |
| 71 init(); | 71 init(); |
| 72 if (writer.bytesWritten() == 0) { | 72 if (writer.bytesWritten() == 0) { |
| 73 fOpData = SkData::NewEmpty(); | 73 fOpData = SkData::NewEmpty(); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 fBoundingHierarchy = record.fBoundingHierarchy; | 77 fBoundingHierarchy = record.fBoundingHierarchy; |
| 78 fStateTree = record.fStateTree; | 78 fStateTree = record.fStateTree; |
| 79 | 79 |
| 80 SkSafeRef(fBoundingHierarchy); | 80 SkSafeRef(fBoundingHierarchy); |
| 81 SkSafeRef(fStateTree); | 81 SkSafeRef(fStateTree); |
| 82 | 82 |
| 83 if (NULL != fBoundingHierarchy) { | 83 if (NULL != fBoundingHierarchy) { |
| 84 fBoundingHierarchy->flushDeferredInserts(); | 84 fBoundingHierarchy->flushDeferredInserts(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 { | 87 { |
| 88 size_t size = writer.bytesWritten(); | |
| 89 void* buffer = sk_malloc_throw(size); | |
| 90 writer.flatten(buffer); | |
| 91 SkASSERT(!fOpData); | 88 SkASSERT(!fOpData); |
| 92 fOpData = SkData::NewFromMalloc(buffer, size); | 89 fOpData = writer.detatchAsData(); |
| 93 } | 90 } |
| 94 | 91 |
| 95 // copy over the refcnt dictionary to our reader | 92 // copy over the refcnt dictionary to our reader |
| 96 record.fFlattenableHeap.setupPlaybacks(); | 93 record.fFlattenableHeap.setupPlaybacks(); |
| 97 | 94 |
| 98 fBitmaps = record.fBitmapHeap->extractBitmaps(); | 95 fBitmaps = record.fBitmapHeap->extractBitmaps(); |
| 99 fPaints = record.fPaints.unflattenToArray(); | 96 fPaints = record.fPaints.unflattenToArray(); |
| 100 | 97 |
| 101 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); | 98 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); |
| 102 fPathHeap.reset(SkSafeRef(record.fPathHeap)); | 99 fPathHeap.reset(SkSafeRef(record.fPathHeap)); |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 for (index = 0; index < fPictureCount; index++) | 1587 for (index = 0; index < fPictureCount; index++) |
| 1591 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), | 1588 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), |
| 1592 "picture%p, ", fPictureRefs[index]); | 1589 "picture%p, ", fPictureRefs[index]); |
| 1593 if (fPictureCount > 0) | 1590 if (fPictureCount > 0) |
| 1594 SkDebugf("%s0};\n", pBuffer); | 1591 SkDebugf("%s0};\n", pBuffer); |
| 1595 | 1592 |
| 1596 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1593 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
| 1597 } | 1594 } |
| 1598 | 1595 |
| 1599 #endif | 1596 #endif |
| OLD | NEW |