blob: 49a5c746a64fbed20a2ec6bb26860d349af58130 [file] [log] [blame]
mtklein@google.coma7a9f372013-10-18 20:52:44 +00001#ifndef DMWriteTask_DEFINED
2#define DMWriteTask_DEFINED
3
commit-bot@chromium.org99589af2013-12-10 14:53:16 +00004#include "DMExpectations.h"
mtklein@google.coma7a9f372013-10-18 20:52:44 +00005#include "DMTask.h"
6#include "SkBitmap.h"
7#include "SkString.h"
rmistry@google.comd6bab022013-12-02 13:50:38 +00008#include "SkTArray.h"
mtklein@google.coma7a9f372013-10-18 20:52:44 +00009
commit-bot@chromium.org99589af2013-12-10 14:53:16 +000010
mtklein@google.coma7a9f372013-10-18 20:52:44 +000011// Writes a bitmap to a file.
12
13namespace DM {
14
15class WriteTask : public Task {
16
17public:
rmistry@google.comd6bab022013-12-02 13:50:38 +000018 WriteTask(const Task& parent, // WriteTask must be a child Task. Pass its parent here.
19 SkBitmap bitmap); // Bitmap to write.
mtklein@google.coma7a9f372013-10-18 20:52:44 +000020
21 virtual void draw() SK_OVERRIDE;
22 virtual bool usesGpu() const SK_OVERRIDE { return false; }
23 virtual bool shouldSkip() const SK_OVERRIDE;
24 virtual SkString name() const SK_OVERRIDE;
25
commit-bot@chromium.org99589af2013-12-10 14:53:16 +000026 // Reads image files WriteTask wrote under root and compares them with bitmap.
27 class Expectations : public DM::Expectations {
28 public:
29 explicit Expectations(const char* root) : fRoot(root) {}
30
31 bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE;
32 private:
33 const char* fRoot;
34 };
35
mtklein@google.coma7a9f372013-10-18 20:52:44 +000036private:
rmistry@google.comd6bab022013-12-02 13:50:38 +000037 SkTArray<SkString> fSuffixes;
mtklein@google.coma7a9f372013-10-18 20:52:44 +000038 SkString fGmName;
39 const SkBitmap fBitmap;
rmistry@google.comd6bab022013-12-02 13:50:38 +000040
41 void makeDirOrFail(SkString dir);
mtklein@google.coma7a9f372013-10-18 20:52:44 +000042};
43
44} // namespace DM
45
46#endif // DMWriteTask_DEFINED