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 "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 } |
OLD | NEW |