aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-17 17:14:25 +0000
committerGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-17 17:14:25 +0000
commit5e5239ed35dcac2a42c4780baa7846b751111895 (patch)
treeb3ef74ab7650ced7405c1eec5f9f0b94f700b1c3 /bench
parentd8807976e7a495a515ea27c3c88d7b92cace964d (diff)
switch to a new canvas every once in a while in picture_record_unique
BUG= R=robertphillips@google.com Review URL: https://codereview.chromium.org/23995020 git-svn-id: http://skia.googlecode.com/svn/trunk@11321 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/PictureRecordBench.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index e9d2b54c4d..5a183e14ed 100644
--- a/bench/PictureRecordBench.cpp
+++ b/bench/PictureRecordBench.cpp
@@ -18,8 +18,6 @@ class PictureRecordBench : public SkBenchmark {
public:
PictureRecordBench(const char name[]) {
fName.printf("picture_record_%s", name);
- fPictureWidth = SkIntToScalar(PICTURE_WIDTH);
- fPictureHeight = SkIntToScalar(PICTURE_HEIGHT);
fIsRendering = false;
}
@@ -47,9 +45,6 @@ protected:
virtual void recordCanvas(SkCanvas* canvas) = 0;
SkString fName;
- SkScalar fPictureWidth;
- SkScalar fPictureHeight;
- SkScalar fTextSize;
private:
typedef SkBenchmark INHERITED;
};
@@ -127,10 +122,21 @@ public:
: INHERITED("unique_paint_dictionary") { }
protected:
- virtual void recordCanvas(SkCanvas* canvas) {
+ virtual void recordCanvas(SkCanvas* /*ignored*/) {
+ // We ignore the parent's canvas (which is just there for our
+ // convenience) because we've got to have more careful control over it.
+ // We start a new one every so often to prevent unbounded memory growth.
+
SkRandom rand;
+ SkPaint paint;
+ SkAutoTDelete<SkPicture> picture;
+ SkCanvas* canvas = NULL;
+ const int kMaxPaintsPerCanvas = 10000;
for (int i = 0; i < this->getLoops(); i++) {
- SkPaint paint;
+ if (0 == i % kMaxPaintsPerCanvas) {
+ picture.reset(SkNEW(SkPicture));
+ canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
+ }
paint.setColor(rand.nextU());
canvas->drawPaint(paint);
}