Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
DM::GPUSink Class Reference

#include <DMSrcSink.h>

Inheritance diagram for DM::GPUSink:
DM::Sink DM::GPUDDLSink DM::GPUPersistentCacheTestingSink DM::GPUPrecompileTestingSink DM::GPURemoteSlugSink DM::GPUSerializeSlugSink DM::GPUSlugSink

Public Member Functions

 GPUSink (const SkCommandLineConfigGpu *, const GrContextOptions &)
 
Result draw (const Src &, SkBitmap *, SkWStream *, SkString *) const override
 
Result onDraw (const Src &, SkBitmap *, SkWStream *, SkString *, const GrContextOptions &baseOptions, std::function< void(GrDirectContext *)> initContext=nullptr, std::function< SkCanvas *(SkCanvas *)> wrapCanvas=nullptr) const
 
skgpu::ContextType contextType () const
 
const sk_gpu_test::GrContextFactory::ContextOverridescontextOverrides () const
 
SkCommandLineConfigGpu::SurfType surfType () const
 
bool serial () const override
 
const char * fileExtension () const override
 
SinkFlags flags () const override
 
const GrContextOptionsbaseContextOptions () const
 
void setColorSpace (sk_sp< SkColorSpace > colorSpace) override
 
SkColorInfo colorInfo () const override
 
- Public Member Functions inherited from DM::Sink
virtual ~Sink ()
 
virtual Result draw (const Src &, SkBitmap *, SkWStream *, SkString *log) const =0
 
virtual void setColorSpace (sk_sp< SkColorSpace >)
 
virtual bool serial () const
 
virtual const char * fileExtension () const =0
 
virtual SinkFlags flags () const =0
 
virtual SkColorInfo colorInfo () const
 

Protected Member Functions

sk_sp< SkSurfacecreateDstSurface (GrDirectContext *, SkISize size) const
 
bool readBack (SkSurface *, SkBitmap *dst) const
 

Detailed Description

Definition at line 367 of file DMSrcSink.h.

Constructor & Destructor Documentation

◆ GPUSink()

DM::GPUSink::GPUSink ( const SkCommandLineConfigGpu config,
const GrContextOptions grCtxOptions 
)

Definition at line 1523 of file DMSrcSink.cpp.

1525 : fContextType(config->getContextType())
1526 , fContextOverrides(config->getContextOverrides())
1527 , fSurfType(config->getSurfType())
1528 , fSampleCount(config->getSamples())
1529 , fSurfaceFlags(config->getSurfaceFlags())
1530 , fColorType(config->getColorType())
1531 , fAlphaType(config->getAlphaType())
1532 , fBaseContextOptions(grCtxOptions) {
1533 if (FLAGS_programBinaryCache) {
1534 fBaseContextOptions.fPersistentCache = &fMemoryCache;
1535 }
1536}
SurfType getSurfType() const
ContextType getContextType() const
ContextOverrides getContextOverrides() const
SkColorType getColorType() const
SkAlphaType getAlphaType() const
uint32_t getSurfaceFlags() const
PersistentCache * fPersistentCache

Member Function Documentation

◆ baseContextOptions()

const GrContextOptions & DM::GPUSink::baseContextOptions ( ) const
inline

Definition at line 389 of file DMSrcSink.h.

389{ return fBaseContextOptions; }

◆ colorInfo()

SkColorInfo DM::GPUSink::colorInfo ( ) const
inlineoverridevirtual

Returns the color type and space used by the sink.

Reimplemented from DM::Sink.

Definition at line 391 of file DMSrcSink.h.

391 {
392 return SkColorInfo(fColorType, fAlphaType, fColorSpace);
393 }

◆ contextOverrides()

const sk_gpu_test::GrContextFactory::ContextOverrides & DM::GPUSink::contextOverrides ( ) const
inline

Definition at line 378 of file DMSrcSink.h.

378 {
379 return fContextOverrides;
380 }

◆ contextType()

skgpu::ContextType DM::GPUSink::contextType ( ) const
inline

Definition at line 377 of file DMSrcSink.h.

377{ return fContextType; }

◆ createDstSurface()

sk_sp< SkSurface > DM::GPUSink::createDstSurface ( GrDirectContext context,
SkISize  size 
) const
protected

Definition at line 1542 of file DMSrcSink.cpp.

1542 {
1544
1546 SkSurfaceProps props(fSurfaceFlags, kRGB_H_SkPixelGeometry);
1547
1548 switch (fSurfType) {
1551 context, skgpu::Budgeted::kNo, info, fSampleCount, &props);
1552 break;
1555 info,
1557 fSampleCount,
1560 &props);
1561 break;
1564 info,
1566 fSampleCount,
1568 &props);
1569 break;
1570 }
1571
1572 return surface;
1573}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
@ kRGB_H_SkPixelGeometry
SkColorInfo colorInfo() const override
Definition: DMSrcSink.h:391
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
sk_sp< SkSurface > MakeBackendRenderTargetSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
sk_sp< SkSurface > MakeBackendTextureSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ draw()

Result DM::GPUSink::draw ( const Src src,
SkBitmap dst,
SkWStream dstStream,
SkString log 
) const
overridevirtual

Implements DM::Sink.

Reimplemented in DM::GPUSlugSink, DM::GPUSerializeSlugSink, DM::GPURemoteSlugSink, DM::GPUPersistentCacheTestingSink, DM::GPUPrecompileTestingSink, and DM::GPUDDLSink.

Definition at line 1538 of file DMSrcSink.cpp.

