Flutter Engine
 
Loading...
Searching...
No Matches
android_surface_vk_impeller.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 <memory>
8#include <utility>
9
11#include "flutter/fml/logging.h"
19
20namespace flutter {
21
23 const std::shared_ptr<AndroidContextVKImpeller>& android_context) {
24 is_valid_ = android_context->IsValid();
25
26 auto& context_vk =
27 impeller::ContextVK::Cast(*android_context->GetImpellerContext());
28 surface_context_vk_ = context_vk.CreateSurfaceContext();
29}
30
32
34 return is_valid_;
35}
36
38 surface_context_vk_->TeardownSwapchain();
39}
40
42 GrDirectContext* gr_context) {
43 if (!IsValid()) {
44 return nullptr;
45 }
46
47 if (!native_window_ || !native_window_->IsValid()) {
48 return nullptr;
49 }
50
51 std::unique_ptr<GPUSurfaceVulkanImpeller> gpu_surface =
52 std::make_unique<GPUSurfaceVulkanImpeller>(nullptr, surface_context_vk_);
53
54 if (!gpu_surface->IsValid()) {
55 return nullptr;
56 }
57
58 return gpu_surface;
59}
60
62 surface_context_vk_->UpdateSurfaceSize(
64 return true;
65}
66
70
74
77 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade) {
78 if (window && (native_window_ == window)) {
79 return OnScreenSurfaceResize(window->GetSize());
80 }
81
82 native_window_ = nullptr;
83
84 if (!window || !window->IsValid()) {
85 return false;
86 }
87
88 impeller::CreateTransactionCB cb = [jni_facade = jni_facade]() {
89 FML_CHECK(jni_facade) << "JNI was nullptr";
90 ASurfaceTransaction* tx = jni_facade->createTransaction();
91 if (tx == nullptr) {
93 }
95 };
96
98 std::reinterpret_pointer_cast<impeller::Context>(
99 surface_context_vk_->GetParent()),
100 window->handle(), cb);
101
102 if (surface_context_vk_->SetSwapchain(std::move(swapchain))) {
103 native_window_ = std::move(window);
104 return true;
105 }
106
107 return false;
108}
109
110std::shared_ptr<impeller::Context>
112 return surface_context_vk_;
113}
114
115} // namespace flutter
std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context) override
bool SetNativeWindow(fml::RefPtr< AndroidNativeWindow > window, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade) override
bool OnScreenSurfaceResize(const DlISize &size) override
std::shared_ptr< impeller::Context > GetImpellerContext() override
AndroidSurfaceVKImpeller(const std::shared_ptr< AndroidContextVKImpeller > &android_context)
static ContextVK & Cast(Context &base)
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#...
VkSwapchainKHR swapchain
Definition main.cc:80
GLFWwindow * window
Definition main.cc:60
#define FML_CHECK(condition)
Definition logging.h:104
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::function< android::SurfaceTransaction()> CreateTransactionCB
Type width
Definition size.h:28