OLD | NEW |
1 #include "DMGpuGMTask.h" | 1 #include "DMGpuGMTask.h" |
2 #include "DMUtil.h" | 2 #include "DMUtil.h" |
3 #include "DMWriteTask.h" | 3 #include "DMWriteTask.h" |
4 #include "SkCommonFlags.h" | 4 #include "SkCommonFlags.h" |
5 #include "SkSurface.h" | 5 #include "SkSurface.h" |
6 #include "SkTLS.h" | 6 #include "SkTLS.h" |
7 | 7 |
8 namespace DM { | 8 namespace DM { |
9 | 9 |
10 GpuGMTask::GpuGMTask(const char* config, | 10 GpuGMTask::GpuGMTask(const char* config, |
11 Reporter* reporter, | 11 Reporter* reporter, |
12 TaskRunner* taskRunner, | 12 TaskRunner* taskRunner, |
13 skiagm::GMRegistry::Factory gmFactory, | 13 skiagm::GMRegistry::Factory gmFactory, |
14 GrContextFactory::GLContextType contextType, | 14 GrContextFactory::GLContextType contextType, |
15 GrGLStandard gpuAPI, | 15 GrGLStandard gpuAPI, |
16 int sampleCount) | 16 int sampleCount) |
17 : GpuTask(reporter, taskRunner) | 17 : GpuTask(reporter, taskRunner) |
18 , fGM(gmFactory(NULL)) | 18 , fGM(gmFactory(NULL)) |
19 , fName(UnderJoin(fGM->getName(), config)) | 19 , fName(UnderJoin(fGM->getName(), config)) |
20 , fContextType(contextType) | 20 , fContextType(contextType) |
21 , fGpuAPI(gpuAPI) | 21 , fGpuAPI(gpuAPI) |
22 , fSampleCount(sampleCount) | 22 , fSampleCount(sampleCount) |
23 {} | 23 {} |
24 | 24 |
| 25 static bool gAlreadyWarned[GrContextFactory::kGLContextTypeCnt][kGrGLStandardCnt
]; |
| 26 |
25 void GpuGMTask::draw(GrContextFactory* grFactory) { | 27 void GpuGMTask::draw(GrContextFactory* grFactory) { |
26 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), | 28 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), |
27 SkScalarCeilToInt(fGM->height()), | 29 SkScalarCeilToInt(fGM->height()), |
28 kN32_SkColorType, | 30 kN32_SkColorType, |
29 kPremul_SkAlphaType); | 31 kPremul_SkAlphaType); |
30 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA
PI, info, | 32 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA
PI, info, |
31 fSampleCount)); | 33 fSampleCount)); |
32 if (!surface) { | 34 if (!surface) { |
33 this->fail("Could not create context for the config and the api."); | 35 if (!gAlreadyWarned[fContextType][fGpuAPI]) { |
| 36 SkDebugf("FYI: couldn't create GPU context, type %d API %d. Will sk
ip.\n", |
| 37 fContextType, fGpuAPI); |
| 38 gAlreadyWarned[fContextType][fGpuAPI] = true; |
| 39 } |
34 return; | 40 return; |
35 } | 41 } |
36 SkCanvas* canvas = surface->getCanvas(); | 42 SkCanvas* canvas = surface->getCanvas(); |
37 CanvasPreflight(canvas); | 43 CanvasPreflight(canvas); |
38 | 44 |
39 canvas->concat(fGM->getInitialTransform()); | 45 canvas->concat(fGM->getInitialTransform()); |
40 fGM->draw(canvas); | 46 fGM->draw(canvas); |
41 canvas->flush(); | 47 canvas->flush(); |
42 #if GR_CACHE_STATS && SK_SUPPORT_GPU | 48 #if GR_CACHE_STATS && SK_SUPPORT_GPU |
43 if (FLAGS_veryVerbose) { | 49 if (FLAGS_veryVerbose) { |
44 grFactory->get(fContextType)->printCacheStats(); | 50 grFactory->get(fContextType)->printCacheStats(); |
45 } | 51 } |
46 #endif | 52 #endif |
47 | 53 |
48 SkBitmap bitmap; | 54 SkBitmap bitmap; |
49 bitmap.setInfo(info); | 55 bitmap.setInfo(info); |
50 canvas->readPixels(&bitmap, 0, 0); | 56 canvas->readPixels(&bitmap, 0, 0); |
51 | 57 |
52 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); | 58 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); |
53 } | 59 } |
54 | 60 |
55 bool GpuGMTask::shouldSkip() const { | 61 bool GpuGMTask::shouldSkip() const { |
56 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag)
; | 62 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag)
; |
57 } | 63 } |
58 | 64 |
59 } // namespace DM | 65 } // namespace DM |
OLD | NEW |