skia2/bench/BigPathBench.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
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>
2019-04-24 16:27:11 +00:00

85 lines
2.2 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.
*/
#include "bench/Benchmark.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPath.h"
#include "tools/ToolUtils.h"
enum Align {
kLeft_Align,
kMiddle_Align,
kRight_Align
};
const char* gAlignName[] = { "left", "middle", "right" };
// Inspired by crbug.com/455429
class BigPathBench : public Benchmark {
SkPath fPath;
SkString fName;
Align fAlign;
bool fRound;
public:
BigPathBench(Align align, bool round) : fAlign(align), fRound(round) {
fName.printf("bigpath_%s", gAlignName[fAlign]);
if (round) {
fName.append("_round");
}
}
protected:
const char* onGetName() override {
return fName.c_str();
}
SkIPoint onGetSize() override {
return SkIPoint::Make(640, 100);
}
void onDelayedSetup() override { ToolUtils::make_big_path(fPath); }
void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(2);
if (fRound) {
paint.setStrokeJoin(SkPaint::kRound_Join);
}
this->setupPaint(&paint);
const SkRect r = fPath.getBounds();
switch (fAlign) {
case kLeft_Align:
canvas->translate(-r.left(), 0);
break;
case kMiddle_Align:
break;
case kRight_Align:
canvas->translate(640 - r.right(), 0);
break;
}
for (int i = 0; i < loops; i++) {
canvas->drawPath(fPath, paint);
}
}
private:
typedef Benchmark INHERITED;
};
DEF_BENCH( return new BigPathBench(kLeft_Align, false); )
DEF_BENCH( return new BigPathBench(kMiddle_Align, false); )
DEF_BENCH( return new BigPathBench(kRight_Align, false); )
DEF_BENCH( return new BigPathBench(kLeft_Align, true); )
DEF_BENCH( return new BigPathBench(kMiddle_Align, true); )
DEF_BENCH( return new BigPathBench(kRight_Align, true); )