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