Flutter Impeller
swapchain_vk.cc
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 
6 
7 #include "flutter/fml/trace_event.h"
11 
12 #if FML_OS_ANDROID
15 #endif // FML_OS_ANDROID
16 
17 namespace impeller {
18 
19 std::shared_ptr<SwapchainVK> SwapchainVK::Create(
20  const std::shared_ptr<Context>& context,
21  vk::UniqueSurfaceKHR surface,
22  const ISize& size,
23  bool enable_msaa) {
24  auto swapchain = std::shared_ptr<KHRSwapchainVK>(
25  new KHRSwapchainVK(context, std::move(surface), size, enable_msaa));
26  if (!swapchain->IsValid()) {
27  VALIDATION_LOG << "Could not create valid swapchain.";
28  return nullptr;
29  }
30  return swapchain;
31 }
32 
33 #if FML_OS_ANDROID
34 std::shared_ptr<SwapchainVK> SwapchainVK::Create(
35  const std::shared_ptr<Context>& context,
36  ANativeWindow* p_window,
37  bool enable_msaa) {
38  TRACE_EVENT0("impeller", "CreateAndroidSwapchain");
39  if (!context) {
40  return nullptr;
41  }
42 
43  android::NativeWindow window(p_window);
44  if (!window.IsValid()) {
45  return nullptr;
46  }
47 
48  vk::AndroidSurfaceCreateInfoKHR surface_info;
49  surface_info.setWindow(window.GetHandle());
50  auto [result, surface] =
51  ContextVK::Cast(*context).GetInstance().createAndroidSurfaceKHRUnique(
52  surface_info);
53  if (result != vk::Result::eSuccess) {
54  VALIDATION_LOG << "Could not create KHR Android Surface: "
55  << vk::to_string(result);
56  return nullptr;
57  }
58 
59  return Create(context, std::move(surface), window.GetSize(), enable_msaa);
60 }
61 #endif // FML_OS_ANDROID
62 
63 SwapchainVK::SwapchainVK() = default;
64 
65 SwapchainVK::~SwapchainVK() = default;
66 
67 } // namespace impeller
khr_swapchain_vk.h
ahb_swapchain_vk.h
impeller::ContextVK::GetInstance
vk::Instance GetInstance() const
Definition: context_vk.cc:526
swapchain_vk.h
vk.h
impeller::TSize
Definition: size.h:19
impeller::SwapchainVK::SwapchainVK
SwapchainVK()
impeller::SwapchainVK::Create
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
Definition: swapchain_vk.cc:19
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
shadow_realm.h
impeller::KHRSwapchainVK
A swapchain implemented backed by VK_KHR_swapchain and VK_KHR_surface.
Definition: khr_swapchain_vk.h:24
impeller::BackendCast< ContextVK, Context >::Cast
static ContextVK & Cast(Context &base)
Definition: backend_cast.h:13
context_vk.h
impeller
Definition: allocation.cc:12
impeller::SwapchainVK::~SwapchainVK
virtual ~SwapchainVK()