c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
117 lines
3.7 KiB
C++
117 lines
3.7 KiB
C++
/*
|
|
* 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.
|
|
// We record an empty picture and a picture with one draw op to force memory allocation.
|
|
|
|
#include "bench/Benchmark.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkPictureRecorder.h"
|
|
#include "src/core/SkLiteDL.h"
|
|
#include "src/core/SkLiteRecorder.h"
|
|
|
|
template <int kDraws, bool kLite>
|
|
struct PictureOverheadBench : public Benchmark {
|
|
PictureOverheadBench() {
|
|
fName.appendf("picture_overhead_%d%s", kDraws, kLite ? "_lite" : "");
|
|
}
|
|
const char* onGetName() override { return fName.c_str(); }
|
|
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
SkLiteRecorder lite;
|
|
SkPictureRecorder rec;
|
|
|
|
SkIRect iBounds = {0,0, 2000,3000};
|
|
SkRect bounds = SkRect::Make(iBounds);
|
|
|
|
for (int i = 0; i < loops; i++) {
|
|
SkLiteDL liteDL;
|
|
SkCanvas* canvas;
|
|
if (kLite) {
|
|
lite.reset(&liteDL, iBounds);
|
|
canvas = &lite;
|
|
} else {
|
|
rec.beginRecording(bounds);
|
|
canvas = rec.getRecordingCanvas();
|
|
}
|
|
|
|
for (int i = 0; i < kDraws; i++) {
|
|
canvas->drawRect({10,10, 1000, 1000}, SkPaint{});
|
|
}
|
|
|
|
if (!kLite) {
|
|
(void)rec.finishRecordingAsPicture();
|
|
}
|
|
}
|
|
}
|
|
|
|
SkString fName;
|
|
};
|
|
|
|
DEF_BENCH(return (new PictureOverheadBench<0, false>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<1, false>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<2, false>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<10,false>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<0, true>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<1, true>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<2, true>);)
|
|
DEF_BENCH(return (new PictureOverheadBench<10, true>);)
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class ClipOverheadRecordingBench : public Benchmark {
|
|
SkString fName;
|
|
const bool fDoLite;
|
|
|
|
public:
|
|
ClipOverheadRecordingBench(bool doLite) : fDoLite(doLite) {
|
|
fName.printf("clip_overhead_recording_%s", doLite ? "lite" : "std");
|
|
}
|
|
|
|
protected:
|
|
const char* onGetName() override { return fName.c_str(); }
|
|
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
SkLiteRecorder lite;
|
|
SkPictureRecorder rec;
|
|
|
|
SkIRect iBounds = {0,0, 2000,3000};
|
|
SkRect bounds = SkRect::Make(iBounds);
|
|
|
|
for (int i = 0; i < loops; i++) {
|
|
SkLiteDL liteDL;
|
|
SkCanvas* canvas;
|
|
if (fDoLite) {
|
|
lite.reset(&liteDL, iBounds);
|
|
canvas = &lite;
|
|
} else {
|
|
rec.beginRecording(bounds);
|
|
canvas = rec.getRecordingCanvas();
|
|
}
|
|
|
|
SkPaint paint;
|
|
SkRRect rrect;
|
|
rrect.setOval({0, 0, 1000, 1000});
|
|
for (int i = 0; i < 1000; i++) {
|
|
canvas->save();
|
|
canvas->translate(10, 10);
|
|
canvas->clipRect({10,10, 1000, 1000});
|
|
canvas->drawRRect(rrect, paint);
|
|
canvas->restore();
|
|
}
|
|
|
|
if (!fDoLite) {
|
|
(void)rec.finishRecordingAsPicture();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
DEF_BENCH( return new ClipOverheadRecordingBench(true); )
|
|
DEF_BENCH( return new ClipOverheadRecordingBench(false); )
|