Debian Codegraph @

bench/ClipMaskBench.cpp

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