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

#include <gpu_surface_vulkan_impeller.h>

Inheritance diagram for flutter::GPUSurfaceVulkanImpeller:
flutter::Surface

Public Member Functions

 GPUSurfaceVulkanImpeller (std::shared_ptr< impeller::Context > context)
 
 ~GPUSurfaceVulkanImpeller () override
 
bool IsValid () override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual bool ClearRenderContext ()
 
virtual bool AllowsDrawingWhenGpuDisabled () const
 
virtual SurfaceData GetSurfaceData () const
 

Private Member Functions

std::unique_ptr< SurfaceFrameAcquireFrame (const SkISize &size) override
 
SkMatrix GetRootTransformation () const override
 
GrDirectContextGetContext () override
 
std::unique_ptr< GLContextResultMakeRenderContextCurrent () override
 
bool EnableRasterCache () const override
 
std::shared_ptr< impeller::AiksContextGetAiksContext () const override
 

Detailed Description

Definition at line 18 of file gpu_surface_vulkan_impeller.h.

Constructor & Destructor Documentation

◆ GPUSurfaceVulkanImpeller()

flutter::GPUSurfaceVulkanImpeller::GPUSurfaceVulkanImpeller ( std::shared_ptr< impeller::Context context)
explicit

Definition at line 18 of file gpu_surface_vulkan_impeller.cc.

19 {
20 if (!context || !context->IsValid()) {
21 return;
22 }
23
24 auto renderer = std::make_shared<impeller::Renderer>(context);
25 if (!renderer->IsValid()) {
26 return;
27 }
28
29 auto aiks_context = std::make_shared<impeller::AiksContext>(
31 if (!aiks_context->IsValid()) {
32 return;
33 }
34
35 impeller_context_ = std::move(context);
36 impeller_renderer_ = std::move(renderer);
37 aiks_context_ = std::move(aiks_context);
38 is_valid_ = true;
39}
static std::shared_ptr< TypographerContext > Make()

◆ ~GPUSurfaceVulkanImpeller()

flutter::GPUSurfaceVulkanImpeller::~GPUSurfaceVulkanImpeller ( )
overridedefault

Member Function Documentation

◆ AcquireFrame()

std::unique_ptr< SurfaceFrame > flutter::GPUSurfaceVulkanImpeller::AcquireFrame ( const SkISize size)
overrideprivatevirtual

Implements flutter::Surface.

Definition at line 50 of file gpu_surface_vulkan_impeller.cc.

51 {
52 if (!IsValid()) {
53 FML_LOG(ERROR) << "Vulkan surface was invalid.";
54 return nullptr;
55 }
56
57 if (size.isEmpty()) {
58 FML_LOG(ERROR) << "Vulkan surface was asked for an empty frame.";
59 return nullptr;
60 }
61
62 auto& context_vk = impeller::SurfaceContextVK::Cast(*impeller_context_);
63 std::unique_ptr<impeller::Surface> surface = context_vk.AcquireNextSurface();
64
65 if (!surface) {
66 FML_LOG(ERROR) << "No surface available.";
67 return nullptr;
68 }
69
70 SurfaceFrame::SubmitCallback submit_callback =
71 fml::MakeCopyable([renderer = impeller_renderer_, //
72 aiks_context = aiks_context_, //
73 surface = std::move(surface) //
74 ](SurfaceFrame& surface_frame, DlCanvas* canvas) mutable -> bool {
75 if (!aiks_context) {
76 return false;
77 }
78
79 auto display_list = surface_frame.BuildDisplayList();
80 if (!display_list) {
81 FML_LOG(ERROR) << "Could not build display list for surface frame.";
82 return false;
83 }
84
85 auto cull_rect =
86 surface->GetTargetRenderPassDescriptor().GetRenderTargetSize();
87
88 return renderer->Render(
89 std::move(surface),
90 fml::MakeCopyable([aiks_context, cull_rect, display_list](
91 impeller::RenderTarget& render_target)
92 -> bool {
93#if ENABLE_EXPERIMENTAL_CANVAS
95 aiks_context->GetContentContext(), impeller::Matrix());
96 display_list->Dispatch(
97 collector,
98 SkIRect::MakeWH(cull_rect.width, cull_rect.height));
99 impeller::ExperimentalDlDispatcher impeller_dispatcher(
100 aiks_context->GetContentContext(), render_target,
102 impeller::Rect::MakeSize(cull_rect)));
103 display_list->Dispatch(
104 impeller_dispatcher,
105 SkIRect::MakeWH(cull_rect.width, cull_rect.height));
106 impeller_dispatcher.FinishRecording();
107 aiks_context->GetContentContext().GetTransientsBuffer().Reset();
108 aiks_context->GetContentContext()
109 .GetLazyGlyphAtlas()
110 ->ResetTextFrames();
111 return true;
112#else
113 impeller::Rect dl_cull_rect = impeller::Rect::MakeSize(cull_rect);
114 impeller::DlDispatcher impeller_dispatcher(dl_cull_rect);
115 display_list->Dispatch(
116 impeller_dispatcher,
117 SkIRect::MakeWH(cull_rect.width, cull_rect.height));
118 auto picture = impeller_dispatcher.EndRecordingAsPicture();
119
120 return aiks_context->Render(picture, render_target,
121 /*reset_host_buffer=*/true);
122#endif
123 }));
124 });
125
126 return std::make_unique<SurfaceFrame>(
127 nullptr, // surface
128 SurfaceFrame::FramebufferInfo{}, // framebuffer info
129 submit_callback, // submit callback
130 size, // frame size
131 nullptr, // context result
132 true // display list fallback
133 );
134}
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> SubmitCallback
static SurfaceContextVK & Cast(Context &base)
Performs a first pass over the display list to collect all text frames.
VkSurfaceKHR surface
Definition main.cc:49
#define FML_LOG(severity)
Definition logging.h:82
sk_sp< const SkPicture > picture
Definition SkRecords.h:299
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
internal::CopyableLambda< T > MakeCopyable(T lambda)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
A 4x4 matrix using column-major storage.
Definition matrix.h:37
RoundOut(const TRect< U > &r)
Definition rect.h:643
static constexpr TRect MakeSize(const TSize< U > &size)
Definition rect.h:146
#define ERROR(message)

