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

#include <vulkan_surface_producer.h>

Inheritance diagram for flutter_runner::VulkanSurfaceProducer:
flutter_runner::SurfaceProducer vulkan::VulkanProvider

Public Member Functions

 VulkanSurfaceProducer ()
 
 ~VulkanSurfaceProducer () override
 
bool IsValid () const
 
GrDirectContextgr_context () const override
 
std::unique_ptr< SurfaceProducerSurfaceProduceOffscreenSurface (const SkISize &size) override
 
std::unique_ptr< SurfaceProducerSurfaceProduceSurface (const SkISize &size) override
 
void SubmitSurfaces (std::vector< std::unique_ptr< SurfaceProducerSurface > > surfaces) override
 
- Public Member Functions inherited from flutter_runner::SurfaceProducer
virtual ~SurfaceProducer ()=default
 
virtual GrDirectContextgr_context () const =0
 
virtual std::unique_ptr< SurfaceProducerSurfaceProduceOffscreenSurface (const SkISize &size)=0
 
virtual std::unique_ptr< SurfaceProducerSurfaceProduceSurface (const SkISize &size)=0
 
virtual void SubmitSurfaces (std::vector< std::unique_ptr< SurfaceProducerSurface > > surfaces)=0
 
- Public Member Functions inherited from vulkan::VulkanProvider
virtual const vulkan::VulkanProcTablevk ()=0
 
virtual const vulkan::VulkanHandle< VkDevice > & vk_device ()=0
 
vulkan::VulkanHandle< VkFence > CreateFence ()
 

Detailed Description

Definition at line 26 of file vulkan_surface_producer.h.

Constructor & Destructor Documentation

◆ VulkanSurfaceProducer()

flutter_runner::VulkanSurfaceProducer::VulkanSurfaceProducer ( )
explicit

Definition at line 45 of file vulkan_surface_producer.cc.

45 {
46 valid_ = Initialize();
47
48 if (!valid_) {
49 FML_LOG(FATAL) << "VulkanSurfaceProducer: Initialization failed";
50 }
51}
#define FATAL(error)
#define FML_LOG(severity)
Definition: logging.h:82

◆ ~VulkanSurfaceProducer()

flutter_runner::VulkanSurfaceProducer::~VulkanSurfaceProducer ( )
override

Definition at line 53 of file vulkan_surface_producer.cc.

53 {
54 // Make sure queue is idle before we start destroying surfaces
55 if (valid_) {
56 VkResult wait_result = VK_CALL_LOG_ERROR(
57 vk_->QueueWaitIdle(logical_device_->GetQueueHandle()));
58 FML_DCHECK(wait_result == VK_SUCCESS);
59 }
60};
#define FML_DCHECK(condition)
Definition: logging.h:103
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_CALL_LOG_ERROR(expression)

Member Function Documentation

◆ gr_context()

GrDirectContext * flutter_runner::VulkanSurfaceProducer::gr_context ( ) const
inlineoverridevirtual

Implements flutter_runner::SurfaceProducer.

Definition at line 35 of file vulkan_surface_producer.h.

35{ return context_.get(); }
T * get() const
Definition: SkRefCnt.h:303

◆ IsValid()

bool flutter_runner::VulkanSurfaceProducer::IsValid ( ) const
inline

Definition at line 32 of file vulkan_surface_producer.h.

32{ return valid_; }

◆ ProduceOffscreenSurface()

std::unique_ptr< SurfaceProducerSurface > flutter_runner::VulkanSurfaceProducer::ProduceOffscreenSurface ( const SkISize size)
overridevirtual

Implements flutter_runner::SurfaceProducer.

Definition at line 289 of file vulkan_surface_producer.cc.

289 {
290 return surface_pool_->CreateSurface(size);
291}
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

◆ ProduceSurface()

std::unique_ptr< SurfaceProducerSurface > flutter_runner::VulkanSurfaceProducer::ProduceSurface ( const SkISize size)
overridevirtual

Implements flutter_runner::SurfaceProducer.

Definition at line 275 of file vulkan_surface_producer.cc.

276 {
277 FML_CHECK(valid_);
278 last_produce_time_ = async::Now(async_get_default_dispatcher());
279 return surface_pool_->AcquireSurface(size);
280}
#define FML_CHECK(condition)
Definition: logging.h:85

◆ SubmitSurfaces()

void flutter_runner::VulkanSurfaceProducer::SubmitSurfaces ( std::vector< std::unique_ptr< SurfaceProducerSurface > >  surfaces)
overridevirtual

Implements flutter_runner::SurfaceProducer.

Definition at line 171 of file vulkan_surface_producer.cc.

172 {
173 TRACE_EVENT0("flutter", "VulkanSurfaceProducer::SubmitSurfaces");
174
175 // Do a single flush for all canvases derived from the context.
176 {
177 TRACE_EVENT0("flutter", "GrDirectContext::flushAndSignalSemaphores");
178 context_->flushAndSubmit();
179 }
180
181 if (!TransitionSurfacesToExternal(surfaces))
182 FML_LOG(ERROR) << "TransitionSurfacesToExternal failed";
183
184 // Submit surface
185 for (auto& surface : surfaces) {
186 SubmitSurface(std::move(surface));
187 }
188
189 // Buffer management.
190 surface_pool_->AgeAndCollectOldBuffers();
191
192 // If no further surface production has taken place for 10 frames (TODO:
193 // Don't hardcode refresh rate here), then shrink our surface pool to fit.
194 constexpr auto kShouldShrinkThreshold = zx::msec(10 * 16.67);
195 async::PostDelayedTask(
196 async_get_default_dispatcher(),
197 [self = weak_factory_.GetWeakPtr(), kShouldShrinkThreshold] {
198 if (!self) {
199 return;
200 }
201 auto time_since_last_produce =
202 async::Now(async_get_default_dispatcher()) -
203 self->last_produce_time_;
204 if (time_since_last_produce >= kShouldShrinkThreshold) {
205 self->surface_pool_->ShrinkToFit();
206 }
207 },
208 kShouldShrinkThreshold);
209}
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
VkSurfaceKHR surface
Definition: main.cc:49
if(end==-1)
#define ERROR(message)
Definition: elf_loader.cc:260
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

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