OLD | NEW |
1 #ifndef DMWriteTask_DEFINED | 1 #ifndef DMWriteTask_DEFINED |
2 #define DMWriteTask_DEFINED | 2 #define DMWriteTask_DEFINED |
3 | 3 |
4 #include "DMTask.h" | 4 #include "DMTask.h" |
5 #include "SkBitmap.h" | 5 #include "SkBitmap.h" |
6 #include "SkStream.h" | 6 #include "SkStream.h" |
7 #include "SkString.h" | 7 #include "SkString.h" |
8 #include "SkTArray.h" | 8 #include "SkTArray.h" |
9 | 9 |
10 | 10 |
11 // Writes a bitmap to a file. | 11 // Writes a bitmap to a file. |
12 | 12 |
13 namespace DM { | 13 namespace DM { |
14 | 14 |
15 class WriteTask : public CpuTask { | 15 class WriteTask : public CpuTask { |
16 | 16 |
17 public: | 17 public: |
18 WriteTask(const Task& parent, // WriteTask must be a child task. | 18 WriteTask(const Task& parent, // WriteTask must be a child task. |
19 const char* sourceType, // E.g. "GM", "SKP". For humans. | 19 const char* sourceType, // E.g. "GM", "SKP". For humans. |
20 SkBitmap bitmap); // Bitmap to encode to PNG and write to d
isk. | 20 SkBitmap bitmap); // Bitmap to encode to PNG and write to d
isk. |
21 | 21 |
22 // Takes ownership of SkStreamAsset | 22 // Takes ownership of SkStreamAsset |
23 WriteTask(const Task& parent, // WriteTask must be a child task. | 23 WriteTask(const Task& parent, // WriteTask must be a child task. |
24 const char* sourceType, // E.g. "GM", "SKP". For humans. | 24 const char* sourceType, // E.g. "GM", "SKP". For humans. |
25 SkStreamAsset* data, // Pre-encoded data to write to disk. | 25 SkStreamAsset* data, // Pre-encoded data to write to disk. |
26 const char* ext); // File extension. | 26 const char* ext); // File extension. |
27 | 27 |
28 virtual void draw() SK_OVERRIDE; | 28 void draw() SK_OVERRIDE; |
29 virtual bool shouldSkip() const SK_OVERRIDE; | 29 bool shouldSkip() const SK_OVERRIDE; |
30 virtual SkString name() const SK_OVERRIDE; | 30 SkString name() const SK_OVERRIDE; |
31 | 31 |
32 private: | 32 private: |
33 SkTArray<SkString> fSuffixes; | 33 SkTArray<SkString> fSuffixes; |
34 const SkString fBaseName; | 34 const SkString fBaseName; |
35 const SkString fSourceType; | 35 const SkString fSourceType; |
36 const SkBitmap fBitmap; | 36 const SkBitmap fBitmap; |
37 SkAutoTDelete<SkStreamAsset> fData; | 37 SkAutoTDelete<SkStreamAsset> fData; |
38 const char* fExtension; | 38 const char* fExtension; |
39 | 39 |
40 void makeDirOrFail(SkString dir); | 40 void makeDirOrFail(SkString dir); |
41 }; | 41 }; |
42 | 42 |
43 } // namespace DM | 43 } // namespace DM |
44 | 44 |
45 #endif // DMWriteTask_DEFINED | 45 #endif // DMWriteTask_DEFINED |
OLD | NEW |