@@ -93,6 +93,7 @@ GMSrc::GMSrc(skiagm::GMFactory factory) : fFactory(factory) {}
9393Result GMSrc::draw (SkCanvas* canvas) const {
9494 std::unique_ptr<skiagm::GM> gm (fFactory ());
9595 SkString msg;
96+
9697 skiagm::DrawResult drawResult = gm->draw (canvas, &msg);
9798 switch (drawResult) {
9899 case skiagm::DrawResult::kOk : return Result (Result::Status::Ok, msg);
@@ -1293,7 +1294,9 @@ SkISize MSKPSrc::size(int i) const {
12931294 return i >= 0 && i < fPages .count () ? fPages [i].fSize .toCeil () : SkISize{0 , 0 };
12941295}
12951296
1296- Result MSKPSrc::draw (SkCanvas* c) const { return this ->draw (0 , c); }
1297+ Result MSKPSrc::draw (SkCanvas* c) const {
1298+ return this ->draw (0 , c);
1299+ }
12971300Result MSKPSrc::draw (int i, SkCanvas* canvas) const {
12981301 if (this ->pageCount () == 0 ) {
12991302 return Result::Fatal (" Unable to parse MultiPictureDocument file: %s" , fPath .c_str ());
@@ -1475,9 +1478,9 @@ Result GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
14751478 }
14761479 surface->flushAndSubmit ();
14771480 if (FLAGS_gpuStats) {
1478- canvas-> getGrContext () ->priv ().dumpCacheStats (log);
1479- canvas-> getGrContext () ->priv ().dumpGpuStats (log);
1480- canvas-> getGrContext () ->priv ().dumpContextStats (log);
1481+ context ->priv ().dumpCacheStats (log);
1482+ context ->priv ().dumpGpuStats (log);
1483+ context ->priv ().dumpContextStats (log);
14811484 }
14821485
14831486 this ->readBack (surface.get (), dst);
@@ -1623,10 +1626,95 @@ Result GPUPrecompileTestingSink::draw(const Src& src, SkBitmap* dst, SkWStream*
16231626}
16241627
16251628/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1626- GPUDDLSink::GPUDDLSink (const SkCommandLineConfigGpu* config, const GrContextOptions& grCtxOptions)
1627- : INHERITED(config, grCtxOptions)
1628- , fRecordingThreadPool(SkExecutor::MakeLIFOThreadPool(1 )) // TODO: this should be at least 2
1629- , fGPUThread(SkExecutor::MakeFIFOThreadPool(1 , false )) {
1629+ GPUOOPRSink::GPUOOPRSink (const SkCommandLineConfigGpu* config, const GrContextOptions& ctxOptions)
1630+ : INHERITED(config, ctxOptions) {
1631+ }
1632+
1633+ Result GPUOOPRSink::ooprDraw (const Src& src,
1634+ sk_sp<SkSurface> dstSurface,
1635+ GrContext* context) const {
1636+ SkSurfaceCharacterization dstCharacterization;
1637+ SkAssertResult (dstSurface->characterize (&dstCharacterization));
1638+
1639+ SkDeferredDisplayListRecorder recorder (dstCharacterization);
1640+
1641+ Result result = src.draw (recorder.getCanvas ());
1642+ if (!result.isOk ()) {
1643+ return result;
1644+ }
1645+
1646+ std::unique_ptr<SkDeferredDisplayList> ddl = recorder.detach ();
1647+
1648+ SkDeferredDisplayList::ProgramIterator iter (context, ddl.get ());
1649+ for (; !iter.done (); iter.next ()) {
1650+ iter.compile ();
1651+ }
1652+
1653+ dstSurface->draw (ddl.get ());
1654+
1655+ // TODO: remove this flush once DDLs are reffed by the drawing manager
1656+ context->flushAndSubmit ();
1657+
1658+ ddl.reset ();
1659+
1660+ return Result::Ok ();
1661+ }
1662+
1663+ Result GPUOOPRSink::draw (const Src& src, SkBitmap* dst, SkWStream*, SkString* log) const {
1664+ GrContextOptions contextOptions = this ->baseContextOptions ();
1665+ src.modifyGrContextOptions (&contextOptions);
1666+ contextOptions.fPersistentCache = nullptr ;
1667+ contextOptions.fExecutor = nullptr ;
1668+
1669+ GrContextFactory factory (contextOptions);
1670+
1671+ ContextInfo ctxInfo = factory.getContextInfo (this ->contextType (), this ->contextOverrides ());
1672+ GrContext* context = ctxInfo.grContext ();
1673+ if (!context) {
1674+ return Result::Fatal (" Could not create context." );
1675+ }
1676+
1677+ SkASSERT (context->priv ().getGpu ());
1678+
1679+ GrBackendTexture backendTexture;
1680+ GrBackendRenderTarget backendRT;
1681+ sk_sp<SkSurface> surface = this ->createDstSurface (context, src.size (),
1682+ &backendTexture, &backendRT);
1683+ if (!surface) {
1684+ return Result::Fatal (" Could not create a surface." );
1685+ }
1686+
1687+ Result result = this ->ooprDraw (src, surface, context);
1688+ if (!result.isOk ()) {
1689+ return result;
1690+ }
1691+
1692+ if (FLAGS_gpuStats) {
1693+ context->priv ().dumpCacheStats (log);
1694+ context->priv ().dumpGpuStats (log);
1695+ context->priv ().dumpContextStats (log);
1696+ }
1697+
1698+ if (!this ->readBack (surface.get (), dst)) {
1699+ return Result::Fatal (" Could not readback from surface." );
1700+ }
1701+
1702+ surface.reset ();
1703+ if (backendTexture.isValid ()) {
1704+ context->deleteBackendTexture (backendTexture);
1705+ }
1706+ if (backendRT.isValid ()) {
1707+ context->priv ().getGpu ()->deleteTestingOnlyBackendRenderTarget (backendRT);
1708+ }
1709+
1710+ return Result::Ok ();
1711+ }
1712+
1713+ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1714+ GPUDDLSink::GPUDDLSink (const SkCommandLineConfigGpu* config, const GrContextOptions& ctxOptions)
1715+ : INHERITED(config, ctxOptions)
1716+ , fRecordingExecutor(SkExecutor::MakeLIFOThreadPool(1 ))
1717+ , fGPUExecutor(SkExecutor::MakeFIFOThreadPool(1 , false )) {
16301718}
16311719
16321720Result GPUDDLSink::ddlDraw (const Src& src,
@@ -1735,7 +1823,7 @@ Result GPUDDLSink::ddlDraw(const Src& src,
17351823 return Result::Ok ();
17361824}
17371825
1738- Result GPUDDLSink::draw (const Src& src, SkBitmap* dst, SkWStream* stream , SkString* log) const {
1826+ Result GPUDDLSink::draw (const Src& src, SkBitmap* dst, SkWStream*, SkString* log) const {
17391827 GrContextOptions contextOptions = this ->baseContextOptions ();
17401828 src.modifyGrContextOptions (&contextOptions);
17411829 contextOptions.fPersistentCache = nullptr ;
@@ -1767,8 +1855,8 @@ Result GPUDDLSink::draw(const Src& src, SkBitmap* dst, SkWStream* stream, SkStri
17671855 SkASSERT(otherCtx->priv().getGpu());
17681856#endif
17691857
1770- SkTaskGroup recordingTaskGroup (*fRecordingThreadPool );
1771- SkTaskGroup gpuTaskGroup (*fGPUThread );
1858+ SkTaskGroup recordingTaskGroup (*fRecordingExecutor );
1859+ SkTaskGroup gpuTaskGroup (*fGPUExecutor );
17721860
17731861 // Make sure 'mainCtx' is current
17741862 mainTestCtx->makeCurrent ();
0 commit comments