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>
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
/*
|
|
* Copyright 2013 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/SkBitmap.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkColorPriv.h"
|
|
#include "include/core/SkMatrix.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "src/core/SkAutoPixmapStorage.h"
|
|
#include "src/core/SkDraw.h"
|
|
#include "src/core/SkRasterClip.h"
|
|
|
|
class DrawPathBench : public Benchmark {
|
|
SkPaint fPaint;
|
|
SkString fName;
|
|
SkPath fPath;
|
|
SkRasterClip fRC;
|
|
SkAutoPixmapStorage fPixmap;
|
|
SkMatrix fIdentity;
|
|
SkDraw fDraw;
|
|
bool fDrawCoverage;
|
|
public:
|
|
DrawPathBench(bool drawCoverage) : fDrawCoverage(drawCoverage) {
|
|
fPaint.setAntiAlias(true);
|
|
fName.printf("draw_coverage_%s", drawCoverage ? "true" : "false");
|
|
|
|
fPath.moveTo(0, 0);
|
|
fPath.quadTo(500, 0, 500, 500);
|
|
fPath.quadTo(250, 0, 0, 500);
|
|
|
|
fPixmap.alloc(SkImageInfo::MakeA8(500, 500));
|
|
if (!drawCoverage) {
|
|
// drawPathCoverage() goes out of its way to work fine with an uninitialized
|
|
// dst buffer, even in "SrcOver" mode, but ordinary drawing sure doesn't.
|
|
fPixmap.erase(0);
|
|
}
|
|
|
|
fIdentity.setIdentity();
|
|
fRC.setRect(fPath.getBounds().round());
|
|
|
|
fDraw.fDst = fPixmap;
|
|
fDraw.fMatrix = &fIdentity;
|
|
fDraw.fRC = &fRC;
|
|
}
|
|
|
|
protected:
|
|
const char* onGetName() override {
|
|
return fName.c_str();
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
if (fDrawCoverage) {
|
|
for (int i = 0; i < loops; ++i) {
|
|
fDraw.drawPathCoverage(fPath, fPaint);
|
|
}
|
|
} else {
|
|
for (int i = 0; i < loops; ++i) {
|
|
fDraw.drawPath(fPath, fPaint);
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
typedef Benchmark INHERITED;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_BENCH( return new DrawPathBench(false) )
|
|
DEF_BENCH( return new DrawPathBench(true) )
|