blob: 839abd7ef14d7f70e584433318766c26fac716ba [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
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000015class WriteTask : public CpuTask {
mtklein@google.coma7a9f372013-10-18 20:52:44 +000016
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;
mtklein@google.coma7a9f372013-10-18 20:52:44 +000022 virtual bool shouldSkip() const SK_OVERRIDE;
23 virtual SkString name() const SK_OVERRIDE;
24
commit-bot@chromium.org99589af2013-12-10 14:53:16 +000025 // 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.coma7a9f372013-10-18 20:52:44 +000035private:
rmistry@google.comd6bab022013-12-02 13:50:38 +000036 SkTArray<SkString> fSuffixes;
mtklein@google.coma7a9f372013-10-18 20:52:44 +000037 SkString fGmName;
38 const SkBitmap fBitmap;
rmistry@google.comd6bab022013-12-02 13:50:38 +000039
40 void makeDirOrFail(SkString dir);
mtklein@google.coma7a9f372013-10-18 20:52:44 +000041};
42
43} // namespace DM
44
45#endif // DMWriteTask_DEFINED