void GpuGMTask::draw(GrContextFactory* grFactory) { SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt(fGM->height()), kN32_SkColorType, kPremul_SkAlphaType); SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuAPI, info, fSampleCount)); if (!surface) { if (!gAlreadyWarned[fContextType][fGpuAPI]) { SkDebugf("FYI: couldn't create GPU context, type %d API %d. Will skip.\n", fContextType, fGpuAPI); gAlreadyWarned[fContextType][fGpuAPI] = true; } return; } SkCanvas* canvas = surface->getCanvas(); CanvasPreflight(canvas); canvas->concat(fGM->getInitialTransform()); fGM->draw(canvas); canvas->flush(); #if GR_CACHE_STATS && SK_SUPPORT_GPU if (FLAGS_veryVerbose) { grFactory->get(fContextType)->printCacheStats(); } #endif SkBitmap bitmap; bitmap.setInfo(info); canvas->readPixels(&bitmap, 0, 0); this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); }
void GpuBenchTask::draw(GrContextFactory* grFactory) { SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(), fBench->getSize().y(), kN32_SkColorType, kPremul_SkAlphaType); SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, info, fSampleCount)); fBench->preDraw(); fBench->draw(1, surface->getCanvas()); }
void GpuGMTask::draw(GrContextFactory* grFactory) { SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt(fGM->height()), kPMColor_SkColorType, kPremul_SkAlphaType); SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, info, fSampleCount)); SkCanvas* canvas = surface->getCanvas(); canvas->concat(fGM->getInitialTransform()); fGM->draw(canvas); canvas->flush(); SkBitmap bitmap; bitmap.setConfig(info); canvas->readPixels(&bitmap, 0, 0); this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap))); this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); }