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; |
(...skipping 15 matching lines...) Expand all Loading... |
26 : CpuTask(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 GrGLStandard gpuAPI, |
36 int sampleCount) | 37 int sampleCount) |
37 : GpuTask(reporter, tasks) | 38 : GpuTask(reporter, tasks) |
38 , fBench(factory(NULL)) | 39 , fBench(factory(NULL)) |
39 , fName(bench_name(fBench->getName(), config)) | 40 , fName(bench_name(fBench->getName(), config)) |
40 , fContextType(contextType) | 41 , fContextType(contextType) |
| 42 , fGpuAPI(gpuAPI) |
41 , fSampleCount(sampleCount) {} | 43 , fSampleCount(sampleCount) {} |
42 | 44 |
43 bool NonRenderingBenchTask::shouldSkip() const { | 45 bool NonRenderingBenchTask::shouldSkip() const { |
44 return !fBench->isSuitableFor(Benchmark::kNonRendering_Backend); | 46 return !fBench->isSuitableFor(Benchmark::kNonRendering_Backend); |
45 } | 47 } |
46 | 48 |
47 bool CpuBenchTask::shouldSkip() const { | 49 bool CpuBenchTask::shouldSkip() const { |
48 return !fBench->isSuitableFor(Benchmark::kRaster_Backend); | 50 return !fBench->isSuitableFor(Benchmark::kRaster_Backend); |
49 } | 51 } |
50 | 52 |
(...skipping 16 matching lines...) Expand all Loading... |
67 | 69 |
68 void CpuBenchTask::draw() { | 70 void CpuBenchTask::draw() { |
69 draw_raster(fBench.get(), fColorType); | 71 draw_raster(fBench.get(), fColorType); |
70 } | 72 } |
71 | 73 |
72 void GpuBenchTask::draw(GrContextFactory* grFactory) { | 74 void GpuBenchTask::draw(GrContextFactory* grFactory) { |
73 SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), | 75 SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), |
74 fBench->getSize().y(), | 76 fBench->getSize().y(), |
75 kN32_SkColorType, | 77 kN32_SkColorType, |
76 kPremul_SkAlphaType); | 78 kPremul_SkAlphaType); |
77 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, info,
fSampleCount)); | 79 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA
PI, info, |
78 | 80 fSampleCount)); |
| 81 if (!surface) { |
| 82 this->fail("Could not create context for the config and the api."); |
| 83 return; |
| 84 } |
79 fBench->preDraw(); | 85 fBench->preDraw(); |
80 fBench->draw(1, surface->getCanvas()); | 86 fBench->draw(1, surface->getCanvas()); |
81 } | 87 } |
82 | 88 |
83 } // namespace DM | 89 } // namespace DM |
OLD | NEW |