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

Unified Diff: bench/FSRectBench.cpp

Issue 21592002: Add fullscreen rect bench (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove skstring Created 7 years, 5 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 | gyp/bench.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/FSRectBench.cpp
diff --git a/bench/FSRectBench.cpp b/bench/FSRectBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a4dff69de32bafdb7020e56d9bf9091a708d8cf7
--- /dev/null
+++ b/bench/FSRectBench.cpp
@@ -0,0 +1,53 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBenchmark.h"
+#include "SkCanvas.h"
+#include "SkPaint.h"
+#include "SkRandom.h"
+
robertphillips 2013/08/01 17:50:14 comment r.e. what it is supposed to hit?
bsalomon 2013/08/02 19:35:10 Done.
+class FSRectBench : public SkBenchmark {
+public:
+ FSRectBench(void* param)
+ : INHERITED(param) {
robertphillips 2013/08/01 17:50:14 MWC?
bsalomon 2013/08/02 19:35:10 Done.
+ SkRandom rand;
+ static const SkScalar kMinOffset = 0;
robertphillips 2013/08/01 17:50:14 Move this setup out of the ctor and into onPreDraw
bsalomon 2013/08/02 19:35:10 Done.
+ static const SkScalar kMaxOffset = 100 * SK_Scalar1;
+ static const SkScalar kOffsetRange = kMaxOffset - kMinOffset;
robertphillips 2013/08/01 17:50:14 pre++?
bsalomon 2013/08/02 19:35:10 Done.
+ for (int i = 0; i < N; i++) {
+ fRects[i].fLeft = -kMinOffset - SkScalarMul(rand.nextUScalar1(), kOffsetRange);
+ fRects[i].fTop = -kMinOffset - SkScalarMul(rand.nextUScalar1(), kOffsetRange);
+ fRects[i].fRight = W + kMinOffset + SkScalarMul(rand.nextUScalar1(), kOffsetRange);
+ fRects[i].fBottom = H + kMinOffset + SkScalarMul(rand.nextUScalar1(), kOffsetRange);
+ fColors[i] = rand.nextU() | 0xFF000000;
+ }
+ }
+
+protected:
+ virtual const char* onGetName() SK_OVERRIDE { return "fullscreen_rects"; }
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
robertphillips 2013/08/01 17:50:14 pre++?
bsalomon 2013/08/02 19:35:10 Done.
+ for (int i = 0; i < N; i++) {
+ paint.setColor(fColors[i]);
+ canvas->drawRect(fRects[i], paint);
+ }
+ }
+
+private:
+ enum {
+ W = 640,
+ H = 480,
+ N = SkBENCHLOOP(300)
+ };
+ SkRect fRects[N];
+ SkColor fColors[N];
+
+ typedef SkBenchmark INHERITED;
+};
+
+DEF_BENCH( return SkNEW_ARGS(FSRectBench, (p)); )
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698