OLD | NEW |
1 #include "DMGpuTask.h" | 1 #include "DMGpuGMTask.h" |
2 | 2 |
3 #include "DMExpectationsTask.h" | 3 #include "DMExpectationsTask.h" |
4 #include "DMUtil.h" | 4 #include "DMUtil.h" |
5 #include "DMWriteTask.h" | 5 #include "DMWriteTask.h" |
6 #include "SkCommandLineFlags.h" | 6 #include "SkCommandLineFlags.h" |
7 #include "SkSurface.h" | 7 #include "SkSurface.h" |
8 #include "SkTLS.h" | 8 #include "SkTLS.h" |
9 | 9 |
10 namespace DM { | 10 namespace DM { |
11 | 11 |
12 GpuTask::GpuTask(const char* config, | 12 GpuGMTask::GpuGMTask(const char* config, |
13 Reporter* reporter, | 13 Reporter* reporter, |
14 TaskRunner* taskRunner, | 14 TaskRunner* taskRunner, |
15 const Expectations& expectations, | 15 const Expectations& expectations, |
16 skiagm::GMRegistry::Factory gmFactory, | 16 skiagm::GMRegistry::Factory gmFactory, |
17 GrContextFactory::GLContextType contextType, | 17 GrContextFactory::GLContextType contextType, |
18 int sampleCount) | 18 int sampleCount) |
19 : Task(reporter, taskRunner) | 19 : GpuTask(reporter, taskRunner) |
20 , fGM(gmFactory(NULL)) | 20 , fGM(gmFactory(NULL)) |
21 , fName(UnderJoin(fGM->getName(), config)) | 21 , fName(UnderJoin(fGM->getName(), config)) |
22 , fExpectations(expectations) | 22 , fExpectations(expectations) |
23 , fContextType(contextType) | 23 , fContextType(contextType) |
24 , fSampleCount(sampleCount) | 24 , fSampleCount(sampleCount) |
25 {} | 25 {} |
26 | 26 |
27 void GpuTask::draw() { | 27 void GpuGMTask::draw(GrContextFactory* grFactory) { |
28 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), | 28 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), |
29 SkScalarCeilToInt(fGM->height()), | 29 SkScalarCeilToInt(fGM->height()), |
30 kPMColor_SkColorType, | 30 kPMColor_SkColorType, |
31 kPremul_SkAlphaType); | 31 kPremul_SkAlphaType); |
32 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget( | 32 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget( |
33 this->getGrContextFactory()->get(fContextType), info, fSampleCount))
; | 33 grFactory->get(fContextType), info, fSampleCount)); |
34 SkCanvas* canvas = surface->getCanvas(); | 34 SkCanvas* canvas = surface->getCanvas(); |
35 | 35 |
36 canvas->concat(fGM->getInitialTransform()); | 36 canvas->concat(fGM->getInitialTransform()); |
37 fGM->draw(canvas); | 37 fGM->draw(canvas); |
38 canvas->flush(); | 38 canvas->flush(); |
39 | 39 |
40 SkBitmap bitmap; | 40 SkBitmap bitmap; |
41 bitmap.setConfig(info); | 41 bitmap.setConfig(info); |
42 canvas->readPixels(&bitmap, 0, 0); | 42 canvas->readPixels(&bitmap, 0, 0); |
43 | 43 |
44 #if GR_CACHE_STATS | 44 #if GR_CACHE_STATS |
45 gr->printCacheStats(); | 45 gr->printCacheStats(); |
46 #endif | 46 #endif |
47 | 47 |
48 this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap)
)); | 48 this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap)
)); |
49 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 49 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
50 } | 50 } |
51 | 51 |
52 bool GpuTask::shouldSkip() const { | 52 bool GpuGMTask::shouldSkip() const { |
53 return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag); | 53 return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag); |
54 } | 54 } |
55 | 55 |
56 } // namespace DM | 56 } // namespace DM |
OLD | NEW |