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

#include <DMSrcSink.h>

Inheritance diagram for DM::GPUPrecompileTestingSink:
DM::GPUSink DM::Sink

Public Member Functions

 GPUPrecompileTestingSink (const SkCommandLineConfigGpu *, const GrContextOptions &)
 
Result draw (const Src &, SkBitmap *, SkWStream *, SkString *) const override
 
const char * fileExtension () const override
 
- Public Member Functions inherited from DM::GPUSink
 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
 

Additional Inherited Members

- Protected Member Functions inherited from DM::GPUSink
sk_sp< SkSurfacecreateDstSurface (GrDirectContext *, SkISize size) const
 
bool readBack (SkSurface *, SkBitmap *dst) const
 

Detailed Description

Definition at line 452 of file DMSrcSink.h.

Constructor & Destructor Documentation

◆ GPUPrecompileTestingSink()

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

Definition at line 1743 of file DMSrcSink.cpp.

1745 : INHERITED(config, grCtxOptions) {}

Member Function Documentation

◆ draw()

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

Reimplemented from DM::GPUSink.

Definition at line 1747 of file DMSrcSink.cpp.

1748 {
1749 // Three step process:
1750 // 1) Draw once with an SkSL cache, and store off the shader blobs.
1751 // 2) For the second context, pre-compile the shaders to warm the cache.
1752 // 3) Draw with the second context, ensuring that we get the same result, and no cache misses.
1753 sk_gpu_test::MemoryCache memoryCache;
1754 GrContextOptions contextOptions = this->baseContextOptions();
1755 contextOptions.fPersistentCache = &memoryCache;
1757
1758 Result result = this->onDraw(src, dst, wStream, log, contextOptions);
1759 if (!result.isOk() || !dst) {
1760 return result;
1761 }
1762
1763 auto precompileShaders = [&memoryCache](GrDirectContext* dContext) {
1764 memoryCache.foreach([dContext](sk_sp<const SkData> key,
1766 const SkString& /*description*/,
1767 int /*count*/) {
1768 SkAssertResult(dContext->precompileShader(*key, *data));
1769 });
1770 };
1771
1772 sk_gpu_test::MemoryCache replayCache;
1773 GrContextOptions replayOptions = this->baseContextOptions();
1774 // Ensure that the runtime cache is large enough to hold all of the shaders we pre-compile
1775 replayOptions.fRuntimeProgramCacheSize = memoryCache.numCacheMisses();
1776 replayOptions.fPersistentCache = &replayCache;
1777
1778 SkBitmap reference;
1779 SkString refLog;
1780 SkDynamicMemoryWStream refStream;
1781 Result refResult = this->onDraw(src, &reference, &refStream, &refLog, replayOptions,
1782 precompileShaders);
1783 if (!refResult.isOk()) {
1784 return refResult;
1785 }
1786 SkASSERT(!replayCache.numCacheMisses());
1787
1788 return compare_bitmaps(reference, *dst);
1789}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
#define SkASSERT(cond)
Definition: SkAssert.h:116
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
const GrContextOptions & baseContextOptions() const
Definition: DMSrcSink.h:389
int numCacheMisses() const
Definition: MemoryCache.h:37
void foreach(Fn &&fn)
Definition: MemoryCache.h:47
GAsyncResult * result
static Result compare_bitmaps(const SkBitmap &reference, const SkBitmap &bitmap)
Definition: DMSrcSink.cpp:1481
dst
Definition: cp.py:12
PersistentCache * fPersistentCache
ShaderCacheStrategy fShaderCacheStrategy
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ fileExtension()

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

Reimplemented from DM::GPUSink.

Definition at line 458 of file DMSrcSink.h.

458 {
459 // Suppress writing out results from this config - we just want to do our matching test
460 return nullptr;
461 }

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