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