Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 canvas.clipRect(area, SkRegion::kIntersect_Op, false); | 213 canvas.clipRect(area, SkRegion::kIntersect_Op, false); |
| 212 canvas.drawPicture(pict); | 214 canvas.drawPicture(pict); |
| 213 | 215 |
| 214 SkData* data = NULL; | 216 SkData* data = NULL; |
| 215 int count = array.count(); | 217 int count = array.count(); |
| 216 if (count > 0) { | 218 if (count > 0) { |
| 217 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*) ); | 219 data = SkData::NewFromMalloc(array.detach(), count * sizeof(SkPixelRef*) ); |
| 218 } | 220 } |
| 219 return data; | 221 return data; |
| 220 } | 222 } |
| 223 | |
| 224 size_t SkPictureUtils::approximateBytesUsed(const SkPicture* pict) { | |
| 225 size_t byteCount = sizeof(*pict); | |
| 226 | |
| 227 // No support for old SkPicture backend | |
| 228 if (!pict->fRecord.get()) { | |
|
mtklein
2014/11/17 20:19:32
You can assume fRecord now.
| |
| 229 return 0; | |
| 230 } | |
| 231 | |
| 232 byteCount += pict->fRecord->bytesUsed(); | |
| 233 if (pict->fBBH.get()) { | |
| 234 byteCount += pict->fBBH->bytesUsed(); | |
| 235 } | |
| 236 return byteCount; | |
| 237 } | |
| 238 | |
| 239 | |
| OLD | NEW |