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

Unified Diff: bench/RectBench.cpp

Issue 93703003: Move non-trivial work in RectBench to onPreDraw. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 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/RectBench.cpp
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index ee0f76b8129fab995a8b904023c15420243c4df4..901304442f9ff068832a8e216535d543979054d7 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -28,24 +28,7 @@ public:
RectBench(int shift, int stroke = 0)
: fShift(shift)
- , fStroke(stroke) {
- SkRandom rand;
- const SkScalar offset = SK_Scalar1/3;
- for (int i = 0; i < N; i++) {
- int x = rand.nextU() % W;
- int y = rand.nextU() % H;
- int w = rand.nextU() % W;
- int h = rand.nextU() % H;
- w >>= shift;
- h >>= shift;
- x -= w/2;
- y -= h/2;
- fRects[i].set(SkIntToScalar(x), SkIntToScalar(y),
- SkIntToScalar(x+w), SkIntToScalar(y+h));
- fRects[i].offset(offset, offset);
- fColors[i] = rand.nextU() | 0xFF808080;
- }
- }
+ , fStroke(stroke) {}
SkString fName;
const char* computeName(const char root[]) {
@@ -62,6 +45,26 @@ protected:
}
virtual const char* onGetName() { return computeName("rects"); }
+
+ virtual void onPreDraw() {
+ SkRandom rand;
+ const SkScalar offset = SK_Scalar1/3;
+ for (int i = 0; i < N; i++) {
+ int x = rand.nextU() % W;
+ int y = rand.nextU() % H;
+ int w = rand.nextU() % W;
+ int h = rand.nextU() % H;
+ w >>= fShift;
+ h >>= fShift;
+ x -= w/2;
+ y -= h/2;
+ fRects[i].set(SkIntToScalar(x), SkIntToScalar(y),
+ SkIntToScalar(x+w), SkIntToScalar(y+h));
+ fRects[i].offset(offset, offset);
+ fColors[i] = rand.nextU() | 0xFF808080;
+ }
+ }
+
virtual void onDraw(const int loops, SkCanvas* canvas) {
SkPaint paint;
if (fStroke > 0) {
« 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