From ac9d306a92e569e85a7611e9db00943b5b551f1e Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 4 Nov 2013 20:10:33 +0000 Subject: speed up A8 by creating a new entry-point in SkDraw that blits the path's coverage directly into an A8 target, regardless of the previous pixel values. R=bsalomon@google.com, mtklein@google.com Review URL: https://codereview.chromium.org/56453002 git-svn-id: http://skia.googlecode.com/svn/trunk@12118 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/CoverageBench.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 bench/CoverageBench.cpp (limited to 'bench/CoverageBench.cpp') diff --git a/bench/CoverageBench.cpp b/bench/CoverageBench.cpp new file mode 100644 index 0000000000..ba35c6a5f1 --- /dev/null +++ b/bench/CoverageBench.cpp @@ -0,0 +1,70 @@ +/* + * 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 "SkBenchmark.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 SkBenchmark { + SkPaint fPaint; + SkString fName; + SkPath fPath; + SkRasterClip fRC; + SkBitmap fBitmap; + 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); + + fBitmap.setConfig(SkBitmap::kA8_Config, 500, 500); + fBitmap.allocPixels(); + + fIdentity.setIdentity(); + fRC.setRect(fPath.getBounds().round()); + + fDraw.fBitmap = &fBitmap; + fDraw.fMatrix = &fIdentity; + fDraw.fRC = &fRC; + } + +protected: + virtual const char* onGetName() SK_OVERRIDE { + return fName.c_str(); + } + + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { + if (fDrawCoverage) { + for (int i = 0; i < this->getLoops(); ++i) { + fDraw.drawPathCoverage(fPath, fPaint); + } + } else { + for (int i = 0; i < this->getLoops(); ++i) { + fDraw.drawPath(fPath, fPaint); + } + } + } + +private: + typedef SkBenchmark INHERITED; +}; + +/////////////////////////////////////////////////////////////////////////////// + +DEF_BENCH( return new DrawPathBench(false) ) +DEF_BENCH( return new DrawPathBench(true) ) -- cgit v1.2.3