2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
13 static bool sect_proc(SkRegion& a, SkRegion& b) {
15 return result.op(a, b, SkRegion::kIntersect_Op);
18 class RegionContainBench : public Benchmark {
20 typedef bool (*Proc)(SkRegion& a, SkRegion& b);
31 SkIRect randrect(SkRandom& rand, int i) {
32 int w = rand.nextU() % W;
33 return SkIRect::MakeXYWH(0, i*H/COUNT, w, H/COUNT);
36 RegionContainBench(Proc proc, const char name[]) {
38 fName.printf("region_contains_%s", name);
41 for (int i = 0; i < COUNT; i++) {
42 fA.op(randrect(rand, i), SkRegion::kXOR_Op);
45 fB.setRect(0, 0, H, W);
48 bool isSuitableFor(Backend backend) SK_OVERRIDE {
49 return backend == kNonRendering_Backend;
53 const char* onGetName() SK_OVERRIDE { return fName.c_str(); }
55 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
58 for (int i = 0; i < loops; ++i) {
64 typedef Benchmark INHERITED;
67 DEF_BENCH( return SkNEW_ARGS(RegionContainBench, (sect_proc, "sect")); )