2015-04-03 20:25:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "bench/Benchmark.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkPictureRecorder.h"
|
2019-05-14 17:33:40 +00:00
|
|
|
#include "include/core/SkRRect.h"
|
2017-03-06 19:14:09 +00:00
|
|
|
|
|
|
|
class ClipOverheadRecordingBench : public Benchmark {
|
|
|
|
public:
|
2019-05-14 17:33:40 +00:00
|
|
|
ClipOverheadRecordingBench() {}
|
2017-03-06 19:14:09 +00:00
|
|
|
|
2019-05-14 17:33:40 +00:00
|
|
|
private:
|
|
|
|
const char* onGetName() override { return "clip_overhead_recording"; }
|
2017-03-06 19:14:09 +00:00
|
|
|
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
|
|
|
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
SkPictureRecorder rec;
|
|
|
|
|
2021-08-13 02:27:39 +00:00
|
|
|
for (int loop = 0; loop < loops; loop++) {
|
2019-05-14 17:33:40 +00:00
|
|
|
SkCanvas* canvas = rec.beginRecording({0,0, 2000,3000});
|
2017-03-06 19:14:09 +00:00
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setOval({0, 0, 1000, 1000});
|
|
|
|
for (int i = 0; i < 1000; i++) {
|
|
|
|
canvas->save();
|
2019-05-14 17:33:40 +00:00
|
|
|
canvas->translate(10, 10);
|
|
|
|
canvas->clipRect({10,10, 1000, 1000});
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2017-03-06 19:14:09 +00:00
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2019-05-14 17:33:40 +00:00
|
|
|
(void)rec.finishRecordingAsPicture();
|
2017-03-06 19:14:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2019-05-14 17:33:40 +00:00
|
|
|
DEF_BENCH( return new ClipOverheadRecordingBench; )
|