Flutter Engine
flutter::GPUSurfaceVulkan Class Reference

#include <gpu_surface_vulkan.h>

Inheritance diagram for flutter::GPUSurfaceVulkan:
flutter::Surface

Public Member Functions

 GPUSurfaceVulkan (GPUSurfaceVulkanDelegate *delegate, std::unique_ptr< vulkan::VulkanNativeSurface > native_surface, bool render_to_surface)
 
 ~GPUSurfaceVulkan () override
 
bool IsValid () override
 
std::unique_ptr< SurfaceFrameAcquireFrame (const SkISize &size) override
 
SkMatrix GetRootTransformation () const override
 
GrDirectContext * GetContext () override
 
flutter::ExternalViewEmbedderGetExternalViewEmbedder () override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual std::unique_ptr< GLContextResultMakeRenderContextCurrent ()
 
virtual bool ClearRenderContext ()
 

Detailed Description

Definition at line 19 of file gpu_surface_vulkan.h.

Constructor & Destructor Documentation

◆ GPUSurfaceVulkan()

flutter::GPUSurfaceVulkan::GPUSurfaceVulkan ( GPUSurfaceVulkanDelegate delegate,
std::unique_ptr< vulkan::VulkanNativeSurface native_surface,
bool  render_to_surface 
)

Definition at line 11 of file gpu_surface_vulkan.cc.

References ~GPUSurfaceVulkan().

15  : window_(delegate->vk(), std::move(native_surface), render_to_surface),
16  delegate_(delegate),
17  render_to_surface_(render_to_surface),
18  weak_factory_(this) {}

◆ ~GPUSurfaceVulkan()

flutter::GPUSurfaceVulkan::~GPUSurfaceVulkan ( )
overridedefault

Referenced by GPUSurfaceVulkan().

Member Function Documentation

◆ AcquireFrame()

std::unique_ptr< SurfaceFrame > flutter::GPUSurfaceVulkan::AcquireFrame ( const SkISize &  size)
overridevirtual

Implements flutter::Surface.

Definition at line 26 of file gpu_surface_vulkan.cc.

References vulkan::VulkanWindow::AcquireSurface().

27  {
28  // TODO(38466): Refactor GPU surface APIs take into account the fact that an
29  // external view embedder may want to render to the root surface.
30  if (!render_to_surface_) {
31  return std::make_unique<SurfaceFrame>(
32  nullptr, true, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) {
33  return true;
34  });
35  }
36 
37  auto surface = window_.AcquireSurface();
38 
39  if (surface == nullptr) {
40  return nullptr;
41  }
42 
44  [weak_this = weak_factory_.GetWeakPtr()](const SurfaceFrame&,
45  SkCanvas* canvas) -> bool {
46  // Frames are only ever acquired on the raster thread. This is also the
47  // thread on which the weak pointer factory is collected (as this instance
48  // is owned by the rasterizer). So this use of weak pointers is safe.
49  if (canvas == nullptr || !weak_this) {
50  return false;
51  }
52  return weak_this->window_.SwapBuffers();
53  };
54  return std::make_unique<SurfaceFrame>(std::move(surface), true,
55  std::move(callback));
56 }
std::function< bool(const SurfaceFrame &surface_frame, SkCanvas *canvas)> SubmitCallback
Definition: surface_frame.h:22
sk_sp< SkSurface > AcquireSurface()

◆ GetContext()

GrDirectContext * flutter::GPUSurfaceVulkan::GetContext ( )
overridevirtual

Implements flutter::Surface.

Definition at line 66 of file gpu_surface_vulkan.cc.

References vulkan::VulkanWindow::GetSkiaGrContext().

66  {
67  return window_.GetSkiaGrContext();
68 }
GrDirectContext * GetSkiaGrContext()

◆ GetExternalViewEmbedder()

flutter::ExternalViewEmbedder * flutter::GPUSurfaceVulkan::GetExternalViewEmbedder ( )
overridevirtual

Reimplemented from flutter::Surface.

Definition at line 70 of file gpu_surface_vulkan.cc.

References flutter::GPUSurfaceVulkanDelegate::GetExternalViewEmbedder().

70  {
71  return delegate_->GetExternalViewEmbedder();
72 }
ExternalViewEmbedder * GetExternalViewEmbedder() override
Gets the view embedder that controls how the Flutter layer hierarchy split into multiple chunks shoul...

◆ GetRootTransformation()

SkMatrix flutter::GPUSurfaceVulkan::GetRootTransformation ( ) const
overridevirtual

Implements flutter::Surface.

Definition at line 58 of file gpu_surface_vulkan.cc.

58  {
59  // This backend does not support delegating to the underlying platform to
60  // query for root surface transformations. Just return identity.
61  SkMatrix matrix;
62  matrix.reset();
63  return matrix;
64 }

◆ IsValid()

bool flutter::GPUSurfaceVulkan::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 22 of file gpu_surface_vulkan.cc.

References vulkan::VulkanWindow::IsValid().

22  {
23  return window_.IsValid();
24 }
bool IsValid() const

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