f55ea6a1de
...preferring SkA8_Coverage_Blitter over SkRasterPipelineBlitter. I think we could make this work with SkRasterPipelineBlitter (tell it, draw white in Src mode with this mask), but the existing blitter is pretty hard to beat in efficiency and correctness. CQ_INCLUDE_TRYBOTS=skia.primary:Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN,Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I72df9995c63f3334d8111c59711818cb5ed1e63c Reviewed-on: https://skia-review.googlesource.com/6627 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
76 lines
2.0 KiB
C++
76 lines
2.0 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 "Benchmark.h"
|
|
#include "SkAutoPixmapStorage.h"
|
|
#include "SkBitmap.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkColorPriv.h"
|
|
#include "SkDraw.h"
|
|
#include "SkMatrix.h"
|
|
#include "SkPath.h"
|
|
#include "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) )
|