blob: 18ec11521eb3b0ef7854a348fde5a36b6a8dabfc [file] [log] [blame]
Mike Reedcf7258a2018-08-15 14:04:01 -04001/*
2 * Copyright 2018 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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "bench/Benchmark.h"
9#include "include/core/SkCubicMap.h"
Mike Reedcf7258a2018-08-15 14:04:01 -040010
11class CubicMapBench : public Benchmark {
12public:
13 CubicMapBench(SkPoint p1, SkPoint p2) : fCMap(p1, p2) {
14 fName.printf("cubicmap_%g_%g_%g_%g", p1.fX, p1.fY, p2.fX, p2.fY);
15 }
16
17 bool isSuitableFor(Backend backend) override {
18 return backend == kNonRendering_Backend;
19 }
20
21 const char* onGetName() override {
22 return fName.c_str();
23 }
24
25 void onDraw(int loops, SkCanvas*) override {
26 for (int i = 0; i < loops * 100; ++i) {
27 for (SkScalar x = 0; x <= 1; x += 1.0f / 512) {
28 fCMap.computeYFromX(x);
29 }
30 }
31 }
32
33private:
34 SkCubicMap fCMap;
35 SkString fName;
36
37 typedef Benchmark INHERITED;
38};
39
40DEF_BENCH( return new CubicMapBench({1, 0}, {0,0}); )
41DEF_BENCH( return new CubicMapBench({1, 0}, {0,1}); )
42DEF_BENCH( return new CubicMapBench({1, 0}, {1,0}); )
43DEF_BENCH( return new CubicMapBench({1, 0}, {1,1}); )
44
45DEF_BENCH( return new CubicMapBench({0, 1}, {0,0}); )
46DEF_BENCH( return new CubicMapBench({0, 1}, {0,1}); )
47DEF_BENCH( return new CubicMapBench({0, 1}, {1,0}); )
48DEF_BENCH( return new CubicMapBench({0, 1}, {1,1}); )
49
50DEF_BENCH( return new CubicMapBench({0, 0}, {1,1}); )
51DEF_BENCH( return new CubicMapBench({1, 1}, {0,0}); )