aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-05 12:07:44 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-05 12:07:44 +0000
commit000d732ca70391aa7196efdbaf9992a96ff2fc99 (patch)
tree4aa53a72c89b8de87616c015ee9970f57dbe01bc
parent8491d24bdc3f48f67475c12c60babb9f9dba8047 (diff)
Move non-trivial work in RectBench() to onPreDraw.
Saw this on a profile where rects was filtered out. ಠ_ಠ BUG= R=reed@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/93703003 git-svn-id: http://skia.googlecode.com/svn/trunk@12500 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/RectBench.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index ee0f76b812..901304442f 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) {