Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: bench/CoverageBench.cpp

Issue 50673005: Revert "Revert "speed up A8 by creating a new entry-point in SkDraw that blits the path's coverage … (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/CoverageBench.cpp
diff --git a/bench/CoverageBench.cpp b/bench/CoverageBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..de09733cf822fcd6b3b2ad42a7b891867ac9c3f2
--- /dev/null
+++ b/bench/CoverageBench.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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.fClip = &fRC.bwRgn();
+ 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) )
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698