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

Unified Diff: dm/DMPipeTask.cpp

Issue 47773002: DM: add --pipe (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
« dm/DMPipeTask.h ('K') | « dm/DMPipeTask.h ('k') | dm/README » ('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..cc7b54cbabe440d5653eca7befbe73079dab4976
--- /dev/null
+++ b/dm/DMPipeTask.cpp
@@ -0,0 +1,79 @@
+#include "DMPipeTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+
+#include "SamplePipeControllers.h"
+#include "SkCommandLineFlags.h"
+#include "SkGPipe.h"
+
+DEFINE_bool(pipe, false, "If true, check several pipe variants against the reference bitmap.");
+
+namespace DM {
+
+static const char* kNames[] = {
epoger 2013/10/28 17:42:15 I see that the indices of these correspond to the
mtklein 2013/10/28 19:03:41 Added get_name().
+ "pipe",
+ "cross_process_pipe",
+ "shared_address_space_pipe",
+ "cross_process_shared_address_space_pipe",
+};
+
+static uint32_t get_flags(bool crossProcess, bool sharedAddressSpace) {
+ uint32_t flags = 0;
+ if (crossProcess) {
+ flags |= SkGPipeWriter::kCrossProcess_Flag;
+ }
+ if (sharedAddressSpace) {
+ flags |= SkGPipeWriter::kSharedAddressSpace_Flag;
+ }
+ return flags;
+}
+
+PipeTask::PipeTask(const Task& parent,
+ skiagm::GM* gm,
+ SkBitmap reference,
+ bool crossProcess,
+ bool sharedAddressSpace)
+ : Task(parent)
+ , fFlags(get_flags(crossProcess, sharedAddressSpace))
+ , fName(UnderJoin(parent.name().c_str(), kNames[fFlags]))
+ , fGM(gm)
+ , fReference(reference)
+ {}
+
+void PipeTask::draw() {
+ SkBitmap bitmap;
+ SetupBitmap(fReference.config(), fGM.get(), &bitmap);
+
+ SkCanvas canvas(bitmap);
+ PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
+ SkGPipeWriter writer;
+
+ SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
+ fFlags,
+ bitmap.width(),
+ bitmap.height());
+ pipeCanvas->concat(fGM->getInitialTransform());
+ fGM->draw(pipeCanvas);
+ writer.endRecording();
+
+ if (!BitmapsEqual(bitmap, fReference)) {
+ this->fail();
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, 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
« dm/DMPipeTask.h ('K') | « dm/DMPipeTask.h ('k') | dm/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698