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

Unified Diff: dm/DMPipeTask.cpp

Issue 853883004: Revert of Sketch DM refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « dm/DMPipeTask.h ('k') | dm/DMQuiltTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMPipeTask.cpp
diff --git a/dm/DMPipeTask.cpp b/dm/DMPipeTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..383b51a38d966162284e3af90e40bdf5f760697d
--- /dev/null
+++ b/dm/DMPipeTask.cpp
@@ -0,0 +1,83 @@
+#include "DMPipeTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+
+#include "SamplePipeControllers.h"
+#include "SkCommandLineFlags.h"
+#include "SkGPipe.h"
+
+DEFINE_bool(pipe, true, "If true, check several pipe variants against the reference bitmap.");
+
+namespace DM {
+
+static uint32_t get_flags(PipeTask::Mode mode) {
+ uint32_t flags = 0;
+ if (mode != PipeTask::kInProcess_Mode) {
+ flags |= SkGPipeWriter::kCrossProcess_Flag;
+ }
+ if (mode == PipeTask::kSharedAddress_Mode) {
+ flags |= SkGPipeWriter::kSharedAddressSpace_Flag;
+ }
+ return flags;
+}
+
+static const char* get_name(const uint32_t flags) {
+ if (flags & SkGPipeWriter::kCrossProcess_Flag &&
+ flags & SkGPipeWriter::kSharedAddressSpace_Flag) {
+ return "shared-address-space-pipe";
+ } else if (flags & SkGPipeWriter::kCrossProcess_Flag) {
+ return "cross-process-pipe";
+ } else {
+ return "pipe";
+ }
+}
+
+PipeTask::PipeTask(const Task& parent,
+ skiagm::GM* gm,
+ SkBitmap reference,
+ Mode mode)
+ : CpuTask(parent)
+ , fFlags(get_flags(mode))
+ , fName(UnderJoin(parent.name().c_str(), get_name(fFlags)))
+ , fGM(gm)
+ , fReference(reference)
+ {}
+
+void PipeTask::draw() {
+ SkBitmap bitmap;
+ AllocatePixels(fReference, &bitmap);
+
+ SkCanvas canvas(bitmap);
+ PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
+ SkGPipeWriter writer;
+
+ SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
+ fFlags,
+ bitmap.width(),
+ bitmap.height());
+ CanvasPreflight(pipeCanvas);
+ pipeCanvas->concat(fGM->getInitialTransform());
+ fGM->draw(pipeCanvas);
+ writer.endRecording();
+
+ if (!BitmapsEqual(bitmap, fReference)) {
+ this->fail();
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
+ }
+}
+
+bool PipeTask::shouldSkip() const {
+ if (!FLAGS_pipe) {
+ return true;
+ }
+ if (fGM->getFlags() & skiagm::GM::kSkipPipe_Flag) {
+ return true;
+ }
+ if (fFlags == SkGPipeWriter::kCrossProcess_Flag &&
+ fGM->getFlags() & skiagm::GM::kSkipPipeCrossProcess_Flag) {
+ return true;
+ }
+ return false;
+}
+
+} // namespace DM
« no previous file with comments | « dm/DMPipeTask.h ('k') | dm/DMQuiltTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698