OLD | NEW |
1 #include "DMGpuTask.h" | 1 #include "DMGpuTask.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* name, | 12 GpuTask::GpuTask(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 SkColorType colorType, | |
18 GrContextFactory::GLContextType contextType, | 17 GrContextFactory::GLContextType contextType, |
19 int sampleCount) | 18 int sampleCount) |
20 : Task(reporter, taskRunner) | 19 : Task(reporter, taskRunner) |
21 , fTaskRunner(taskRunner) | |
22 , fGM(gmFactory(NULL)) | 20 , fGM(gmFactory(NULL)) |
23 , fName(UnderJoin(fGM->shortName(), name)) | 21 , fName(UnderJoin(fGM->getName(), config)) |
24 , fExpectations(expectations) | 22 , fExpectations(expectations) |
25 , fColorType(colorType) | |
26 , fContextType(contextType) | 23 , fContextType(contextType) |
27 , fSampleCount(sampleCount) | 24 , fSampleCount(sampleCount) |
28 {} | 25 {} |
29 | 26 |
30 void GpuTask::draw() { | 27 void GpuTask::draw() { |
31 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), | 28 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), |
32 SkScalarCeilToInt(fGM->height()), | 29 SkScalarCeilToInt(fGM->height()), |
33 fColorType, | 30 kPMColor_SkColorType, |
34 kPremul_SkAlphaType); | 31 kPremul_SkAlphaType); |
35 GrContext* gr = fTaskRunner->getGrContextFactory()->get(fContextType); // O
wned by surface. | 32 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget( |
36 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(gr, info, fSample
Count)); | 33 this->getGrContextFactory()->get(fContextType), info, fSampleCount))
; |
37 SkCanvas* canvas = surface->getCanvas(); | 34 SkCanvas* canvas = surface->getCanvas(); |
38 | 35 |
39 canvas->concat(fGM->getInitialTransform()); | 36 canvas->concat(fGM->getInitialTransform()); |
40 fGM->draw(canvas); | 37 fGM->draw(canvas); |
41 canvas->flush(); | 38 canvas->flush(); |
42 | 39 |
43 SkBitmap bitmap; | 40 SkBitmap bitmap; |
44 bitmap.setConfig(info); | 41 bitmap.setConfig(info); |
45 canvas->readPixels(&bitmap, 0, 0); | 42 canvas->readPixels(&bitmap, 0, 0); |
46 | 43 |
47 #if GR_CACHE_STATS | 44 #if GR_CACHE_STATS |
48 gr->printCacheStats(); | 45 gr->printCacheStats(); |
49 #endif | 46 #endif |
50 | 47 |
51 this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap)
)); | 48 this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap)
)); |
52 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 49 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
53 } | 50 } |
54 | 51 |
55 bool GpuTask::shouldSkip() const { | 52 bool GpuTask::shouldSkip() const { |
56 return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag); | 53 return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag); |
57 } | 54 } |
58 | 55 |
59 } // namespace DM | 56 } // namespace DM |
OLD | NEW |