aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMGpuGMTask.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-28 20:31:31 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-28 20:31:31 +0000
commitef57b7e65330d5f794a513630517907500f1c1d0 (patch)
treead4e3a100ff3da01a22f7aa6bda8cf11cea609c5 /dm/DMGpuGMTask.cpp
parentd1a7e2ec6ffb47243a31dc5c30b00fd7f700a339 (diff)
DM: make GPU tasks multithreaded again. Big refactor.
The main meat of things is in SkThreadPool. We can now give SkThreadPool a type for each thread to create and destroy on its local stack. It's TLS without going through SkTLS. I've split the DM tasks into CpuTasks that run on threads with no TLS, and GpuTasks that run on threads with a thread local GrContextFactory. The old CpuTask and GpuTask have been renamed to CpuGMTask and GpuGMTask. Upshot: default run of out/Debug/dm goes from ~45 seconds to ~20 seconds. BUG=skia: R=bsalomon@google.com, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/179233005 git-svn-id: http://skia.googlecode.com/svn/trunk@13632 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'dm/DMGpuGMTask.cpp')
-rw-r--r--dm/DMGpuGMTask.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/dm/DMGpuGMTask.cpp b/dm/DMGpuGMTask.cpp
new file mode 100644
index 0000000000..cffa2291c5
--- /dev/null
+++ b/dm/DMGpuGMTask.cpp
@@ -0,0 +1,56 @@
+#include "DMGpuGMTask.h"
+
+#include "DMExpectationsTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+#include "SkCommandLineFlags.h"
+#include "SkSurface.h"
+#include "SkTLS.h"
+
+namespace DM {
+
+GpuGMTask::GpuGMTask(const char* config,
+ Reporter* reporter,
+ TaskRunner* taskRunner,
+ const Expectations& expectations,
+ skiagm::GMRegistry::Factory gmFactory,
+ GrContextFactory::GLContextType contextType,
+ int sampleCount)
+ : GpuTask(reporter, taskRunner)
+ , fGM(gmFactory(NULL))
+ , fName(UnderJoin(fGM->getName(), config))
+ , fExpectations(expectations)
+ , fContextType(contextType)
+ , fSampleCount(sampleCount)
+ {}
+
+void GpuGMTask::draw(GrContextFactory* grFactory) {
+ SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()),
+ SkScalarCeilToInt(fGM->height()),
+ kPMColor_SkColorType,
+ kPremul_SkAlphaType);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(
+ grFactory->get(fContextType), info, fSampleCount));
+ SkCanvas* canvas = surface->getCanvas();
+
+ canvas->concat(fGM->getInitialTransform());
+ fGM->draw(canvas);
+ canvas->flush();
+
+ SkBitmap bitmap;
+ bitmap.setConfig(info);
+ canvas->readPixels(&bitmap, 0, 0);
+
+#if GR_CACHE_STATS
+ gr->printCacheStats();
+#endif
+
+ this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+}
+
+bool GpuGMTask::shouldSkip() const {
+ return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag);
+}
+
+} // namespace DM