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

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

Issue 1090943004: O(1) SkPictureUtils::ApproxBytesUsed() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 5 years, 8 months 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/SkVarAlloc.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 "SkBBoxHierarchy.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
11 #include "SkPictureUtils.h" 11 #include "SkPictureUtils.h"
12 #include "SkRecord.h" 12 #include "SkRecord.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 14
15 struct MeasureRecords {
16 template <typename T> size_t operator()(const T& op) { return 0; }
17 size_t operator()(const SkRecords::DrawPicture& op) {
18 return SkPictureUtils::ApproximateBytesUsed(op.picture);
19 }
20 };
21
22 size_t SkPictureUtils::ApproximateBytesUsed(const SkPicture* pict) { 15 size_t SkPictureUtils::ApproximateBytesUsed(const SkPicture* pict) {
23 size_t byteCount = sizeof(*pict); 16 size_t byteCount = sizeof(*pict);
24 17
25 byteCount += pict->fRecord->bytesUsed(); 18 byteCount += pict->fRecord->bytesUsed();
26 if (pict->fBBH.get()) { 19 if (pict->fBBH.get()) {
27 byteCount += pict->fBBH->bytesUsed(); 20 byteCount += pict->fBBH->bytesUsed();
28 } 21 }
29 MeasureRecords visitor; 22 byteCount += pict->fApproxBytesUsedBySubPictures;
30 for (unsigned curOp = 0; curOp < pict->fRecord->count(); curOp++) {
31 byteCount += pict->fRecord->visit<size_t>(curOp, visitor);
32 }
33 23
34 return byteCount; 24 return byteCount;
35 } 25 }
OLDNEW
« no previous file with comments | « src/core/SkVarAlloc.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698