Flutter Impeller
surface_context_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
7 
8 #include <memory>
9 
13 
14 namespace impeller {
15 
16 class ContextVK;
17 class Surface;
18 class SwapchainVK;
19 
20 class SurfaceContextVK : public Context,
21  public BackendCast<SurfaceContextVK, Context> {
22  public:
23  explicit SurfaceContextVK(const std::shared_ptr<ContextVK>& parent);
24 
25  // |Context|
26  ~SurfaceContextVK() override;
27 
28  // |Context|
29  BackendType GetBackendType() const override;
30 
31  // |Context|
32  std::string DescribeGpuModel() const override;
33 
34  // |Context|
35  bool IsValid() const override;
36 
37  // |Context|
38  std::shared_ptr<Allocator> GetResourceAllocator() const override;
39 
40  // |Context|
41  std::shared_ptr<ShaderLibrary> GetShaderLibrary() const override;
42 
43  // |Context|
44  std::shared_ptr<SamplerLibrary> GetSamplerLibrary() const override;
45 
46  // |Context|
47  std::shared_ptr<PipelineLibrary> GetPipelineLibrary() const override;
48 
49  // |Context|
50  std::shared_ptr<CommandBuffer> CreateCommandBuffer() const override;
51 
52  // |Context|
53  const std::shared_ptr<const Capabilities>& GetCapabilities() const override;
54 
55  // |Context|
56  void Shutdown() override;
57 
58  // |Context|
59  void SetSyncPresentation(bool value) override;
60 
61  [[nodiscard]] bool SetWindowSurface(vk::UniqueSurfaceKHR surface);
62 
63  std::unique_ptr<Surface> AcquireNextSurface();
64 
65 #ifdef FML_OS_ANDROID
66  vk::UniqueSurfaceKHR CreateAndroidSurface(ANativeWindow* window) const;
67 #endif // FML_OS_ANDROID
68 
69  private:
70  std::shared_ptr<ContextVK> parent_;
71  std::shared_ptr<SwapchainVK> swapchain_;
72 };
73 
74 } // namespace impeller
75 
76 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SURFACE_CONTEXT_VK_H_
impeller::Context::BackendType
BackendType
Definition: context.h:49
impeller::SurfaceContextVK::AcquireNextSurface
std::unique_ptr< Surface > AcquireNextSurface()
Definition: surface_context_vk.cc:74
impeller::SurfaceContextVK::GetSamplerLibrary
std::shared_ptr< SamplerLibrary > GetSamplerLibrary() const override
Returns the library of combined image samplers used in shaders.
Definition: surface_context_vk.cc:39
impeller::SurfaceContextVK::~SurfaceContextVK
~SurfaceContextVK() override
impeller::SurfaceContextVK::GetBackendType
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
Definition: surface_context_vk.cc:19
impeller::SurfaceContextVK::CreateCommandBuffer
std::shared_ptr< CommandBuffer > CreateCommandBuffer() const override
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
Definition: surface_context_vk.cc:47
impeller::SurfaceContextVK::GetShaderLibrary
std::shared_ptr< ShaderLibrary > GetShaderLibrary() const override
Returns the library of shaders used to specify the programmable stages of a pipeline.
Definition: surface_context_vk.cc:35
vk.h
impeller::SurfaceContextVK
Definition: surface_context_vk.h:20
impeller::SurfaceContextVK::SetWindowSurface
bool SetWindowSurface(vk::UniqueSurfaceKHR surface)
Definition: surface_context_vk.cc:60
impeller::SurfaceContextVK::GetCapabilities
const std::shared_ptr< const Capabilities > & GetCapabilities() const override
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
Definition: surface_context_vk.cc:51
impeller::SurfaceContextVK::SurfaceContextVK
SurfaceContextVK(const std::shared_ptr< ContextVK > &parent)
Definition: surface_context_vk.cc:14
backend_cast.h
impeller::SurfaceContextVK::DescribeGpuModel
std::string DescribeGpuModel() const override
Definition: surface_context_vk.cc:23
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:47
impeller::BackendCast
Definition: backend_cast.h:13
impeller::SurfaceContextVK::SetSyncPresentation
void SetSyncPresentation(bool value) override
Force the Vulkan presentation (submitKHR) to be performed on the raster task runner.
Definition: surface_context_vk.cc:91
impeller::SurfaceContextVK::GetResourceAllocator
std::shared_ptr< Allocator > GetResourceAllocator() const override
Returns the allocator used to create textures and buffers on the device.
Definition: surface_context_vk.cc:31
context.h
impeller::SurfaceContextVK::GetPipelineLibrary
std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const override
Returns the library of pipelines used by render or compute commands.
Definition: surface_context_vk.cc:43
impeller::SurfaceContextVK::IsValid
bool IsValid() const override
Determines if a context is valid. If the caller ever receives an invalid context, they must discard i...
Definition: surface_context_vk.cc:27
impeller
Definition: aiks_context.cc:10
impeller::SurfaceContextVK::Shutdown
void Shutdown() override
Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent mess...
Definition: surface_context_vk.cc:56