Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: dm/DMExpectations.h

Issue 108963002: DM: Add support for reading a directory of images with --expectations (-r). (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments etc Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dm/DMCpuTask.cpp ('k') | dm/DMExpectationsTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifndef DMExpectations_DEFINED
2 #define DMExpectations_DEFINED
3
4 #include "DMTask.h"
5 #include "gm_expectations.h"
6
7 namespace DM {
8
9 struct Expectations {
10 virtual ~Expectations() {}
11
12 // Return true if bitmap is the correct output for task, else false.
13 virtual bool check(const Task& task, SkBitmap bitmap) const = 0;
14 };
15
16 class NoExpectations : public Expectations {
17 public:
18 NoExpectations() {}
19 bool check(const Task&, SkBitmap) const SK_OVERRIDE { return true; }
20 };
21
22 class JsonExpectations : public Expectations {
23 public:
24 explicit JsonExpectations(const char* path) : fGMExpectations(path) {}
25
26 bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE {
27 SkString filename = task.name();
28 filename.append(".png");
29 const skiagm::Expectations expectations = fGMExpectations.get(filename.c _str());
30
31 if (expectations.ignoreFailure() || expectations.empty()) {
32 return true;
33 }
34
35 // Delay this calculation as long as possible. It's expensive.
36 const skiagm::GmResultDigest digest(bitmap);
37 return expectations.match(digest);
38 }
39
40 private:
41 skiagm::JsonExpectationsSource fGMExpectations;
42 };
43
44 } // namespace DM
45
46 #endif // DMExpectations_DEFINED
OLDNEW
« no previous file with comments | « dm/DMCpuTask.cpp ('k') | dm/DMExpectationsTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698