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

#include <vulkan_surface.h>

Inheritance diagram for flutter_runner::VulkanSurface:
flutter_runner::SurfaceProducerSurface

Public Member Functions

 VulkanSurface (vulkan::VulkanProvider &vulkan_provider, fuchsia::sysmem::AllocatorSyncPtr &sysmem_allocator, fuchsia::ui::composition::AllocatorPtr &flatland_allocator, sk_sp< GrDirectContext > context, const SkISize &size)
 
 ~VulkanSurface () override
 
size_t AdvanceAndGetAge () override
 
bool FlushSessionAcquireAndReleaseEvents () override
 
bool IsValid () const override
 
SkISize GetSize () const override
 
void SignalWritesFinished (const std::function< void(void)> &on_writes_committed) 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
 
const vulkan::VulkanHandle< VkImage > & GetVkImage ()
 
const vulkan::VulkanHandle< VkSemaphore > & GetAcquireVkSemaphore ()
 
vulkan::VulkanCommandBufferGetCommandBuffer (const vulkan::VulkanHandle< VkCommandPool > &pool)
 
const vulkan::VulkanHandle< VkFence > & GetCommandBufferFence ()
 
size_t GetAllocationSize () const
 
size_t GetImageMemoryRequirementsSize () const
 
bool IsOversized () const
 
bool HasStableSizeHistory () const
 
- 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 44 of file vulkan_surface.h.

Constructor & Destructor Documentation

◆ VulkanSurface()

flutter_runner::VulkanSurface::VulkanSurface ( vulkan::VulkanProvider vulkan_provider,
fuchsia::sysmem::AllocatorSyncPtr &  sysmem_allocator,
fuchsia::ui::composition::AllocatorPtr &  flatland_allocator,
sk_sp< GrDirectContext context,
const SkISize size 
)

Definition at line 148 of file vulkan_surface.cc.

154 : vulkan_provider_(vulkan_provider), wait_(this) {
155 FML_CHECK(flatland_allocator.is_bound());
156 FML_CHECK(context != nullptr);
157
158 if (!AllocateDeviceMemory(sysmem_allocator, flatland_allocator,
159 std::move(context), size)) {
160 FML_LOG(ERROR) << "VulkanSurface: Could not allocate device memory.";
161 return;
162 }
163
164 if (!CreateFences()) {
165 FML_LOG(ERROR) << "VulkanSurface: Could not create signal fences.";
166 return;
167 }
168
169 std::fill(size_history_.begin(), size_history_.end(), SkISize::MakeEmpty());
170
171 wait_.set_object(release_event_.get());
172 wait_.set_trigger(ZX_EVENT_SIGNALED);
173 Reset();
174
175 valid_ = true;
176}
#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
static constexpr SkISize MakeEmpty()
Definition: SkSize.h:22
#define ERROR(message)
Definition: elf_loader.cc:260

◆ ~VulkanSurface()

flutter_runner::VulkanSurface::~VulkanSurface ( )
override

Definition at line 178 of file vulkan_surface.cc.

178 {
179 if (release_image_callback_) {
180 release_image_callback_();
181 }
182 wait_.Cancel();
183 wait_.set_object(ZX_HANDLE_INVALID);
184}

Member Function Documentation

◆ AdvanceAndGetAge()

size_t flutter_runner::VulkanSurface::AdvanceAndGetAge ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 474 of file vulkan_surface.cc.

474 {
475 size_history_[size_history_index_] = GetSize();
476 size_history_index_ = (size_history_index_ + 1) % kSizeHistorySize;
477 age_++;
478 return age_;
479}
SkISize GetSize() const override

◆ FlushSessionAcquireAndReleaseEvents()

bool flutter_runner::VulkanSurface::FlushSessionAcquireAndReleaseEvents ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 481 of file vulkan_surface.cc.

481 {
482 age_ = 0;
483 return true;
484}

◆ GetAcquireFence()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 458 of file vulkan_surface.cc.

458 {
459 zx::event fence;
460 acquire_event_.duplicate(ZX_RIGHT_SAME_RIGHTS, &fence);
461 return fence;
462}
FlKeyEvent * event

◆ GetAcquireVkSemaphore()

const vulkan::VulkanHandle< VkSemaphore > & flutter_runner::VulkanSurface::GetAcquireVkSemaphore ( )
inline

Definition at line 98 of file vulkan_surface.h.

98 {
99 return acquire_semaphore_;
100 }

◆ GetAllocationSize()

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

Definition at line 114 of file vulkan_surface.h.

114{ return vk_memory_info_.allocationSize; }
VkDeviceSize allocationSize
Definition: vulkan_core.h:3305

