Florin Malita | c3b10a3 | 2017-05-02 11:09:01 -0400 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 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" |
Florin Malita | c3b10a3 | 2017-05-02 11:09:01 -0400 | [diff] [blame] | 16 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "include/core/SkPath.h" |
| 18 | #include "include/core/SkSurface.h" |
Mike Reed | 2dc50cc | 2018-04-12 12:20:25 -0400 | [diff] [blame] | 19 | |
| 20 | class RasterTileBench : public Benchmark { |
| 21 | sk_sp<SkSurface> fSurf; |
| 22 | SkPath fPath; |
| 23 | SkString fName; |
| 24 | public: |
| 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: |
| 35 | const char* onGetName() override { return fName.c_str(); } |
| 36 | |
| 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;) |