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