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

Unified Diff: dm/DMBenchTask.cpp

Issue 178473006: DM: also run benches once. (Closed) Base URL: https://skia.googlesource.com/skia.git@dm
Patch Set: add note Created 6 years, 10 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 | « dm/DMBenchTask.h ('k') | dm/DMCpuTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMBenchTask.cpp
diff --git a/dm/DMBenchTask.cpp b/dm/DMBenchTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4e251de2e9e1a69383dccaa4ab79edaaa22c092a
--- /dev/null
+++ b/dm/DMBenchTask.cpp
@@ -0,0 +1,86 @@
+#include "DMBenchTask.h"
+#include "DMUtil.h"
+#include "SkSurface.h"
+
+namespace DM {
+
+static SkString bench_name(const char* name, const char* config) {
+ SkString result("bench ");
+ result.appendf("%s_%s", name, config);
+ return result;
+}
+
+NonRenderingBenchTask::NonRenderingBenchTask(const char* config,
+ Reporter* reporter,
+ TaskRunner* tasks,
+ BenchRegistry::Factory factory)
+ : Task(reporter, tasks)
+ , fBench(factory(NULL))
+ , fName(bench_name(fBench->getName(), config)) {}
+
+CpuBenchTask::CpuBenchTask(const char* config,
+ Reporter* reporter,
+ TaskRunner* tasks,
+ BenchRegistry::Factory factory,
+ SkColorType colorType)
+ : Task(reporter, tasks)
+ , fBench(factory(NULL))
+ , fName(bench_name(fBench->getName(), config))
+ , fColorType(colorType) {}
+
+GpuBenchTask::GpuBenchTask(const char* config,
+ Reporter* reporter,
+ TaskRunner* tasks,
+ BenchRegistry::Factory factory,
+ GrContextFactory::GLContextType contextType,
+ int sampleCount)
+ : Task(reporter, tasks)
+ , fBench(factory(NULL))
+ , fName(bench_name(fBench->getName(), config))
+ , fContextType(contextType)
+ , fSampleCount(sampleCount) {}
+
+bool NonRenderingBenchTask::shouldSkip() const {
+ return !fBench->isSuitableFor(SkBenchmark::kNonRendering_Backend);
+}
+
+bool CpuBenchTask::shouldSkip() const {
+ return !fBench->isSuitableFor(SkBenchmark::kRaster_Backend);
+}
+
+bool GpuBenchTask::shouldSkip() const {
+ return !fBench->isSuitableFor(SkBenchmark::kGPU_Backend);
+}
+
+static void draw_raster(SkBenchmark* bench, SkColorType colorType) {
+ SkBitmap bitmap;
+ SetupBitmap(colorType, bench, &bitmap);
+ SkCanvas canvas(bitmap);
+
+ bench->preDraw();
+ bench->draw(1, &canvas);
+ bench->postDraw();
+}
+
+void NonRenderingBenchTask::draw() {
+ draw_raster(fBench.get(), kPMColor_SkColorType);
+}
+
+void CpuBenchTask::draw() {
+ draw_raster(fBench.get(), fColorType);
+}
+
+void GpuBenchTask::draw() {
+ SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(),
+ fBench->getSize().y(),
+ kPMColor_SkColorType,
+ kPremul_SkAlphaType);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(
+ this->getGrContextFactory()->get(fContextType), info, fSampleCount));
+
+ fBench->preDraw();
+ fBench->draw(1, surface->getCanvas());
+ fBench->postDraw();
+}
+
+} // namespace DM
« no previous file with comments | « dm/DMBenchTask.h ('k') | dm/DMCpuTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698