@@ -93,6 +93,7 @@ GMSrc::GMSrc(skiagm::GMFactory factory) : fFactory(factory) {}
93
93
Result GMSrc::draw (SkCanvas* canvas) const {
94
94
std::unique_ptr<skiagm::GM> gm (fFactory ());
95
95
SkString msg;
96
+
96
97
skiagm::DrawResult drawResult = gm->draw (canvas, &msg);
97
98
switch (drawResult) {
98
99
case skiagm::DrawResult::kOk : return Result (Result::Status::Ok, msg);
@@ -1293,7 +1294,9 @@ SkISize MSKPSrc::size(int i) const {
1293
1294
return i >= 0 && i < fPages .count () ? fPages [i].fSize .toCeil () : SkISize{0 , 0 };
1294
1295
}
1295
1296
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
+ }
1297
1300
Result MSKPSrc::draw (int i, SkCanvas* canvas) const {
1298
1301
if (this ->pageCount () == 0 ) {
1299
1302
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,
1475
1478
}
1476
1479
surface->flushAndSubmit ();
1477
1480
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);
1481
1484
}
1482
1485
1483
1486
this ->readBack (surface.get (), dst);
@@ -1623,10 +1626,95 @@ Result GPUPrecompileTestingSink::draw(const Src& src, SkBitmap* dst, SkWStream*
1623
1626
}
1624
1627
1625
1628
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
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 )) {
1630
1718
}
1631
1719
1632
1720
Result GPUDDLSink::ddlDraw (const Src& src,
@@ -1735,7 +1823,7 @@ Result GPUDDLSink::ddlDraw(const Src& src,
1735
1823
return Result::Ok ();
1736
1824
}
1737
1825
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 {
1739
1827
GrContextOptions contextOptions = this ->baseContextOptions ();
1740
1828
src.modifyGrContextOptions (&contextOptions);
1741
1829
contextOptions.fPersistentCache = nullptr ;
@@ -1767,8 +1855,8 @@ Result GPUDDLSink::draw(const Src& src, SkBitmap* dst, SkWStream* stream, SkStri
1767
1855
SkASSERT(otherCtx->priv().getGpu());
1768
1856
#endif
1769
1857
1770
- SkTaskGroup recordingTaskGroup (*fRecordingThreadPool );
1771
- SkTaskGroup gpuTaskGroup (*fGPUThread );
1858
+ SkTaskGroup recordingTaskGroup (*fRecordingExecutor );
1859
+ SkTaskGroup gpuTaskGroup (*fGPUExecutor );
1772
1860
1773
1861
// Make sure 'mainCtx' is current
1774
1862
mainTestCtx->makeCurrent ();
0 commit comments