aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMChecksumTask.cpp
blob: 0d9dce7fd1f85ff28c6ad62072aa87bf5adf7fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "DMChecksumTask.h"
#include "DMUtil.h"

namespace DM {

ChecksumTask::ChecksumTask(const Task& parent,
                           skiagm::Expectations expectations,
                           SkBitmap bitmap)
    : Task(parent)
    , fName(parent.name())  // Masquerade as parent so failures are attributed to it.
    , fExpectations(expectations)
    , fBitmap(bitmap)
    {}

void ChecksumTask::draw() {
    if (fExpectations.ignoreFailure() || fExpectations.empty()) {
        return;
    }

    const skiagm::GmResultDigest digest(fBitmap);
    if (!fExpectations.match(digest)) {
        this->fail();
    }
}

}  // namespace DM