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

Side by Side Diff: bench/DrawBitmapAABench.cpp

Issue 1207403007: Add a bench for measuring drawBitmap anti-aliasing overhead (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "Benchmark.h"
8 #include "SkCanvas.h"
9 #include "SkMatrix.h"
10 #include "SkPaint.h"
11 #include "SkString.h"
12
13 /**
14 * This bench measures the rendering time of SkCanvas::drawBitmap with different anti-aliasing /
15 * matrix combinations.
16 */
17
18 class DrawBitmapAABench : public Benchmark {
19 public:
20 DrawBitmapAABench(bool doAA, const SkMatrix& matrix, const char name[])
21 : fMatrix(matrix)
22 , fName("draw_bitmap_") {
23
24 fPaint.setAntiAlias(doAA);
25 fName.appendf("%s_%s", doAA ? "aa" : "noaa", name);
26 }
27
28 protected:
29 const char* onGetName() override {
30 return fName.c_str();
31 }
32
33 void onPreDraw() override {
34 fBitmap.allocN32Pixels(200, 200);
35 fBitmap.eraseARGB(255, 0, 255, 0);
36 }
37
38 void onDraw(const int loops, SkCanvas* canvas) override {
39 canvas->concat(fMatrix);
40 for (int i = 0; i < loops; i++) {
41 canvas->drawBitmap(fBitmap, 0, 0, &fPaint);
42 }
43 }
44
45 private:
46 SkPaint fPaint;
47 SkMatrix fMatrix;
48 SkString fName;
49 SkBitmap fBitmap;
50
51 typedef Benchmark INHERITED;
52 };
53
54 DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeScale(1), "ident"); )
55
56 DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeScale(1.17f), "scal e"); )
57
58 DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeTrans(17.5f, 17.5f) , "translate"); )
59
60 DEF_BENCH(
61 SkMatrix m;
62 m.reset();
63 m.preRotate(15);
64 return new DrawBitmapAABench(false, m, "rotate");
65 )
66
67 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1), "ident"); )
68
69 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1.17f), "scale "); )
70
71 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeTrans(17.5f, 17.5f), "translate"); )
72
73 DEF_BENCH(
74 SkMatrix m;
75 m.reset();
76 m.preRotate(15);
77 return new DrawBitmapAABench(true, m, "rotate");
78 )
OLDNEW
« 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