blob: 1feade41f5d4264c61b1cf334ecd6f278e517a3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Benchmark.h"
#include "SkCanvas.h"
#include "SkRandom.h"
class QuickRejectBench : public Benchmark {
enum { N = 1000000 };
float fFloats[N];
int fInts [N];
const char* onGetName() override { return "quick_reject"; }
bool isSuitableFor(Backend backend) override { return backend != kNonRendering_Backend; }
void onDelayedSetup() override {
SkRandom rand;
for (int i = 0; i < N; ++i) {
fFloats[i] = 300.0f * (rand.nextSScalar1() + 0.5f);
}
}
void onDraw(int loops, SkCanvas* canvas) override {
while (loops --> 0) {
for (int i = 0; i < N - 4; i++) {
if (canvas->quickReject(*(SkRect*)(fFloats+i))) {
fInts[i] = 11;
} else {
fInts[i] = 24;
}
}
}
}
};
DEF_BENCH( return new QuickRejectBench; )
class ConcatBench : public Benchmark {
SkMatrix fMatrix;
const char* onGetName() override { return "concat"; }
bool isSuitableFor(Backend backend) override { return backend != kNonRendering_Backend; }
void onDelayedSetup() override {
SkRandom r;
fMatrix.setScale(5.0f, 5.0f);
fMatrix.setTranslateX(10.0f);
fMatrix.setTranslateY(10.0f);
}
void onDraw(int loops, SkCanvas* canvas) override {
while (loops --> 0) {
canvas->setMatrix(SkMatrix::MakeScale(3.0f));
canvas->concat(fMatrix);
}
}
};
DEF_BENCH( return new ConcatBench; )
|