aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/GMBench.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bench/GMBench.cpp')
-rw-r--r--bench/GMBench.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/bench/GMBench.cpp b/bench/GMBench.cpp
new file mode 100644
index 0000000000..41a8e8c5f4
--- /dev/null
+++ b/bench/GMBench.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 "GMBench.h"
+
+GMBench::GMBench(skiagm::GM* gm) : fGM(gm) {
+ fName.printf("GM:%s", gm->getName());
+}
+
+GMBench::~GMBench() { delete fGM; }
+
+const char* GMBench::onGetName() {
+ return fName.c_str();
+}
+
+bool GMBench::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 GMBench::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 GMBench::onGetSize() {
+ SkISize size = fGM->getISize();
+ return SkIPoint::Make(size.fWidth, size.fHeight);
+}