mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 1 | #ifndef DMWriteTask_DEFINED |
| 2 | #define DMWriteTask_DEFINED |
| 3 | |
| 4 | #include "DMTask.h" |
| 5 | #include "SkBitmap.h" |
mtklein | 1d0f164 | 2014-09-08 08:05:18 -0700 | [diff] [blame] | 6 | #include "SkJSONCPP.h" |
| 7 | #include "SkStream.h" |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 8 | #include "SkString.h" |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 9 | #include "SkTArray.h" |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 10 | |
commit-bot@chromium.org | 99589af | 2013-12-10 14:53:16 +0000 | [diff] [blame] | 11 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 12 | // Writes a bitmap to a file. |
| 13 | |
| 14 | namespace DM { |
| 15 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 16 | class WriteTask : public CpuTask { |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 17 | |
| 18 | public: |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 19 | WriteTask(const Task& parent, // WriteTask must be a child task. |
| 20 | const char* sourceType, // E.g. "GM", "SKP". For humans. |
| 21 | SkBitmap bitmap); // Bitmap to encode to PNG and write to disk. |
mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 22 | |
halcanary | a4c6094 | 2014-08-26 10:38:07 -0700 | [diff] [blame] | 23 | // Takes ownership of SkStreamAsset |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 24 | WriteTask(const Task& parent, // WriteTask must be a child task. |
| 25 | const char* sourceType, // E.g. "GM", "SKP". For humans. |
| 26 | SkStreamAsset* data, // Pre-encoded data to write to disk. |
| 27 | const char* ext); // File extension. |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 28 | |
| 29 | virtual void draw() SK_OVERRIDE; |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 30 | virtual bool shouldSkip() const SK_OVERRIDE; |
| 31 | virtual SkString name() const SK_OVERRIDE; |
| 32 | |
mtklein | 1d0f164 | 2014-09-08 08:05:18 -0700 | [diff] [blame] | 33 | static void DumpJson(); |
| 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 | 1d0f164 | 2014-09-08 08:05:18 -0700 | [diff] [blame] | 37 | const SkString fBaseName; |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 38 | const SkString fSourceType; |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 39 | const SkBitmap fBitmap; |
halcanary | a4c6094 | 2014-08-26 10:38:07 -0700 | [diff] [blame] | 40 | SkAutoTDelete<SkStreamAsset> fData; |
mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 41 | const char* fExtension; |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 42 | |
| 43 | void makeDirOrFail(SkString dir); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace DM |
| 47 | |
| 48 | #endif // DMWriteTask_DEFINED |