| OLD | NEW |
| 1 #include "DMSerializeTask.h" | 1 #include "DMSerializeTask.h" |
| 2 #include "DMUtil.h" | 2 #include "DMUtil.h" |
| 3 #include "DMWriteTask.h" | 3 #include "DMWriteTask.h" |
| 4 | 4 |
| 5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
| 6 #include "SkPicture.h" | 6 #include "SkPicture.h" |
| 7 #include "SkPixelRef.h" | 7 #include "SkPixelRef.h" |
| 8 | 8 |
| 9 DEFINE_bool(serialize, true, "If true, run picture serialization tests."); | 9 DEFINE_bool(serialize, true, "If true, run picture serialization tests."); |
| 10 | 10 |
| 11 namespace DM { | 11 namespace DM { |
| 12 | 12 |
| 13 SerializeTask::SerializeTask(const Task& parent, | 13 SerializeTask::SerializeTask(const Task& parent, |
| 14 skiagm::GM* gm, | 14 skiagm::GM* gm, |
| 15 SkBitmap reference) | 15 SkBitmap reference) |
| 16 : CpuTask(parent) | 16 : CpuTask(parent) |
| 17 , fName(UnderJoin(parent.name().c_str(), "serialize")) | 17 , fName(UnderJoin(parent.name().c_str(), "serialize")) |
| 18 , fGM(gm) | 18 , fGM(gm) |
| 19 , fReference(reference) | 19 , fReference(reference) |
| 20 {} | 20 {} |
| 21 | 21 |
| 22 void SerializeTask::draw() { | 22 void SerializeTask::draw() { |
| 23 SkPicture recorded; | 23 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get())); |
| 24 RecordPicture(fGM.get(), &recorded); | |
| 25 | 24 |
| 26 SkDynamicMemoryWStream wStream; | 25 SkDynamicMemoryWStream wStream; |
| 27 recorded.serialize(&wStream, NULL); | 26 recorded->serialize(&wStream, NULL); |
| 28 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream()); | 27 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream()); |
| 29 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream)); | 28 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream)); |
| 30 | 29 |
| 31 SkBitmap bitmap; | 30 SkBitmap bitmap; |
| 32 SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); | 31 SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); |
| 33 DrawPicture(reconstructed, &bitmap); | 32 DrawPicture(reconstructed, &bitmap); |
| 34 if (!BitmapsEqual(bitmap, fReference)) { | 33 if (!BitmapsEqual(bitmap, fReference)) { |
| 35 this->fail(); | 34 this->fail(); |
| 36 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 35 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
| 37 } | 36 } |
| 38 } | 37 } |
| 39 | 38 |
| 40 bool SerializeTask::shouldSkip() const { | 39 bool SerializeTask::shouldSkip() const { |
| 41 return !FLAGS_serialize || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; | 40 return !FLAGS_serialize || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; |
| 42 } | 41 } |
| 43 | 42 |
| 44 } // namespace DM | 43 } // namespace DM |
| OLD | NEW |