Flutter Engine
 
Loading...
Searching...
No Matches
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
 
GrDirectContext * gr_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
 
- Public Member Functions inherited from vulkan::VulkanProvider
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 FML_LOG(severity)
Definition logging.h:101

References FML_LOG.

◆ ~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:122
#define VK_CALL_LOG_ERROR(expression)

References FML_DCHECK, and VK_CALL_LOG_ERROR.

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(); }

◆ 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}

◆ 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:104

References FML_CHECK.

◆ 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}
#define TRACE_EVENT0(category_group, name)

References FML_LOG, self, surface, and TRACE_EVENT0.


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