blob: be7c431946c9d68d97df2f87b59febbe770ee04d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkBBoxHierarchy.h"
#include "SkCanvas.h"
#include "SkData.h"
#include "SkPictureUtils.h"
#include "SkRecord.h"
#include "SkShader.h"
struct MeasureRecords {
template <typename T> size_t operator()(const T& op) { return 0; }
size_t operator()(const SkRecords::DrawPicture& op) {
return SkPictureUtils::ApproximateBytesUsed(op.picture);
}
};
size_t SkPictureUtils::ApproximateBytesUsed(const SkPicture* pict) {
size_t byteCount = sizeof(*pict);
byteCount += pict->fRecord->bytesUsed();
if (pict->fBBH.get()) {
byteCount += pict->fBBH->bytesUsed();
}
MeasureRecords visitor;
for (unsigned curOp = 0; curOp < pict->fRecord->count(); curOp++) {
byteCount += pict->fRecord->visit<size_t>(curOp, visitor);
}
return byteCount;
}
|