1 /*
2  * Copyright 2017 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 
8 #include "bench/Benchmark.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkColorSpace.h"
11 #include "include/core/SkImage.h"
12 #include "include/core/SkPictureRecorder.h"
13 #include "include/core/SkString.h"
14 #include "include/core/SkSurface.h"
15 #include "tools/ToolUtils.h"
16 
17 #include "include/core/SkPath.h"
18 #include "include/core/SkSurface.h"
19 
20 class RasterTileBench : public Benchmark {
21     sk_sp<SkSurface> fSurf;
22     SkPath           fPath;
23     SkString       fName;
24 public:
RasterTileBench()25     RasterTileBench() : fName("rastertile") {
26         int W = 2014 * 20;
27         int H = 20;
28         fSurf = SkSurface::MakeRasterN32Premul(W, H);
29 
30         fPath.moveTo(0, 0);
31         fPath.cubicTo(20, 10, 10, 15, 30, 5);
32     }
33 
34 protected:
onGetName()35     const char* onGetName() override { return fName.c_str(); }
36 
onDraw(int loops,SkCanvas * canvas)37     void onDraw(int loops, SkCanvas* canvas) override {
38         SkPaint paint;
39         paint.setStyle(SkPaint::kStroke_Style);
40         paint.setStrokeWidth(1.1f);
41         paint.setAntiAlias(true);
42 
43         for (int i = 0; i < loops; ++i) {
44             for (int j = 0; j < 1000; ++j) {
45                 fSurf->getCanvas()->drawPath(fPath, paint);
46             }
47         }
48     }
49 
50 private:
51 };
52 DEF_BENCH(return new RasterTileBench;)
53