| 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 "SkDrawPictureCallback.h" | 9 #include "SkDrawPictureCallback.h" |
| 10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 const SkTDArray<const SkTextBlob*>& blobs = record.getTextBlobRefs(); | 82 const SkTDArray<const SkTextBlob*>& blobs = record.getTextBlobRefs(); |
| 83 fTextBlobCount = blobs.count(); | 83 fTextBlobCount = blobs.count(); |
| 84 if (fTextBlobCount > 0) { | 84 if (fTextBlobCount > 0) { |
| 85 fTextBlobRefs = SkNEW_ARRAY(const SkTextBlob*, fTextBlobCount); | 85 fTextBlobRefs = SkNEW_ARRAY(const SkTextBlob*, fTextBlobCount); |
| 86 for (int i = 0; i < fTextBlobCount; ++i) { | 86 for (int i = 0; i < fTextBlobCount; ++i) { |
| 87 fTextBlobRefs[i] = SkRef(blobs[i]); | 87 fTextBlobRefs[i] = SkRef(blobs[i]); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | |
| 93 SkPictureData::SkPictureData(const SkPictureData& src, SkPictCopyInfo* deepCopyI
nfo) | |
| 94 : fInfo(src.fInfo) { | |
| 95 this->init(); | |
| 96 | |
| 97 fBitmapHeap.reset(SkSafeRef(src.fBitmapHeap.get())); | |
| 98 fPathHeap.reset(SkSafeRef(src.fPathHeap.get())); | |
| 99 | |
| 100 fOpData = SkSafeRef(src.fOpData); | |
| 101 | |
| 102 fBoundingHierarchy = src.fBoundingHierarchy; | |
| 103 fStateTree = src.fStateTree; | |
| 104 fContentInfo.set(src.fContentInfo); | |
| 105 | |
| 106 SkSafeRef(fBoundingHierarchy); | |
| 107 SkSafeRef(fStateTree); | |
| 108 | |
| 109 if (deepCopyInfo) { | |
| 110 int paintCount = SafeCount(src.fPaints); | |
| 111 | |
| 112 if (src.fBitmaps) { | |
| 113 fBitmaps = SkTRefArray<SkBitmap>::Create(src.fBitmaps->begin(), src.
fBitmaps->count()); | |
| 114 } | |
| 115 | |
| 116 fPaints = SkTRefArray<SkPaint>::Create(paintCount); | |
| 117 SkASSERT(deepCopyInfo->paintData.count() == paintCount); | |
| 118 SkBitmapHeap* bmHeap = deepCopyInfo->controller.getBitmapHeap(); | |
| 119 SkTypefacePlayback* tfPlayback = deepCopyInfo->controller.getTypefacePla
yback(); | |
| 120 for (int i = 0; i < paintCount; i++) { | |
| 121 if (deepCopyInfo->paintData[i]) { | |
| 122 deepCopyInfo->paintData[i]->unflatten<SkPaintFlatteningTraits>( | |
| 123 &fPaints->writableAt(i), bmHeap, tfPlayback); | |
| 124 } else { | |
| 125 // needs_deep_copy was false, so just need to assign | |
| 126 fPaints->writableAt(i) = src.fPaints->at(i); | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 } else { | |
| 131 fBitmaps = SkSafeRef(src.fBitmaps); | |
| 132 fPaints = SkSafeRef(src.fPaints); | |
| 133 } | |
| 134 | |
| 135 fPictureCount = src.fPictureCount; | |
| 136 fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount); | |
| 137 for (int i = 0; i < fPictureCount; i++) { | |
| 138 if (deepCopyInfo) { | |
| 139 fPictureRefs[i] = src.fPictureRefs[i]->clone(); | |
| 140 } else { | |
| 141 fPictureRefs[i] = src.fPictureRefs[i]; | |
| 142 fPictureRefs[i]->ref(); | |
| 143 } | |
| 144 } | |
| 145 } | |
| 146 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE | |
| 147 | |
| 148 void SkPictureData::init() { | 92 void SkPictureData::init() { |
| 149 fBitmaps = NULL; | 93 fBitmaps = NULL; |
| 150 fPaints = NULL; | 94 fPaints = NULL; |
| 151 fPictureRefs = NULL; | 95 fPictureRefs = NULL; |
| 152 fPictureCount = 0; | 96 fPictureCount = 0; |
| 153 fTextBlobRefs = NULL; | 97 fTextBlobRefs = NULL; |
| 154 fTextBlobCount = 0; | 98 fTextBlobCount = 0; |
| 155 fOpData = NULL; | 99 fOpData = NULL; |
| 156 fFactoryPlayback = NULL; | 100 fFactoryPlayback = NULL; |
| 157 fBoundingHierarchy = NULL; | 101 fBoundingHierarchy = NULL; |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 605 } |
| 662 } | 606 } |
| 663 | 607 |
| 664 bool SkPictureData::suitableForLayerOptimization() const { | 608 bool SkPictureData::suitableForLayerOptimization() const { |
| 665 return fContentInfo.numLayers() > 0; | 609 return fContentInfo.numLayers() > 0; |
| 666 } | 610 } |
| 667 #endif | 611 #endif |
| 668 /////////////////////////////////////////////////////////////////////////////// | 612 /////////////////////////////////////////////////////////////////////////////// |
| 669 | 613 |
| 670 | 614 |
| OLD | NEW |