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

Unified Diff: dm/DMGpuTask.cpp

Issue 22839016: Skeleton of DM (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: one last sync Created 7 years, 2 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/DMGpuTask.h ('k') | dm/DMReplayTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMGpuTask.cpp
diff --git a/dm/DMGpuTask.cpp b/dm/DMGpuTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9205cb996bfa736a218eb8976803b5faee15da2b
--- /dev/null
+++ b/dm/DMGpuTask.cpp
@@ -0,0 +1,63 @@
+#include "DMGpuTask.h"
+
+#include "DMComparisonTask.h"
+#include "DMUtil.h"
+#include "SkCommandLineFlags.h"
+#include "SkGpuDevice.h"
+#include "SkTLS.h"
+
+namespace DM {
+
+GpuTask::GpuTask(const char* name,
+ Reporter* reporter,
+ TaskRunner* taskRunner,
+ const skiagm::ExpectationsSource& expectations,
+ skiagm::GMRegistry::Factory gmFactory,
+ SkBitmap::Config config,
+ GrContextFactory::GLContextType contextType,
+ int sampleCount)
+ : Task(reporter, taskRunner)
+ , fGM(gmFactory(NULL))
+ , fName(underJoin(fGM->shortName(), name))
+ , fExpectations(expectations.get(png(fName).c_str()))
+ , fConfig(config)
+ , fContextType(contextType)
+ , fSampleCount(sampleCount)
+ {}
+
+static void* new_gr_context_factory() {
+ return SkNEW(GrContextFactory);
+}
+
+static void delete_gr_context_factory(void* factory) {
+ return SkDELETE((GrContextFactory*) factory);
+}
+
+static GrContextFactory* get_gr_factory() {
+ return reinterpret_cast<GrContextFactory*>(SkTLS::Get(&new_gr_context_factory,
+ &delete_gr_context_factory));
+}
+
+void GpuTask::draw() {
+ GrContext* gr = get_gr_factory()->get(fContextType); // Will be owned by device.
+ SkGpuDevice device(gr, fConfig, fGM->width(), fGM->height(), fSampleCount);
+ SkCanvas canvas(&device);
+
+ canvas.concat(fGM->getInitialTransform());
+ fGM->draw(&canvas);
+ canvas.flush();
+
+ SkBitmap bitmap;
+ bitmap.setConfig(fConfig, fGM->width(), fGM->height());
+ canvas.readPixels(&bitmap, 0, 0);
+
+ // We offload checksum comparison to the main CPU threadpool.
+ // This cuts run time by about 30%.
+ this->spawnChild(SkNEW_ARGS(ComparisonTask, (*this, fExpectations, bitmap)));
+}
+
+bool GpuTask::shouldSkip() const {
+ return fGM->getFlags() & skiagm::GM::kSkipGPU_Flag;
+}
+
+} // namespace DM
« no previous file with comments | « dm/DMGpuTask.h ('k') | dm/DMReplayTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698