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

Unified Diff: bench/RectBench.cpp

Issue 14688007: Add new bench for rotated rects (aarects_rotated) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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/RectBench.cpp
===================================================================
--- bench/RectBench.cpp (revision 8933)
+++ bench/RectBench.cpp (working copy)
@@ -169,30 +169,48 @@
H = 480,
};
- AARectBench(void* param) : INHERITED(param) {}
+ AARectBench(void* param, bool rotate) : INHERITED(param), fRotate(rotate) {}
protected:
- virtual const char* onGetName() { return "aarects"; }
+ virtual const char* onGetName() {
+ if (fRotate) {
+ return "aarects_rotated";
+ }
+ return "aarects";
+ }
virtual void onDraw(SkCanvas* canvas) {
+ static const SkScalar kHalfRectSize = SkFloatToScalar(0.75f);
+
SkPaint paint;
this->setupPaint(&paint);
paint.setAntiAlias(true);
paint.setColor(SK_ColorBLACK);
- SkRect r;
+ SkRect r = { -kHalfRectSize, -kHalfRectSize, kHalfRectSize, kHalfRectSize };
+ int rot = 0;
// Draw small aa rects in a grid across the screen
- for (SkScalar y = SK_ScalarHalf; y < H; y += SkIntToScalar(2)) {
- for (SkScalar x = SK_ScalarHalf; x < W; x += SkIntToScalar(2)) {
- r.set(x, y,
- x+SkFloatToScalar(1.5f), y+SkFloatToScalar(1.5f));
+ for (SkScalar y = kHalfRectSize+SK_Scalar1; y < H; y += 2*kHalfRectSize+2) {
+ for (SkScalar x = kHalfRectSize+SK_Scalar1; x < W; x += 2*kHalfRectSize+2) {
+ canvas->save();
+ canvas->translate(x, y);
+
+ if (fRotate) {
+ SkMatrix rotate;
+ rotate.setRotate(SkIntToScalar(rot));
+ canvas->concat(rotate);
+ rot += 10;
+ }
+
canvas->drawRect(r, paint);
+ canvas->restore();
}
}
}
private:
+ bool fRotate;
typedef SkBenchmark INHERITED;
};
@@ -290,8 +308,10 @@
DEF_BENCH( return SkNEW_ARGS(PointsBench, (p, SkCanvas::kPolygon_PointMode, "polygon")); )
DEF_BENCH( return SkNEW_ARGS(SrcModeRectBench, (p)); )
-DEF_BENCH( return SkNEW_ARGS(AARectBench, (p)); )
+DEF_BENCH( return SkNEW_ARGS(AARectBench, (p, false)); )
+DEF_BENCH( return SkNEW_ARGS(AARectBench, (p, true)); )
+
/* init the blitmask bench
*/
DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
« 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