1538 {
1539 return this->onDraw(src, dst, dstStream, log, fBaseContextOptions);
1540}
Result onDraw(const Src &, SkBitmap *, SkWStream *, SkString *, const GrContextOptions &baseOptions, std::function< void(GrDirectContext *)> initContext=nullptr, std::function< SkCanvas *(SkCanvas *)> wrapCanvas=nullptr) const
Definition: DMSrcSink.cpp:1584

◆ fileExtension()

const char * DM::GPUSink::fileExtension ( ) const
inlineoverridevirtual

Implements DM::Sink.

Reimplemented in DM::GPUPersistentCacheTestingSink, and DM::GPUPrecompileTestingSink.

Definition at line 383 of file DMSrcSink.h.

383{ return "png"; }

◆ flags()

SinkFlags DM::GPUSink::flags ( ) const
inlineoverridevirtual

Implements DM::Sink.

Definition at line 384 of file DMSrcSink.h.

384 {
387 return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect, ms };
388 }
@ kNotMultisampled
Definition: DMSrcSink.h:87

◆ onDraw()

Result DM::GPUSink::onDraw ( const Src src,
SkBitmap dst,
SkWStream ,
SkString log,
const GrContextOptions baseOptions,
std::function< void(GrDirectContext *)>  initContext = nullptr,
std::function< SkCanvas *(SkCanvas *)>  wrapCanvas = nullptr 
) const

Definition at line 1584 of file DMSrcSink.cpp.

1587 {
1588 GrContextOptions grOptions = baseOptions;
1589
1590 // We don't expect the src to mess with the persistent cache or the executor.
1591 SkDEBUGCODE(auto cache = grOptions.fPersistentCache);
1592 SkDEBUGCODE(auto exec = grOptions.fExecutor);
1593 src.modifyGrContextOptions(&grOptions);
1594 SkASSERT(cache == grOptions.fPersistentCache);
1595 SkASSERT(exec == grOptions.fExecutor);
1596
1597 GrContextFactory factory(grOptions);
1598 auto direct = factory.getContextInfo(fContextType, fContextOverrides).directContext();
1599 if (initContext) {
1600 initContext(direct);
1601 }
1602
1603 const int maxDimension = direct->priv().caps()->maxTextureSize();
1604 if (maxDimension < std::max(src.size().width(), src.size().height())) {
1605 return Result::Skip("Src too large to create a texture.\n");
1606 }
1607
1608 sk_sp<SkSurface> surface = this->createDstSurface(direct, src.size());
1609 if (!surface) {
1610 return Result::Fatal("Could not create a surface.");
1611 }
1612 if (FLAGS_preAbandonGpuContext) {
1613 factory.abandonContexts();
1614 }
1615
1616 auto canvas = surface->getCanvas();
1617 if (wrapCanvas != nullptr) {
1618 canvas = wrapCanvas(canvas);
1619 }
1620
1621 Result result = src.draw(canvas, /*GraphiteTestContext=*/nullptr);
1622 if (!result.isOk()) {
1623 return result;
1624 }
1625 direct->flushAndSubmit(surface.get(), GrSyncCpu::kNo);
1626 if (FLAGS_gpuStats) {
1627 direct->priv().dumpCacheStats(log);
1628 direct->priv().dumpGpuStats(log);
1629 direct->priv().dumpContextStats(log);
1630 }
1631
1632 this->readBack(surface.get(), dst);
1633
1634 if (FLAGS_abandonGpuContext) {
1635 factory.abandonContexts();
1636 } else if (FLAGS_releaseAndAbandonGpuContext) {
1637 factory.releaseResourcesAndAbandonContexts();
1638 }
1639
1640 if (grOptions.fPersistentCache) {
1641 direct->storeVkPipelineCacheData();
1642 }
1643 return Result::Ok();
1644}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
bool readBack(SkSurface *, SkBitmap *dst) const
Definition: DMSrcSink.cpp:1575
sk_sp< SkSurface > createDstSurface(GrDirectContext *, SkISize size) const
Definition: DMSrcSink.cpp:1542
static Result Skip(const char *fmt,...) SK_PRINTF_LIKE(1
static Result Ok()
Definition: DMSrcSink.h:50
static Result Fatal(const char *fmt,...) SK_PRINTF_LIKE(1
T * get() const
Definition: SkRefCnt.h:303
GAsyncResult * result
static float max(float r, float g, float b)
Definition: hsl.cpp:49
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
dst
Definition: cp.py:12
SkExecutor * fExecutor

◆ readBack()

bool DM::GPUSink::readBack ( SkSurface surface,
SkBitmap dst 
) const
protected

Definition at line 1575 of file DMSrcSink.cpp.

1575 {
1576 SkCanvas* canvas = surface->getCanvas();
1577 SkISize size = surface->imageInfo().dimensions();
1578
1580 dst->allocPixels(info);
1581 return canvas->readPixels(*dst, 0, 0);
1582}
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
Definition: SkCanvas.cpp:382
Definition: SkSize.h:16

◆ serial()

bool DM::GPUSink::serial ( ) const
inlineoverridevirtual

Reimplemented from DM::Sink.

Definition at line 382 of file DMSrcSink.h.

382{ return true; }

◆ setColorSpace()

void DM::GPUSink::setColorSpace ( sk_sp< SkColorSpace colorSpace)
inlineoverridevirtual

Reimplemented from DM::Sink.

Definition at line 390 of file DMSrcSink.h.

390{ fColorSpace = colorSpace; }

◆ surfType()

SkCommandLineConfigGpu::SurfType DM::GPUSink::surfType ( ) const
inline

Definition at line 381 of file DMSrcSink.h.

381{ return fSurfType; }

The documentation for this class was generated from the following files: