OLD | NEW |
1 #include "DMBenchTask.h" | 1 #include "DMBenchTask.h" |
2 #include "DMUtil.h" | 2 #include "DMUtil.h" |
3 #include "SkSurface.h" | 3 #include "SkSurface.h" |
4 | 4 |
5 namespace DM { | 5 namespace DM { |
6 | 6 |
7 static SkString bench_name(const char* name, const char* config) { | 7 static SkString bench_name(const char* name, const char* config) { |
8 SkString result("bench "); | 8 SkString result("bench "); |
9 result.appendf("%s_%s", name, config); | 9 result.appendf("%s_%s", name, config); |
10 return result; | 10 return result; |
11 } | 11 } |
12 | 12 |
13 NonRenderingBenchTask::NonRenderingBenchTask(const char* config, | 13 NonRenderingBenchTask::NonRenderingBenchTask(const char* config, |
14 Reporter* reporter, | 14 Reporter* reporter, |
15 TaskRunner* tasks, | 15 TaskRunner* tasks, |
16 BenchRegistry::Factory factory) | 16 BenchRegistry::Factory factory) |
17 : Task(reporter, tasks) | 17 : CpuTask(reporter, tasks) |
18 , fBench(factory(NULL)) | 18 , fBench(factory(NULL)) |
19 , fName(bench_name(fBench->getName(), config)) {} | 19 , fName(bench_name(fBench->getName(), config)) {} |
20 | 20 |
21 CpuBenchTask::CpuBenchTask(const char* config, | 21 CpuBenchTask::CpuBenchTask(const char* config, |
22 Reporter* reporter, | 22 Reporter* reporter, |
23 TaskRunner* tasks, | 23 TaskRunner* tasks, |
24 BenchRegistry::Factory factory, | 24 BenchRegistry::Factory factory, |
25 SkColorType colorType) | 25 SkColorType colorType) |
26 : Task(reporter, tasks) | 26 : CpuTask(reporter, tasks) |
27 , fBench(factory(NULL)) | 27 , fBench(factory(NULL)) |
28 , fName(bench_name(fBench->getName(), config)) | 28 , fName(bench_name(fBench->getName(), config)) |
29 , fColorType(colorType) {} | 29 , fColorType(colorType) {} |
30 | 30 |
31 GpuBenchTask::GpuBenchTask(const char* config, | 31 GpuBenchTask::GpuBenchTask(const char* config, |
32 Reporter* reporter, | 32 Reporter* reporter, |
33 TaskRunner* tasks, | 33 TaskRunner* tasks, |
34 BenchRegistry::Factory factory, | 34 BenchRegistry::Factory factory, |
35 GrContextFactory::GLContextType contextType, | 35 GrContextFactory::GLContextType contextType, |
36 int sampleCount) | 36 int sampleCount) |
37 : Task(reporter, tasks) | 37 : GpuTask(reporter, tasks) |
38 , fBench(factory(NULL)) | 38 , fBench(factory(NULL)) |
39 , fName(bench_name(fBench->getName(), config)) | 39 , fName(bench_name(fBench->getName(), config)) |
40 , fContextType(contextType) | 40 , fContextType(contextType) |
41 , fSampleCount(sampleCount) {} | 41 , fSampleCount(sampleCount) {} |
42 | 42 |
43 bool NonRenderingBenchTask::shouldSkip() const { | 43 bool NonRenderingBenchTask::shouldSkip() const { |
44 return !fBench->isSuitableFor(SkBenchmark::kNonRendering_Backend); | 44 return !fBench->isSuitableFor(SkBenchmark::kNonRendering_Backend); |
45 } | 45 } |
46 | 46 |
47 bool CpuBenchTask::shouldSkip() const { | 47 bool CpuBenchTask::shouldSkip() const { |
(...skipping 15 matching lines...) Expand all Loading... |
63 } | 63 } |
64 | 64 |
65 void NonRenderingBenchTask::draw() { | 65 void NonRenderingBenchTask::draw() { |
66 draw_raster(fBench.get(), kPMColor_SkColorType); | 66 draw_raster(fBench.get(), kPMColor_SkColorType); |
67 } | 67 } |
68 | 68 |
69 void CpuBenchTask::draw() { | 69 void CpuBenchTask::draw() { |
70 draw_raster(fBench.get(), fColorType); | 70 draw_raster(fBench.get(), fColorType); |
71 } | 71 } |
72 | 72 |
73 void GpuBenchTask::draw() { | 73 void GpuBenchTask::draw(GrContextFactory* grFactory) { |
74 SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), | 74 SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), |
75 fBench->getSize().y(), | 75 fBench->getSize().y(), |
76 kPMColor_SkColorType, | 76 kPMColor_SkColorType, |
77 kPremul_SkAlphaType); | 77 kPremul_SkAlphaType); |
78 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget( | 78 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget( |
79 this->getGrContextFactory()->get(fContextType), info, fSampleCount))
; | 79 grFactory->get(fContextType), info, fSampleCount)); |
80 | 80 |
81 fBench->preDraw(); | 81 fBench->preDraw(); |
82 fBench->draw(1, surface->getCanvas()); | 82 fBench->draw(1, surface->getCanvas()); |
83 fBench->postDraw(); | 83 fBench->postDraw(); |
84 } | 84 } |
85 | 85 |
86 } // namespace DM | 86 } // namespace DM |
OLD | NEW |