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

Side by Side Diff: bench/PicturePlaybackBench.cpp

Issue 99893003: Simplify benchmark internal API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/PerlinNoiseBench.cpp ('k') | bench/PictureRecordBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 #include "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 17 matching lines...) Expand all
28 enum { 28 enum {
29 PICTURE_WIDTH = 1000, 29 PICTURE_WIDTH = 1000,
30 PICTURE_HEIGHT = 4000, 30 PICTURE_HEIGHT = 4000,
31 TEXT_SIZE = 10 31 TEXT_SIZE = 10
32 }; 32 };
33 protected: 33 protected:
34 virtual const char* onGetName() { 34 virtual const char* onGetName() {
35 return fName.c_str(); 35 return fName.c_str();
36 } 36 }
37 37
38 virtual void onDraw(SkCanvas* canvas) { 38 virtual void onDraw(const int loops, SkCanvas* canvas) {
39 39
40 SkPicture picture; 40 SkPicture picture;
41 41
42 SkCanvas* pCanvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT ); 42 SkCanvas* pCanvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT );
43 recordCanvas(pCanvas); 43 recordCanvas(pCanvas);
44 picture.endRecording(); 44 picture.endRecording();
45 45
46 const SkPoint translateDelta = getTranslateDelta(this->getLoops()); 46 const SkPoint translateDelta = getTranslateDelta(loops);
47 47
48 for (int i = 0; i < this->getLoops(); i++) { 48 for (int i = 0; i < loops; i++) {
49 picture.draw(canvas); 49 picture.draw(canvas);
50 canvas->translate(translateDelta.fX, translateDelta.fY); 50 canvas->translate(translateDelta.fX, translateDelta.fY);
51 } 51 }
52 } 52 }
53 53
54 virtual void recordCanvas(SkCanvas* canvas) = 0; 54 virtual void recordCanvas(SkCanvas* canvas) = 0;
55 virtual SkPoint getTranslateDelta(int N) { 55 virtual SkPoint getTranslateDelta(int N) {
56 SkIPoint canvasSize = onGetSize(); 56 SkIPoint canvasSize = onGetSize();
57 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N), 57 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N),
58 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N)); 58 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 bool fDrawPosH; 132 bool fDrawPosH;
133 typedef PicturePlaybackBench INHERITED; 133 typedef PicturePlaybackBench INHERITED;
134 }; 134 };
135 135
136 136
137 /////////////////////////////////////////////////////////////////////////////// 137 ///////////////////////////////////////////////////////////////////////////////
138 138
139 DEF_BENCH( return new TextPlaybackBench(); ) 139 DEF_BENCH( return new TextPlaybackBench(); )
140 DEF_BENCH( return new PosTextPlaybackBench(true); ) 140 DEF_BENCH( return new PosTextPlaybackBench(true); )
141 DEF_BENCH( return new PosTextPlaybackBench(false); ) 141 DEF_BENCH( return new PosTextPlaybackBench(false); )
OLDNEW
« no previous file with comments | « bench/PerlinNoiseBench.cpp ('k') | bench/PictureRecordBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698