Flutter Engine
android_surface_vulkan.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 
5 #include "flutter/shell/platform/android/android_surface_vulkan.h"
6 
7 #include <utility>
8 
9 #include "flutter/fml/logging.h"
10 #include "flutter/shell/gpu/gpu_surface_vulkan.h"
11 #include "flutter/vulkan/vulkan_native_surface_android.h"
12 
13 namespace flutter {
14 
16  std::shared_ptr<AndroidContext> android_context,
17  std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
18  std::shared_ptr<AndroidExternalViewEmbedder> external_view_embedder)
19  : external_view_embedder_(external_view_embedder),
20  proc_table_(fml::MakeRefCounted<vulkan::VulkanProcTable>()) {}
21 
23 
25  return proc_table_->HasAcquiredMandatoryProcAddresses();
26 }
27 
29  // Nothing to do.
30 }
31 
32 std::unique_ptr<Surface> AndroidSurfaceVulkan::CreateGPUSurface(
33  GrDirectContext* gr_context) {
34  if (!IsValid()) {
35  return nullptr;
36  }
37 
38  if (!native_window_ || !native_window_->IsValid()) {
39  return nullptr;
40  }
41 
42  auto vulkan_surface_android =
43  std::make_unique<vulkan::VulkanNativeSurfaceAndroid>(
44  native_window_->handle());
45 
46  if (!vulkan_surface_android->IsValid()) {
47  return nullptr;
48  }
49 
50  auto gpu_surface = std::make_unique<GPUSurfaceVulkan>(
51  this, std::move(vulkan_surface_android), true);
52 
53  if (!gpu_surface->IsValid()) {
54  return nullptr;
55  }
56 
57  return gpu_surface;
58 }
59 
61  return true;
62 }
63 
65  FML_DLOG(ERROR) << "The vulkan backend does not support resource contexts.";
66  return false;
67 }
68 
70  FML_DLOG(ERROR) << "The vulkan backend does not support resource contexts.";
71  return false;
72 }
73 
76  native_window_ = std::move(window);
77  return native_window_ && native_window_->IsValid();
78 }
79 
81  return external_view_embedder_.get();
82 }
83 
85  return proc_table_;
86 }
87 
88 } // namespace flutter
bool SetNativeWindow(fml::RefPtr< AndroidNativeWindow > window) override
ExternalViewEmbedder * GetExternalViewEmbedder() override
Gets the view embedder that controls how the Flutter layer hierarchy split into multiple chunks shoul...
fml::RefPtr< vulkan::VulkanProcTable > vk() override
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
Definition: ascii_trie.cc:9
AndroidSurfaceVulkan(std::shared_ptr< AndroidContext > android_context, std::shared_ptr< PlatformViewAndroidJNI > jni_facade, std::shared_ptr< AndroidExternalViewEmbedder > external_view_embedder)
bool HasAcquiredMandatoryProcAddresses() const
RefPtr< T > MakeRefCounted(Args &&... args)
Definition: ref_ptr.h:244
bool OnScreenSurfaceResize(const SkISize &size) override
std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context) override
#define FML_DLOG(severity)
Definition: logging.h:85