mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 1 | #ifndef DMWriteTask_DEFINED |
| 2 | #define DMWriteTask_DEFINED |
| 3 | |
commit-bot@chromium.org | 99589af | 2013-12-10 14:53:16 +0000 | [diff] [blame] | 4 | #include "DMExpectations.h" |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 5 | #include "DMTask.h" |
| 6 | #include "SkBitmap.h" |
| 7 | #include "SkString.h" |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 8 | #include "SkTArray.h" |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 9 | |
commit-bot@chromium.org | 99589af | 2013-12-10 14:53:16 +0000 | [diff] [blame] | 10 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 11 | // Writes a bitmap to a file. |
| 12 | |
| 13 | namespace DM { |
| 14 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 15 | class WriteTask : public CpuTask { |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 16 | |
| 17 | public: |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 18 | WriteTask(const Task& parent, // WriteTask must be a child Task. Pass its parent here. |
| 19 | SkBitmap bitmap); // Bitmap to write. |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 20 | |
| 21 | virtual void draw() SK_OVERRIDE; |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 22 | virtual bool shouldSkip() const SK_OVERRIDE; |
| 23 | virtual SkString name() const SK_OVERRIDE; |
| 24 | |
commit-bot@chromium.org | 99589af | 2013-12-10 14:53:16 +0000 | [diff] [blame] | 25 | // Reads image files WriteTask wrote under root and compares them with bitmap. |
| 26 | class Expectations : public DM::Expectations { |
| 27 | public: |
| 28 | explicit Expectations(const char* root) : fRoot(root) {} |
| 29 | |
| 30 | bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE; |
| 31 | private: |
| 32 | const char* fRoot; |
| 33 | }; |
| 34 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 35 | private: |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 36 | SkTArray<SkString> fSuffixes; |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 37 | SkString fGmName; |
| 38 | const SkBitmap fBitmap; |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 39 | |
| 40 | void makeDirOrFail(SkString dir); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | } // namespace DM |
| 44 | |
| 45 | #endif // DMWriteTask_DEFINED |