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

Unified Diff: dm/DMSerializeTask.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/DMSerializeTask.h ('k') | dm/DMSrcSink.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSerializeTask.cpp
diff --git a/dm/DMSerializeTask.cpp b/dm/DMSerializeTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3e2503c6d52e407d66758588800dd0fbe87b803
--- /dev/null
+++ b/dm/DMSerializeTask.cpp
@@ -0,0 +1,44 @@
+#include "DMSerializeTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+
+#include "SkCommandLineFlags.h"
+#include "SkPicture.h"
+#include "SkPixelRef.h"
+
+DEFINE_bool(serialize, true, "If true, run picture serialization tests via SkPictureData.");
+
+namespace DM {
+
+SerializeTask::SerializeTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
+ : CpuTask(parent)
+ , fName(UnderJoin(parent.name().c_str(), "serialize"))
+ , fGM(gm)
+ , fReference(reference)
+ {}
+
+void SerializeTask::draw() {
+ SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), NULL/*no BBH*/));
+
+ SkDynamicMemoryWStream wStream;
+ recorded->serialize(&wStream);
+ SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
+ SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
+
+ SkBitmap bitmap;
+ AllocatePixels(fReference, &bitmap);
+ DrawPicture(*reconstructed, &bitmap);
+ if (!BitmapsEqual(bitmap, fReference)) {
+ this->fail();
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
+ }
+}
+
+bool SerializeTask::shouldSkip() const {
+ if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
+ return true;
+ }
+ return !FLAGS_serialize;
+}
+
+} // namespace DM
« no previous file with comments | « dm/DMSerializeTask.h ('k') | dm/DMSrcSink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698