Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | List of all members
flutter::EmbedderSurfaceSoftware Class Referencefinal

#include <embedder_surface_software.h>

Inheritance diagram for flutter::EmbedderSurfaceSoftware:
flutter::EmbedderSurface flutter::GPUSurfaceSoftwareDelegate

Classes

struct  SoftwareDispatchTable
 

Public Member Functions

 EmbedderSurfaceSoftware (SoftwareDispatchTable software_dispatch_table, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
 
 ~EmbedderSurfaceSoftware () override
 
- Public Member Functions inherited from flutter::EmbedderSurface
 EmbedderSurface ()
 
virtual ~EmbedderSurface ()
 
virtual std::shared_ptr< impeller::ContextCreateImpellerContext () const
 
- Public Member Functions inherited from flutter::GPUSurfaceSoftwareDelegate
 ~GPUSurfaceSoftwareDelegate ()
 

Private Member Functions

bool IsValid () const override
 
std::unique_ptr< SurfaceCreateGPUSurface () override
 
sk_sp< GrDirectContextCreateResourceContext () const override
 
sk_sp< SkSurfaceAcquireBackingStore (const SkISize &size) override
 Called when the GPU surface needs a new buffer to render a new frame into.
 
bool PresentBackingStore (sk_sp< SkSurface > backing_store) override
 Called by the platform when a frame has been rendered into the backing store and the platform must display it on-screen.
 

Detailed Description

Definition at line 17 of file embedder_surface_software.h.

Constructor & Destructor Documentation

◆ EmbedderSurfaceSoftware()

flutter::EmbedderSurfaceSoftware::EmbedderSurfaceSoftware ( SoftwareDispatchTable  software_dispatch_table,
std::shared_ptr< EmbedderExternalViewEmbedder external_view_embedder 
)

Definition at line 18 of file embedder_surface_software.cc.

21 : software_dispatch_table_(std::move(software_dispatch_table)),
22 external_view_embedder_(std::move(external_view_embedder)) {
23 if (!software_dispatch_table_.software_present_backing_store) {
24 return;
25 }
26 valid_ = true;
27}
std::function< bool(const void *allocation, size_t row_bytes, size_t height)> software_present_backing_store

◆ ~EmbedderSurfaceSoftware()

flutter::EmbedderSurfaceSoftware::~EmbedderSurfaceSoftware ( )
overridedefault

Member Function Documentation

◆ AcquireBackingStore()

sk_sp< SkSurface > flutter::EmbedderSurfaceSoftware::AcquireBackingStore ( const SkISize size)
overrideprivatevirtual

Called when the GPU surface needs a new buffer to render a new frame into.

Parameters
[in]sizeThe size of the frame.
Returns
A raster surface returned by the platform.

Implements flutter::GPUSurfaceSoftwareDelegate.

Definition at line 57 of file embedder_surface_software.cc.

58 {
59 TRACE_EVENT0("flutter", "EmbedderSurfaceSoftware::AcquireBackingStore");
60 if (!IsValid()) {
62 << "Could not acquire backing store for the software surface.";
63 return nullptr;
64 }
65
66 if (sk_surface_ != nullptr &&
67 SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) {
68 // The old and new surface sizes are the same. Nothing to do here.
69 return sk_surface_;
70 }
71
74 sk_surface_ = SkSurfaces::Raster(info, nullptr);
75
76 if (sk_surface_ == nullptr) {
77 FML_LOG(ERROR) << "Could not create backing store for software rendering.";
78 return nullptr;
79 }
80
81 return sk_surface_;
82}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
static sk_sp< SkColorSpace > MakeSRGB()
int width() const
Definition SkSurface.h:178
int height() const
Definition SkSurface.h:184
#define FML_LOG(severity)
Definition logging.h:82
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
#define ERROR(message)
#define TRACE_EVENT0(category_group, name)

◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::EmbedderSurfaceSoftware::CreateGPUSurface ( )
overrideprivatevirtual

Implements flutter::EmbedderSurface.

Definition at line 37 of file embedder_surface_software.cc.

37 {
38 if (!IsValid()) {
39 return nullptr;
40 }
41 const bool render_to_surface = !external_view_embedder_;
42 auto surface = std::make_unique<GPUSurfaceSoftware>(this, render_to_surface);
43
44 if (!surface->IsValid()) {
45 return nullptr;
46 }
47
48 return surface;
49}
VkSurfaceKHR surface
Definition main.cc:49

◆ CreateResourceContext()

sk_sp< GrDirectContext > flutter::EmbedderSurfaceSoftware::CreateResourceContext ( ) const
overrideprivatevirtual

Reimplemented from flutter::EmbedderSurface.

Definition at line 52 of file embedder_surface_software.cc.

52 {
53 return nullptr;
54}

◆ IsValid()

bool flutter::EmbedderSurfaceSoftware::IsValid ( ) const
overrideprivatevirtual

Implements flutter::EmbedderSurface.

Definition at line 32 of file embedder_surface_software.cc.

32 {
33 return valid_;
34}

◆ PresentBackingStore()

bool flutter::EmbedderSurfaceSoftware::PresentBackingStore ( sk_sp< SkSurface backing_store)
overrideprivatevirtual

Called by the platform when a frame has been rendered into the backing store and the platform must display it on-screen.

Parameters
[in]backing_storeThe software backing store to present.
Returns
Returns if the platform could present the backing store onto the screen.

Implements flutter::GPUSurfaceSoftwareDelegate.

Definition at line 85 of file embedder_surface_software.cc.

86 {
87 if (!IsValid()) {
88 FML_LOG(ERROR) << "Tried to present an invalid software surface.";
89 return false;
90 }
91
92 SkPixmap pixmap;
93 if (!backing_store->peekPixels(&pixmap)) {
94 FML_LOG(ERROR) << "Could not peek the pixels of the backing store.";
95 return false;
96 }
97
98 // Some basic sanity checking.
99 uint64_t expected_pixmap_data_size = pixmap.width() * pixmap.height() * 4;
100
101 const size_t pixmap_size = pixmap.computeByteSize();
102
103 if (expected_pixmap_data_size != pixmap_size) {
104 FML_LOG(ERROR) << "Software backing store had unexpected size.";
105 return false;
106 }
107
108 return software_dispatch_table_.software_present_backing_store(
109 pixmap.addr(), //
110 pixmap.rowBytes(), //
111 pixmap.height() //
112 );
113}
size_t rowBytes() const
Definition SkPixmap.h:145
int width() const
Definition SkPixmap.h:160
size_t computeByteSize() const
Definition SkPixmap.h:231
const void * addr() const
Definition SkPixmap.h:153
int height() const
Definition SkPixmap.h:166
bool peekPixels(SkPixmap *pixmap)

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