| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 7 |
| 8 #include "SkBBoxHierarchy.h" |
| 8 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
| 9 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 11 #include "SkData.h" |
| 11 #include "SkNoSaveLayerCanvas.h" | 12 #include "SkNoSaveLayerCanvas.h" |
| 12 #include "SkPictureUtils.h" | 13 #include "SkPictureUtils.h" |
| 13 #include "SkPixelRef.h" | 14 #include "SkPixelRef.h" |
| 14 #include "SkRRect.h" | 15 #include "SkRRect.h" |
| 16 #include "SkRecord.h" |
| 15 #include "SkShader.h" | 17 #include "SkShader.h" |
| 16 | 18 |
| 17 class PixelRefSet { | 19 class PixelRefSet { |
| 18 public: | 20 public: |
| 19 PixelRefSet(SkTDArray<SkPixelRef*>* array) : fArray(array) {} | 21 PixelRefSet(SkTDArray<SkPixelRef*>* array) : fArray(array) {} |
| 20 | 22 |
| 21 // This does a linear search on existing pixelrefs, so if this list gets big | 23 // This does a linear search on existing pixelrefs, so if this list gets big |
| 22 // we should use a more complex sorted/hashy thing. | 24 // we should use a more complex sorted/hashy thing. |
| 23 // | 25 // |
| 24 void add(SkPixelRef* pr) { | 26 void add(SkPixelRef* pr) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 canvas.clipRect(area, SkRegion::kIntersect_Op, false); | 210 canvas.clipRect(area, SkRegion::kIntersect_Op, false); |
| 209 canvas.drawPicture(pict); | 211 canvas.drawPicture(pict); |
| 210 | 212 |
| 211 SkData* data = NULL; | 213 SkData* data = NULL; |
| 212 int count = array.count(); | 214 int count = array.count(); |
| 213 if (count > 0) { | 215 if (count > 0) { |
| 214 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*)
); | 216 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*)
); |
| 215 } | 217 } |
| 216 return data; | 218 return data; |
| 217 } | 219 } |
| 220 |
| 221 size_t SkPictureUtils::ApproximateBytesUsed(const SkPicture* pict) { |
| 222 size_t byteCount = sizeof(*pict); |
| 223 |
| 224 byteCount += pict->fRecord->bytesUsed(); |
| 225 if (pict->fBBH.get()) { |
| 226 byteCount += pict->fBBH->bytesUsed(); |
| 227 } |
| 228 byteCount += |
| 229 pict->fDeletionListeners.reserved() * sizeof(SkPicture::DeletionListener
*) + |
| 230 pict->fDeletionListeners.count() * sizeof(SkPicture::DeletionListener); |
| 231 return byteCount; |
| 232 } |
| OLD | NEW |