Debian Codegraph @

bench/PictureOverheadBench.cpp

raw
1 /*
2 * Copyright 2015 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
8 #include "bench/Benchmark.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkPicture.h"
11 #include "include/core/SkPictureRecorder.h"
12 #include "include/core/SkRRect.h"
13
14 class ClipOverheadRecordingBench : public Benchmark {
15 public:
16 ClipOverheadRecordingBench() {}
17
18 private:
19 const char* onGetName() override { return "clip_overhead_recording"; }
20 bool isSuitableFor(Backend backend) override { return backend == Backend::kNonRendering; }
21
22 void onDraw(int loops, SkCanvas*) override {
23 SkPictureRecorder rec;
24
25 for (int loop = 0; loop < loops; loop++) {
26 SkCanvas* canvas = rec.beginRecording({0,0, 2000,3000});
27
28 SkPaint paint;
29 SkRRect rrect;
30 rrect.setOval({0, 0, 1000, 1000});
31 for (int i = 0; i < 1000; i++) {
32 canvas->save();
33 canvas->translate(10, 10);
34 canvas->clipRect({10,10, 1000, 1000});
35 canvas->drawRRect(rrect, paint);
36 canvas->restore();
37 }
38
39 (void)rec.finishRecordingAsPicture();
40 }
41 }
42 };
43 DEF_BENCH( return new ClipOverheadRecordingBench; )