| OLD | NEW |
| 1 #ifndef DMWriteTask_DEFINED | 1 #ifndef DMWriteTask_DEFINED |
| 2 #define DMWriteTask_DEFINED | 2 #define DMWriteTask_DEFINED |
| 3 | 3 |
| 4 #include "DMExpectations.h" | 4 #include "DMExpectations.h" |
| 5 #include "DMTask.h" | 5 #include "DMTask.h" |
| 6 #include "SkBitmap.h" | 6 #include "SkBitmap.h" |
| 7 #include "SkJSONCPP.h" |
| 8 #include "SkStream.h" |
| 7 #include "SkString.h" | 9 #include "SkString.h" |
| 8 #include "SkTArray.h" | 10 #include "SkTArray.h" |
| 9 | 11 |
| 10 | 12 |
| 11 // Writes a bitmap to a file. | 13 // Writes a bitmap to a file. |
| 12 | 14 |
| 13 namespace DM { | 15 namespace DM { |
| 14 | 16 |
| 15 class WriteTask : public CpuTask { | 17 class WriteTask : public CpuTask { |
| 16 | 18 |
| 17 public: | 19 public: |
| 18 WriteTask(const Task& parent, // WriteTask must be a child task. | 20 WriteTask(const Task& parent, // WriteTask must be a child task. |
| 19 SkBitmap bitmap); // Bitmap to encode to PNG and write to disk. | 21 SkBitmap bitmap); // Bitmap to encode to PNG and write to disk. |
| 20 | 22 |
| 21 // Takes ownership of SkStreamAsset | 23 // Takes ownership of SkStreamAsset |
| 22 WriteTask(const Task& parent, // WriteTask must be a child task. | 24 WriteTask(const Task& parent, // WriteTask must be a child task. |
| 23 SkStreamAsset* data, // Pre-encoded data to write to disk. | 25 SkStreamAsset* data, // Pre-encoded data to write to disk. |
| 24 const char* ext); // File extension. | 26 const char* ext); // File extension. |
| 25 | 27 |
| 26 virtual void draw() SK_OVERRIDE; | 28 virtual void draw() SK_OVERRIDE; |
| 27 virtual bool shouldSkip() const SK_OVERRIDE; | 29 virtual bool shouldSkip() const SK_OVERRIDE; |
| 28 virtual SkString name() const SK_OVERRIDE; | 30 virtual SkString name() const SK_OVERRIDE; |
| 29 | 31 |
| 30 // Reads image files WriteTask wrote under root and compares them with bitma
p. | 32 // Reads JSON file WriteTask wrote under root and compares the bitmap with c
hecksums inside. |
| 31 class Expectations : public DM::Expectations { | 33 class Expectations : public DM::Expectations { |
| 32 public: | 34 public: |
| 33 explicit Expectations(const char* root) : fRoot(root) {} | 35 static Expectations* Create(const char*); |
| 34 | |
| 35 bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE; | 36 bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE; |
| 36 private: | 37 private: |
| 37 const char* fRoot; | 38 Expectations() {} |
| 39 Json::Value fJson; |
| 38 }; | 40 }; |
| 39 | 41 |
| 42 static void DumpJson(); |
| 43 |
| 40 private: | 44 private: |
| 41 SkTArray<SkString> fSuffixes; | 45 SkTArray<SkString> fSuffixes; |
| 42 const SkString fGmName; | 46 const SkString fFullName; |
| 47 const SkString fBaseName; |
| 43 const SkBitmap fBitmap; | 48 const SkBitmap fBitmap; |
| 44 SkAutoTDelete<SkStreamAsset> fData; | 49 SkAutoTDelete<SkStreamAsset> fData; |
| 45 const char* fExtension; | 50 const char* fExtension; |
| 46 | 51 |
| 47 void makeDirOrFail(SkString dir); | 52 void makeDirOrFail(SkString dir); |
| 48 }; | 53 }; |
| 49 | 54 |
| 50 } // namespace DM | 55 } // namespace DM |
| 51 | 56 |
| 52 #endif // DMWriteTask_DEFINED | 57 #endif // DMWriteTask_DEFINED |
| OLD | NEW |