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

Unified Diff: bench/SkGMBench.cpp

Issue 151843002: Allow GMs ato be used as benchmarks. Make convex_poly_clip opt in. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Address comments Created 6 years, 11 months 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 | « bench/SkGMBench.h ('k') | bench/benchmain.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SkGMBench.cpp
diff --git a/bench/SkGMBench.cpp b/bench/SkGMBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e1d812476482baeb33c96cdd39421bd39ede7c8a
--- /dev/null
+++ b/bench/SkGMBench.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkGMBench.h"
+
+SkGMBench::SkGMBench(skiagm::GM* gm) : fGM(gm) {
+ fName.printf("GM:%s", gm->shortName());
+}
+
+SkGMBench::~SkGMBench() { delete fGM; }
+
+const char* SkGMBench::onGetName() {
+ return fName.c_str();
+}
+
+bool SkGMBench::isSuitableFor(Backend backend) {
+ uint32_t flags = fGM->getFlags();
+ switch (backend) {
+ case kGPU_Backend:
+ return !(skiagm::GM::kSkipGPU_Flag & flags);
+ case kPDF_Backend:
+ return !(skiagm::GM::kSkipPDF_Flag & flags);
+ case kRaster_Backend:
+ // GM doesn't have an equivalent flag. If the GM has known issues with 565 then
+ // we skip it for ALL raster configs in bench.
+ return !(skiagm::GM::kSkip565_Flag & flags);
+ case kNonRendering_Backend:
+ return false;
+ default:
+ SkDEBUGFAIL("Unexpected backend type.");
+ return false;
+ }
+}
+
+void SkGMBench::onDraw(const int loops, SkCanvas* canvas) {
+ // Do we care about timing the draw of the background (once)?
+ // Does the GM ever rely on drawBackground to lazily compute something?
+ fGM->drawBackground(canvas);
+ for (int i = 0; i < loops; ++i) {
+ fGM->drawContent(canvas);
+ }
+}
+
+SkIPoint SkGMBench::onGetSize() {
+ SkISize size = fGM->getISize();
+ return SkIPoint::Make(size.fWidth, size.fHeight);
+}
« no previous file with comments | « bench/SkGMBench.h ('k') | bench/benchmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698