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

Side by Side Diff: dm/DMExpectations.h

Issue 546873002: Start to rework DM JSON handling. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: back to one hash Created 6 years, 3 months 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
« no previous file with comments | « dm/DM.cpp ('k') | dm/DMWriteTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef DMExpectations_DEFINED 1 #ifndef DMExpectations_DEFINED
2 #define DMExpectations_DEFINED 2 #define DMExpectations_DEFINED
3 3
4 #include "DMTask.h" 4 #include "DMTask.h"
5 #include "gm_expectations.h"
6 5
7 namespace DM { 6 namespace DM {
8 7
9 struct Expectations { 8 struct Expectations {
10 virtual ~Expectations() {} 9 virtual ~Expectations() {}
11 10
12 // Return true if bitmap is the correct output for task, else false. 11 // Return true if bitmap is the correct output for task, else false.
13 virtual bool check(const Task& task, SkBitmap bitmap) const = 0; 12 virtual bool check(const Task& task, SkBitmap bitmap) const {
14 }; 13 return true;
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 } 14 }
39
40 private:
41 skiagm::JsonExpectationsSource fGMExpectations;
42 }; 15 };
43 16
44 } // namespace DM 17 } // namespace DM
45 18
46 #endif // DMExpectations_DEFINED 19 #endif // DMExpectations_DEFINED
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | dm/DMWriteTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698