2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "bench/Benchmark.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkPictureRecorder.h"
11 #include "include/core/SkRRect.h"
13 class ClipOverheadRecordingBench : public Benchmark {
15 ClipOverheadRecordingBench() {}
18 const char* onGetName() override { return "clip_overhead_recording"; }
19 bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
21 void onDraw(int loops, SkCanvas*) override {
22 SkPictureRecorder rec;
24 for (int loop = 0; loop < loops; loop++) {
25 SkCanvas* canvas = rec.beginRecording({0,0, 2000,3000});
29 rrect.setOval({0, 0, 1000, 1000});
30 for (int i = 0; i < 1000; i++) {
32 canvas->translate(10, 10);
33 canvas->clipRect({10,10, 1000, 1000});
34 canvas->drawRRect(rrect, paint);
38 (void)rec.finishRecordingAsPicture();
42 DEF_BENCH( return new ClipOverheadRecordingBench; )