Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter_runner::SoftwareSurface Class Referencefinal

#include <software_surface.h>

Inheritance diagram for flutter_runner::SoftwareSurface:
flutter_runner::SurfaceProducerSurface

Public Member Functions

 SoftwareSurface (fuchsia::sysmem::AllocatorSyncPtr &sysmem_allocator, fuchsia::ui::composition::AllocatorPtr &flatland_allocator, const SkISize &size)
 
 ~SoftwareSurface () override
 
size_t GetAllocationSize () const
 
size_t AdvanceAndGetAge () override
 
bool FlushSessionAcquireAndReleaseEvents () override
 
bool IsValid () const override
 
SkISize GetSize () const override
 
void SignalWritesFinished (const std::function< void(void)> &on_surface_read_finished) override
 
void SetImageId (uint32_t image_id) override
 
uint32_t GetImageId () override
 
sk_sp< SkSurfaceGetSkiaSurface () const override
 
fuchsia::ui::composition::BufferCollectionImportToken GetBufferCollectionImportToken () override
 
zx::event GetAcquireFence () override
 
zx::event GetReleaseFence () override
 
void SetReleaseImageCallback (ReleaseImageCallback release_image_callback) override
 
- Public Member Functions inherited from flutter_runner::SurfaceProducerSurface
virtual ~SurfaceProducerSurface ()=default
 
virtual bool IsValid () const =0
 
virtual SkISize GetSize () const =0
 
virtual void SetImageId (uint32_t image_id)=0
 
virtual uint32_t GetImageId ()=0
 
virtual sk_sp< SkSurfaceGetSkiaSurface () const =0
 
virtual fuchsia::ui::composition::BufferCollectionImportToken GetBufferCollectionImportToken ()=0
 
virtual zx::event GetAcquireFence ()=0
 
virtual zx::event GetReleaseFence ()=0
 
virtual void SetReleaseImageCallback (ReleaseImageCallback release_image_callback)=0
 
virtual size_t AdvanceAndGetAge ()=0
 
virtual bool FlushSessionAcquireAndReleaseEvents ()=0
 
virtual void SignalWritesFinished (const std::function< void(void)> &on_writes_committed)=0
 

Detailed Description

Definition at line 26 of file software_surface.h.

Constructor & Destructor Documentation

◆ SoftwareSurface()

flutter_runner::SoftwareSurface::SoftwareSurface ( fuchsia::sysmem::AllocatorSyncPtr &  sysmem_allocator,
fuchsia::ui::composition::AllocatorPtr &  flatland_allocator,
const SkISize size 
)

Definition at line 48 of file software_surface.cc.

52 : wait_for_surface_read_finished_(this) {
53 FML_CHECK(flatland_allocator.is_bound());
54
55 if (!SetupSkiaSurface(sysmem_allocator, flatland_allocator, size)) {
56 FML_LOG(ERROR) << "Could not create render surface.";
57 return;
58 }
59
60 if (!CreateFences()) {
61 FML_LOG(ERROR) << "Could not create signal fences.";
62 return;
63 }
64
65 wait_for_surface_read_finished_.set_object(release_event_.get());
66 wait_for_surface_read_finished_.set_trigger(ZX_EVENT_SIGNALED);
67 Reset();
68
69 valid_ = true;
70}
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_CHECK(condition)
Definition: logging.h:85
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
#define ERROR(message)
Definition: elf_loader.cc:260

◆ ~SoftwareSurface()

flutter_runner::SoftwareSurface::~SoftwareSurface ( )
override

Definition at line 72 of file software_surface.cc.

72 {
73 release_image_callback_();
74 wait_for_surface_read_finished_.Cancel();
75 wait_for_surface_read_finished_.set_object(ZX_HANDLE_INVALID);
76}

Member Function Documentation

◆ AdvanceAndGetAge()

size_t flutter_runner::SoftwareSurface::AdvanceAndGetAge ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 316 of file software_surface.cc.

316 {
317 return ++age_;
318}

◆ FlushSessionAcquireAndReleaseEvents()

bool flutter_runner::SoftwareSurface::FlushSessionAcquireAndReleaseEvents ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 320 of file software_surface.cc.

