Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::DlSurfaceProvider Class Referenceabstract

#include <dl_test_surface_provider.h>

Inheritance diagram for flutter::testing::DlSurfaceProvider:
flutter::testing::DlMetalSurfaceProvider flutter::testing::DlOpenGLSurfaceProvider flutter::testing::DlSoftwareSurfaceProvider

Public Types

enum  PixelFormat {
  kN32PremulPixelFormat ,
  k565PixelFormat
}
 
enum  BackendType {
  kSoftwareBackend ,
  kOpenGlBackend ,
  kMetalBackend
}
 

Public Member Functions

virtual ~DlSurfaceProvider ()=default
 
virtual const std::string backend_name () const =0
 
virtual BackendType backend_type () const =0
 
virtual bool supports (PixelFormat format) const =0
 
virtual bool supports_impeller () const
 
virtual bool InitializeSurface (size_t width, size_t height, PixelFormat format=kN32PremulPixelFormat)=0
 
virtual std::shared_ptr< DlSurfaceInstanceGetPrimarySurface () const =0
 
virtual std::shared_ptr< DlSurfaceInstanceMakeOffscreenSurface (size_t width, size_t height, PixelFormat format=kN32PremulPixelFormat) const =0
 
virtual bool Snapshot (std::string &filename) const
 
virtual sk_sp< DlPixelDataImpellerSnapshot (const sk_sp< DisplayList > &list, int width, int height) const
 
virtual sk_sp< DlImageMakeImpellerImage (const sk_sp< DisplayList > &list, int width, int height) const
 

Static Public Member Functions

static SkImageInfo MakeInfo (PixelFormat format, int w, int h)
 
static std::string BackendName (BackendType type)
 
static std::unique_ptr< DlSurfaceProviderCreate (BackendType backend_type)
 

Protected Member Functions

 DlSurfaceProvider ()=default
 

Detailed Description

Definition at line 57 of file dl_test_surface_provider.h.

Member Enumeration Documentation

◆ BackendType

◆ PixelFormat

Constructor & Destructor Documentation

◆ ~DlSurfaceProvider()

virtual flutter::testing::DlSurfaceProvider::~DlSurfaceProvider ( )
virtualdefault

◆ DlSurfaceProvider()

flutter::testing::DlSurfaceProvider::DlSurfaceProvider ( )
protecteddefault

Member Function Documentation

◆ backend_name()

virtual const std::string flutter::testing::DlSurfaceProvider::backend_name ( ) const
pure virtual

◆ backend_type()

◆ BackendName()

std::string flutter::testing::DlSurfaceProvider::BackendName ( BackendType  type)
static

Definition at line 12 of file dl_test_surface_provider.cc.

12 {
13 switch (type) {
15 return "Software";
16 case kOpenGlBackend:
17 return "OpenGL";
18 case kMetalBackend:
19 return "Metal";
20 }
21}
GLenum type

References kMetalBackend, kOpenGlBackend, kSoftwareBackend, and type.

Referenced by flutter::testing::CanvasCompareTester::GetProvider(), and flutter::testing::DisplayListRenderingTestBase< BaseT >::SetUpTestSuite().

◆ Create()

◆ GetPrimarySurface()

virtual std::shared_ptr< DlSurfaceInstance > flutter::testing::DlSurfaceProvider::GetPrimarySurface ( ) const
pure virtual

◆ ImpellerSnapshot()

virtual sk_sp< DlPixelData > flutter::testing::DlSurfaceProvider::ImpellerSnapshot ( const sk_sp< DisplayList > &  list,
int  width,
int  height 
) const
inlinevirtual

Reimplemented in flutter::testing::DlMetalSurfaceProvider.

Definition at line 92 of file dl_test_surface_provider.h.

94 {
95 return nullptr;
96 }

Referenced by flutter::testing::RenderEnvironment::getImpellerResult().

◆ InitializeSurface()

virtual bool flutter::testing::DlSurfaceProvider::InitializeSurface ( size_t  width,
size_t  height,
PixelFormat  format = kN32PremulPixelFormat 
)
pure virtual

◆ MakeImpellerImage()

virtual sk_sp< DlImage > flutter::testing::DlSurfaceProvider::MakeImpellerImage ( const sk_sp< DisplayList > &  list,
int  width,
int  height 
) const
inlinevirtual

Reimplemented in flutter::testing::DlMetalSurfaceProvider.

Definition at line 97 of file dl_test_surface_provider.h.

99 {
100 return nullptr;
101 }

◆ MakeInfo()

static SkImageInfo flutter::testing::DlSurfaceProvider::MakeInfo ( PixelFormat  format,
int  w,
int  h 
)
inlinestatic

Definition at line 62 of file dl_test_surface_provider.h.

62 {
63 switch (format) {
65 return SkImageInfo::MakeN32Premul(w, h);
66 case k565PixelFormat:
67 return SkImageInfo::Make(SkISize::Make(w, h), kRGB_565_SkColorType,
68 kOpaque_SkAlphaType);
69 }
70 FML_DCHECK(false);
71 }
#define FML_DCHECK(condition)
Definition logging.h:122
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 h
Definition switch_defs.h:54

References FML_DCHECK, format, flutter::h, k565PixelFormat, and kN32PremulPixelFormat.

Referenced by flutter::testing::DlOpenGLSurfaceProvider::MakeOffscreenSurface(), and flutter::testing::DlSoftwareSurfaceProvider::MakeOffscreenSurface().

◆ MakeOffscreenSurface()

virtual std::shared_ptr< DlSurfaceInstance > flutter::testing::DlSurfaceProvider::MakeOffscreenSurface ( size_t  width,
size_t  height,
PixelFormat  format = kN32PremulPixelFormat 
) const
pure virtual

◆ Snapshot()

bool flutter::testing::DlSurfaceProvider::Snapshot ( std::string &  filename) const
virtual

Definition at line 35 of file dl_test_surface_provider.cc.

35 {
36#ifdef BENCHMARKS_NO_SNAPSHOT
37 return false;
38#else
39 auto image = GetPrimarySurface()->sk_surface()->makeImageSnapshot();
40 if (!image) {
41 return false;
42 }
43 auto raster = image->makeRasterImage(nullptr);
44 if (!raster) {
45 return false;
46 }
47 auto data = SkPngEncoder::Encode(nullptr, raster.get(), {});
48 if (!data) {
49 return false;
50 }
51 fml::NonOwnedMapping mapping(static_cast<const uint8_t*>(data->data()),
52 data->size());
53 return WriteAtomically(OpenFixturesDirectory(), filename.c_str(), mapping);
54#endif
55}
virtual std::shared_ptr< DlSurfaceInstance > GetPrimarySurface() const =0
FlutterVulkanImage * image
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
Definition testing.cc:22
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)

References flutter::data, GetPrimarySurface(), image, and flutter::testing::OpenFixturesDirectory().

◆ supports()

◆ supports_impeller()

virtual bool flutter::testing::DlSurfaceProvider::supports_impeller ( ) const
inlinevirtual

Reimplemented in flutter::testing::DlMetalSurfaceProvider.

Definition at line 80 of file dl_test_surface_provider.h.

80{ return false; }

Referenced by flutter::testing::RenderEnvironment::supports_impeller().


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