| 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 bool useDFText) | |
| 18 : GpuTask(reporter, taskRunner) | 17 : GpuTask(reporter, taskRunner) |
| 19 , fGM(gmFactory(NULL)) | 18 , fGM(gmFactory(NULL)) |
| 20 , fName(UnderJoin(fGM->getName(), config)) | 19 , fName(UnderJoin(fGM->getName(), config)) |
| 21 , fContextType(contextType) | 20 , fContextType(contextType) |
| 22 , fGpuAPI(gpuAPI) | 21 , fGpuAPI(gpuAPI) |
| 23 , fSampleCount(sampleCount) | 22 , fSampleCount(sampleCount) |
| 24 , fUseDFText(useDFText) | |
| 25 {} | 23 {} |
| 26 | 24 |
| 27 void GpuGMTask::draw(GrContextFactory* grFactory) { | 25 void GpuGMTask::draw(GrContextFactory* grFactory) { |
| 28 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), | 26 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), |
| 29 SkScalarCeilToInt(fGM->height()), | 27 SkScalarCeilToInt(fGM->height()), |
| 30 kN32_SkColorType, | 28 kN32_SkColorType, |
| 31 kPremul_SkAlphaType); | 29 kPremul_SkAlphaType); |
| 32 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA
PI, info, | 30 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA
PI, info, |
| 33 fSampleCount, fUseDFText)); | 31 fSampleCount)); |
| 34 if (!surface) { | 32 if (!surface) { |
| 35 this->fail("Could not create context for the config and the api."); | 33 this->fail("Could not create context for the config and the api."); |
| 36 return; | 34 return; |
| 37 } | 35 } |
| 38 SkCanvas* canvas = surface->getCanvas(); | 36 SkCanvas* canvas = surface->getCanvas(); |
| 39 CanvasPreflight(canvas); | 37 CanvasPreflight(canvas); |
| 40 | 38 |
| 41 canvas->concat(fGM->getInitialTransform()); | 39 canvas->concat(fGM->getInitialTransform()); |
| 42 fGM->draw(canvas); | 40 fGM->draw(canvas); |
| 43 canvas->flush(); | 41 canvas->flush(); |
| 44 #if GR_CACHE_STATS && SK_SUPPORT_GPU | 42 #if GR_CACHE_STATS && SK_SUPPORT_GPU |
| 45 if (FLAGS_veryVerbose) { | 43 if (FLAGS_veryVerbose) { |
| 46 grFactory->get(fContextType)->printCacheStats(); | 44 grFactory->get(fContextType)->printCacheStats(); |
| 47 } | 45 } |
| 48 #endif | 46 #endif |
| 49 | 47 |
| 50 SkBitmap bitmap; | 48 SkBitmap bitmap; |
| 51 bitmap.setInfo(info); | 49 bitmap.setInfo(info); |
| 52 canvas->readPixels(&bitmap, 0, 0); | 50 canvas->readPixels(&bitmap, 0, 0); |
| 53 | 51 |
| 54 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); | 52 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); |
| 55 } | 53 } |
| 56 | 54 |
| 57 bool GpuGMTask::shouldSkip() const { | 55 bool GpuGMTask::shouldSkip() const { |
| 58 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag)
; | 56 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag)
; |
| 59 } | 57 } |
| 60 | 58 |
| 61 } // namespace DM | 59 } // namespace DM |
| OLD | NEW |