OLD | NEW |
1 #include "DMCpuTask.h" | 1 #include "DMCpuTask.h" |
2 #include "DMReplayTask.h" | 2 #include "DMReplayTask.h" |
3 #include "DMUtil.h" | 3 #include "DMUtil.h" |
4 #include "SkCommandLineFlags.h" | 4 #include "SkCommandLineFlags.h" |
5 | 5 |
6 DEFINE_bool(replay, false, "If true, run replay tests for each CpuTask."); | 6 DEFINE_bool(replay, false, "If true, run replay tests for each CpuTask."); |
7 // TODO(mtklein): add the other various options | 7 // TODO(mtklein): add the other various options |
8 | 8 |
9 namespace DM { | 9 namespace DM { |
10 | 10 |
11 CpuTask::CpuTask(const char* name, | 11 CpuTask::CpuTask(const char* name, |
12 Reporter* reporter, | 12 Reporter* reporter, |
13 TaskRunner* taskRunner, | 13 TaskRunner* taskRunner, |
14 const skiagm::ExpectationsSource& expectations, | 14 const skiagm::ExpectationsSource& expectations, |
15 skiagm::GMRegistry::Factory gmFactory, | 15 skiagm::GMRegistry::Factory gmFactory, |
16 SkBitmap::Config config) | 16 SkBitmap::Config config) |
17 : Task(reporter, taskRunner) | 17 : Task(reporter, taskRunner) |
18 , fGMFactory(gmFactory) | 18 , fGMFactory(gmFactory) |
19 , fGM(fGMFactory(NULL)) | 19 , fGM(fGMFactory(NULL)) |
20 , fName(underJoin(fGM->shortName(), name)) | 20 , fName(underJoin(fGM->shortName(), name)) |
21 , fExpectations(expectations.get(png(fName).c_str())) | 21 , fExpectations(expectations.get(png(fName).c_str())) |
22 , fConfig(config) | 22 , fConfig(config) |
23 {} | 23 {} |
24 | 24 |
25 void CpuTask::draw() { | 25 void CpuTask::draw() { |
26 SkBitmap bitmap; | 26 SkBitmap bitmap; |
27 bitmap.setConfig(fConfig, fGM->width(), fGM->height()); | 27 bitmap.setConfig(fConfig, SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt
(fGM->height())); |
28 bitmap.allocPixels(); | 28 bitmap.allocPixels(); |
29 bitmap.eraseColor(0x00000000); | 29 bitmap.eraseColor(0x00000000); |
30 SkCanvas canvas(bitmap); | 30 SkCanvas canvas(bitmap); |
31 | 31 |
32 canvas.concat(fGM->getInitialTransform()); | 32 canvas.concat(fGM->getInitialTransform()); |
33 fGM->draw(&canvas); | 33 fGM->draw(&canvas); |
34 canvas.flush(); | 34 canvas.flush(); |
35 | 35 |
36 const skiagm::GmResultDigest digest(bitmap); | 36 const skiagm::GmResultDigest digest(bitmap); |
37 if (!meetsExpectations(fExpectations, digest)) { | 37 if (!meetsExpectations(fExpectations, digest)) { |
(...skipping 10 matching lines...) Expand all Loading... |
48 if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::k
Skip565_Flag)) { | 48 if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::k
Skip565_Flag)) { |
49 return true; | 49 return true; |
50 } | 50 } |
51 if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) { | 51 if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) { |
52 return true; | 52 return true; |
53 } | 53 } |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 } // namespace DM | 57 } // namespace DM |
OLD | NEW |