◆ GetBufferCollectionImportToken()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 452 of file vulkan_surface.cc.

452 {
453 fuchsia::ui::composition::BufferCollectionImportToken import_dup;
454 import_token_.value.duplicate(ZX_RIGHT_SAME_RIGHTS, &import_dup.value);
455 return import_dup;
456}

◆ GetCommandBuffer()

vulkan::VulkanCommandBuffer * flutter_runner::VulkanSurface::GetCommandBuffer ( const vulkan::VulkanHandle< VkCommandPool > &  pool)
inline

Definition at line 102 of file vulkan_surface.h.

103 {
104 if (!command_buffer_)
105 command_buffer_ = std::make_unique<vulkan::VulkanCommandBuffer>(
106 vulkan_provider_.vk(), vulkan_provider_.vk_device(), pool);
107 return command_buffer_.get();
108 }
AutoreleasePool pool
virtual const vulkan::VulkanProcTable & vk()=0
virtual const vulkan::VulkanHandle< VkDevice > & vk_device()=0

◆ GetCommandBufferFence()

const vulkan::VulkanHandle< VkFence > & flutter_runner::VulkanSurface::GetCommandBufferFence ( )
inline

Definition at line 110 of file vulkan_surface.h.

110 {
111 return command_buffer_fence_;
112 }

◆ GetImageId()

uint32_t flutter_runner::VulkanSurface::GetImageId ( )
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 443 of file vulkan_surface.cc.

443 {
444 return image_id_;
445}

◆ GetImageMemoryRequirementsSize()

size_t flutter_runner::VulkanSurface::GetImageMemoryRequirementsSize ( ) const
inline

Definition at line 116 of file vulkan_surface.h.

116 {
117 return vulkan_image_.vk_memory_requirements.size;
118 }
VkMemoryRequirements vk_memory_requirements

◆ GetReleaseFence()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 464 of file vulkan_surface.cc.

464 {
465 zx::event fence;
466 release_event_.duplicate(ZX_RIGHT_SAME_RIGHTS, &fence);
467 return fence;
468}

◆ GetSize()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 190 of file vulkan_surface.cc.

190 {
191 if (!valid_) {
192 return SkISize::Make(0, 0);
193 }
194
195 return SkISize::Make(sk_surface_->width(), sk_surface_->height());
196}
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::VulkanSurface::GetSkiaSurface ( ) const
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 447 of file vulkan_surface.cc.

447 {
448 return valid_ ? sk_surface_ : nullptr;
449}

◆ GetVkImage()

const vulkan::VulkanHandle< VkImage > & flutter_runner::VulkanSurface::GetVkImage ( )
inline

Definition at line 94 of file vulkan_surface.h.

94 {
95 return vulkan_image_.vk_image;
96 }
vulkan::VulkanHandle< VkImage > vk_image

◆ HasStableSizeHistory()

bool flutter_runner::VulkanSurface::HasStableSizeHistory ( ) const
inline

Definition at line 124 of file vulkan_surface.h.

124 {
125 return std::equal(size_history_.begin() + 1, size_history_.end(),
126 size_history_.begin());
127 }
static bool equal(const SkBitmap &a, const SkBitmap &b)
Definition: ImageTest.cpp:1395

◆ IsOversized()

bool flutter_runner::VulkanSurface::IsOversized ( ) const
inline

Definition at line 120 of file vulkan_surface.h.

120 {
122 }
size_t GetImageMemoryRequirementsSize() const

◆ IsValid()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 186 of file vulkan_surface.cc.

186 {
187 return valid_;
188}

◆ SetImageId()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 438 of file vulkan_surface.cc.

438 {
439 FML_CHECK(image_id_ == 0);
440 image_id_ = image_id;
441}

◆ SetReleaseImageCallback()

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

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 469 of file vulkan_surface.cc.

470 {
471 release_image_callback_ = release_image_callback;
472}

◆ SignalWritesFinished()

void flutter_runner::VulkanSurface::SignalWritesFinished ( const std::function< void(void)> &  on_writes_committed)
overridevirtual

Implements flutter_runner::SurfaceProducerSurface.

Definition at line 486 of file vulkan_surface.cc.

487 {
488 FML_CHECK(on_writes_committed);
489
490 if (!valid_) {
491 on_writes_committed();
492 return;
493 }
494
495 FML_CHECK(pending_on_writes_committed_ == nullptr)
496 << "Attempted to signal a write on the surface when the "
497 "previous write has not yet been acknowledged by the "
498 "compositor.";
499
500 pending_on_writes_committed_ = on_writes_committed;
501}

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