◆ EnableRasterCache()

bool flutter::GPUSurfaceVulkanImpeller::EnableRasterCache ( ) const
overrideprivatevirtual

Reimplemented from flutter::Surface.

Definition at line 157 of file gpu_surface_vulkan_impeller.cc.

157 {
158 return false;
159}

◆ GetAiksContext()

std::shared_ptr< impeller::AiksContext > flutter::GPUSurfaceVulkanImpeller::GetAiksContext ( ) const
overrideprivatevirtual

Reimplemented from flutter::Surface.

Definition at line 163 of file gpu_surface_vulkan_impeller.cc.

163 {
164 return aiks_context_;
165}

◆ GetContext()

GrDirectContext * flutter::GPUSurfaceVulkanImpeller::GetContext ( )
overrideprivatevirtual

Implements flutter::Surface.

Definition at line 144 of file gpu_surface_vulkan_impeller.cc.

144 {
145 // Impeller != Skia.
146 return nullptr;
147}

◆ GetRootTransformation()

SkMatrix flutter::GPUSurfaceVulkanImpeller::GetRootTransformation ( ) const
overrideprivatevirtual

Implements flutter::Surface.

Definition at line 137 of file gpu_surface_vulkan_impeller.cc.

137 {
138 // This backend does not currently support root surface transformations. Just
139 // return identity.
140 return {};
141}

◆ IsValid()

bool flutter::GPUSurfaceVulkanImpeller::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 45 of file gpu_surface_vulkan_impeller.cc.

45 {
46 return is_valid_;
47}

◆ MakeRenderContextCurrent()

std::unique_ptr< GLContextResult > flutter::GPUSurfaceVulkanImpeller::MakeRenderContextCurrent ( )
overrideprivatevirtual

Reimplemented from flutter::Surface.

Definition at line 151 of file gpu_surface_vulkan_impeller.cc.

151 {
152 // This backend has no such concept.
153 return std::make_unique<GLContextDefaultResult>(true);
154}

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