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

Side by Side Diff: src/utils/SkPictureUtils.cpp

Issue 490253003: Implement SkPicture::bytesUsed() for SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More tweaks for object size Created 6 years, 1 month 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/SkTileGrid.cpp ('k') | tests/PictureTest.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 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
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 struct MeasureRecords {
222 template <typename T> size_t operator()(const T& op) { return 0; }
223 size_t operator()(const SkRecords::DrawPicture& op) {
224 return SkPictureUtils::ApproximateBytesUsed(op.picture);
225 }
226 };
227
228 size_t SkPictureUtils::ApproximateBytesUsed(const SkPicture* pict) {
229 size_t byteCount = sizeof(*pict);
230
231 byteCount += pict->fRecord->bytesUsed();
232 if (pict->fBBH.get()) {
233 byteCount += pict->fBBH->bytesUsed();
234 }
235 byteCount +=
236 pict->fDeletionListeners.reserved() * sizeof(SkPicture::DeletionListener *) +
237 pict->fDeletionListeners.count() * sizeof(SkPicture::DeletionListener);
238
239 MeasureRecords visitor;
240 for (unsigned curOp = 0; curOp < pict->fRecord->count(); curOp++) {
241 byteCount += pict->fRecord->visit<size_t>(curOp, visitor);
242 }
243
244 return byteCount;
245 }
OLDNEW
« no previous file with comments | « src/core/SkTileGrid.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698