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

Unified Diff: bench/PictureRecordBench.cpp

Issue 23995020: switch to a new canvas every once in a while in picture_record_unique (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PictureRecordBench.cpp
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index e9d2b54c4d659201552fef90b6df8f59441d71b5..5a183e14ed1ffb5619f293860a3e3507053272ce 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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698