blob: 0d9dce7fd1f85ff28c6ad62072aa87bf5adf7fee [file] [log] [blame]
mtklein@google.comee21a3e2013-11-26 18:52:31 +00001#include "DMChecksumTask.h"
2#include "DMUtil.h"
3
4namespace DM {
5
6ChecksumTask::ChecksumTask(const Task& parent,
7 skiagm::Expectations expectations,
8 SkBitmap bitmap)
9 : Task(parent)
10 , fName(parent.name()) // Masquerade as parent so failures are attributed to it.
11 , fExpectations(expectations)
12 , fBitmap(bitmap)
13 {}
14
15void ChecksumTask::draw() {
16 if (fExpectations.ignoreFailure() || fExpectations.empty()) {
17 return;
18 }
19
20 const skiagm::GmResultDigest digest(fBitmap);
21 if (!fExpectations.match(digest)) {
22 this->fail();
23 }
24}
25
26} // namespace DM