O(1) SkPictureUtils::ApproxBytesUsed()
Chrome wants to call this more often, and it's quite slow today.
Seems like this could be clearer if SkPictureUtils::ApproxBytesUsed() were SkPicture::approxBytesUsed().
BUG=chromium:471873
Review URL: https://codereview.chromium.org/1090943004
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 8684a8e..0a2d43e 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -5,9 +5,10 @@
* found in the LICENSE file.
*/
-#include "SkRecorder.h"
#include "SkPatchUtils.h"
#include "SkPicture.h"
+#include "SkPictureUtils.h"
+#include "SkRecorder.h"
SkDrawableList::~SkDrawableList() {
fArray.unrefAll();
@@ -33,10 +34,12 @@
SkRecorder::SkRecorder(SkRecord* record, int width, int height)
: SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag)
+ , fApproxBytesUsedBySubPictures(0)
, fRecord(record) {}
SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds)
: SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
+ , fApproxBytesUsedBySubPictures(0)
, fRecord(record) {}
void SkRecorder::reset(SkRecord* record, const SkRect& bounds) {
@@ -47,6 +50,7 @@
void SkRecorder::forgetRecord() {
fDrawableList.reset(NULL);
+ fApproxBytesUsedBySubPictures = 0;
fRecord = NULL;
}
@@ -248,6 +252,7 @@
}
void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) {
+ fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic);
APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I());
}