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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// A benchmark designed to isolate the constant overheads of picture recording.
|
2015-04-06 14:25:04 +00:00
|
|
|
// We record an empty picture and a picture with one draw op to force memory allocation.
|
2015-04-03 20:25:13 +00:00
|
|
|
|
|
|
|
#include "Benchmark.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkPictureRecorder.h"
|
|
|
|
|
2015-04-06 14:25:04 +00:00
|
|
|
template <bool kDraw>
|
2015-04-03 20:25:13 +00:00
|
|
|
struct PictureOverheadBench : public Benchmark {
|
2015-04-06 14:25:04 +00:00
|
|
|
const char* onGetName() override {
|
|
|
|
return kDraw ? "picture_overhead_draw" : "picture_overhead_nodraw";
|
|
|
|
}
|
2015-04-03 20:25:13 +00:00
|
|
|
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
|
|
|
|
2015-10-01 16:43:39 +00:00
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
2015-04-03 20:25:13 +00:00
|
|
|
SkPictureRecorder rec;
|
|
|
|
for (int i = 0; i < loops; i++) {
|
2015-04-06 14:25:04 +00:00
|
|
|
rec.beginRecording(SkRect::MakeWH(2000,3000));
|
|
|
|
if (kDraw) {
|
|
|
|
rec.getRecordingCanvas()->drawRect(SkRect::MakeXYWH(10, 10, 1000, 1000), SkPaint());
|
|
|
|
}
|
2015-04-03 20:25:13 +00:00
|
|
|
SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-04-06 14:25:04 +00:00
|
|
|
|
|
|
|
DEF_BENCH(return (new PictureOverheadBench<false>);)
|
|
|
|
DEF_BENCH(return (new PictureOverheadBench< true>);)
|