320 {
321 age_ = 0;
322 return true;
323}

◆ GetAcquireFence()

zx::event flutter_runner::SoftwareSurface::GetAcquireFence ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 300 of file software_surface.cc.

300 {
301 zx::event fence;
302 acquire_event_.duplicate(ZX_RIGHT_SAME_RIGHTS, &fence);
303 return fence;
304}
FlKeyEvent * event

◆ GetAllocationSize()

size_t flutter_runner::SoftwareSurface::GetAllocationSize ( ) const
inline

Definition at line 34 of file software_surface.h.

34{ return surface_size_bytes_; }

◆ GetBufferCollectionImportToken()

fuchsia::ui::composition::BufferCollectionImportToken flutter_runner::SoftwareSurface::GetBufferCollectionImportToken ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 294 of file software_surface.cc.

294 {
295 fuchsia::ui::composition::BufferCollectionImportToken import_dup;
296 import_token_.value.duplicate(ZX_RIGHT_SAME_RIGHTS, &import_dup.value);
297 return import_dup;
298}

◆ GetImageId()

uint32_t flutter_runner::SoftwareSurface::GetImageId ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 285 of file software_surface.cc.

285 {
286 return image_id_;
287}

◆ GetReleaseFence()

zx::event flutter_runner::SoftwareSurface::GetReleaseFence ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 306 of file software_surface.cc.

306 {
307 zx::event fence;
308 release_event_.duplicate(ZX_RIGHT_SAME_RIGHTS, &fence);
309 return fence;
310}

◆ GetSize()

SkISize flutter_runner::SoftwareSurface::GetSize ( ) const
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 82 of file software_surface.cc.

82 {
83 if (!valid_) {
84 return SkISize::Make(0, 0);
85 }
86
87 return SkISize::Make(sk_surface_->width(), sk_surface_->height());
88}
int width() const
Definition: SkSurface.h:178
int height() const
Definition: SkSurface.h:184
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ GetSkiaSurface()

sk_sp< SkSurface > flutter_runner::SoftwareSurface::GetSkiaSurface ( ) const
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 289 of file software_surface.cc.

289 {
290 return valid_ ? sk_surface_ : nullptr;
291}

◆ IsValid()

bool flutter_runner::SoftwareSurface::IsValid ( ) const
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 78 of file software_surface.cc.

78 {
79 return valid_;
80}

◆ SetImageId()

void flutter_runner::SoftwareSurface::SetImageId ( uint32_t  image_id)
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 280 of file software_surface.cc.

280 {
281 FML_CHECK(image_id_ == 0);
282 image_id_ = image_id;
283}

◆ SetReleaseImageCallback()

void flutter_runner::SoftwareSurface::SetReleaseImageCallback ( ReleaseImageCallback  release_image_callback)
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 311 of file software_surface.cc.

312 {
313 release_image_callback_ = release_image_callback;
314}

◆ SignalWritesFinished()

void flutter_runner::SoftwareSurface::SignalWritesFinished ( const std::function< void(void)> &  on_surface_read_finished)
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 325 of file software_surface.cc.

326 {
327 FML_CHECK(on_surface_read_finished);
328
329 if (!valid_) {
330 on_surface_read_finished();
331 return;
332 }
333
334 FML_CHECK(surface_read_finished_callback_ == nullptr)
335 << "Attempted to signal a write on the surface when the "
336 "previous write has not yet been acknowledged by the "
337 "compositor.";
338 surface_read_finished_callback_ = on_surface_read_finished;
339
340 // Sysmem *may* require the cache to be cleared after writes to the surface
341 // are complete.
342 if (needs_cache_clean_) {
343 surface_vmo_.op_range(ZX_VMO_OP_CACHE_CLEAN, 0, surface_size_bytes_,
344 /*buffer*/ nullptr,
345 /*buffer_size*/ 0);
346 }
347
348 // Inform scenic that flutter is finished writing to the surface.
349 zx_status_t signal_status = acquire_event_.signal(0u, ZX_EVENT_SIGNALED);
350 if (signal_status != ZX_OK) {
351 FML_LOG(ERROR) << "Failed to signal acquire event; "
352 << zx_status_get_string(signal_status);
353 }
354}

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