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)
 Create a GPUSurfaceVulkan which implicitly creates its own GrDirectContext for Skia. More...
 
 GPUSurfaceVulkan (const sk_sp< GrDirectContext > &context, GPUSurfaceVulkanDelegate *delegate, std::unique_ptr< vulkan::VulkanNativeSurface > native_surface, bool render_to_surface)
 Create a GPUSurfaceVulkan while letting it reuse an existing GrDirectContext. More...
 
 ~GPUSurfaceVulkan () override
 
bool IsValid () override
 
std::unique_ptr< SurfaceFrameAcquireFrame (const SkISize &size) override
 
SkMatrix GetRootTransformation () const override
 
GrDirectContext * GetContext () override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual std::unique_ptr< GLContextResultMakeRenderContextCurrent ()
 
virtual bool ClearRenderContext ()
 
virtual bool AllowsDrawingWhenGpuDisabled () const
 

Detailed Description

Definition at line 20 of file gpu_surface_vulkan.h.

Constructor & Destructor Documentation

◆ GPUSurfaceVulkan() [1/2]

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

Create a GPUSurfaceVulkan which implicitly creates its own GrDirectContext for Skia.

Definition at line 11 of file gpu_surface_vulkan.cc.

15  : GPUSurfaceVulkan(/*context=*/nullptr,
16  delegate,
17  std::move(native_surface),
18  render_to_surface) {}
GPUSurfaceVulkan(GPUSurfaceVulkanDelegate *delegate, std::unique_ptr< vulkan::VulkanNativeSurface > native_surface, bool render_to_surface)
Create a GPUSurfaceVulkan which implicitly creates its own GrDirectContext for Skia.

◆ GPUSurfaceVulkan() [2/2]

flutter::GPUSurfaceVulkan::GPUSurfaceVulkan ( const sk_sp< GrDirectContext > &  context,
GPUSurfaceVulkanDelegate delegate,
std::unique_ptr< vulkan::VulkanNativeSurface native_surface,
bool  render_to_surface 
)

Create a GPUSurfaceVulkan while letting it reuse an existing GrDirectContext.

Definition at line 20 of file gpu_surface_vulkan.cc.

References ~GPUSurfaceVulkan().

25  : window_(context,
26  delegate->vk(),
27  std::move(native_surface),
28  render_to_surface),
29  render_to_surface_(render_to_surface),
30  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 38 of file gpu_surface_vulkan.cc.

References vulkan::VulkanWindow::AcquireSurface(), and callback.

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

◆ GetContext()

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

Implements flutter::Surface.

Definition at line 78 of file gpu_surface_vulkan.cc.

References vulkan::VulkanWindow::GetSkiaGrContext().

78  {
79  return window_.GetSkiaGrContext();
80 }
GrDirectContext * GetSkiaGrContext()

◆ GetRootTransformation()

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

Implements flutter::Surface.

Definition at line 70 of file gpu_surface_vulkan.cc.

70  {
71  // This backend does not support delegating to the underlying platform to
72  // query for root surface transformations. Just return identity.
73  SkMatrix matrix;
74  matrix.reset();
75  return matrix;
76 }

◆ IsValid()

bool flutter::GPUSurfaceVulkan::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 34 of file gpu_surface_vulkan.cc.

References vulkan::VulkanWindow::IsValid().

34  {
35  return window_.IsValid();
36 }
bool IsValid() const

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