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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return kGPUDisabled || !fBench->isSuitableFor(SkBenchmark::kGPU_Backend); | 52 return kGPUDisabled || !fBench->isSuitableFor(SkBenchmark::kGPU_Backend); |
53 } | 53 } |
54 | 54 |
55 static void draw_raster(SkBenchmark* bench, SkColorType colorType) { | 55 static void draw_raster(SkBenchmark* bench, SkColorType colorType) { |
56 SkBitmap bitmap; | 56 SkBitmap bitmap; |
57 AllocatePixels(colorType, bench->getSize().x(), bench->getSize().y(), &bitma
p); | 57 AllocatePixels(colorType, bench->getSize().x(), bench->getSize().y(), &bitma
p); |
58 SkCanvas canvas(bitmap); | 58 SkCanvas canvas(bitmap); |
59 | 59 |
60 bench->preDraw(); | 60 bench->preDraw(); |
61 bench->draw(1, &canvas); | 61 bench->draw(1, &canvas); |
62 bench->postDraw(); | |
63 } | 62 } |
64 | 63 |
65 void NonRenderingBenchTask::draw() { | 64 void NonRenderingBenchTask::draw() { |
66 draw_raster(fBench.get(), kN32_SkColorType); | 65 draw_raster(fBench.get(), kN32_SkColorType); |
67 } | 66 } |
68 | 67 |
69 void CpuBenchTask::draw() { | 68 void CpuBenchTask::draw() { |
70 draw_raster(fBench.get(), fColorType); | 69 draw_raster(fBench.get(), fColorType); |
71 } | 70 } |
72 | 71 |
73 void GpuBenchTask::draw(GrContextFactory* grFactory) { | 72 void GpuBenchTask::draw(GrContextFactory* grFactory) { |
74 SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), | 73 SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), |
75 fBench->getSize().y(), | 74 fBench->getSize().y(), |
76 kN32_SkColorType, | 75 kN32_SkColorType, |
77 kPremul_SkAlphaType); | 76 kPremul_SkAlphaType); |
78 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, info,
fSampleCount)); | 77 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, info,
fSampleCount)); |
79 | 78 |
80 fBench->preDraw(); | 79 fBench->preDraw(); |
81 fBench->draw(1, surface->getCanvas()); | 80 fBench->draw(1, surface->getCanvas()); |
82 fBench->postDraw(); | |
83 } | 81 } |
84 | 82 |
85 } // namespace DM | 83 } // namespace DM |
OLD | NEW |