5#include "flutter/shell/common/shell_test_platform_view_vulkan.h"
9#include "flutter/common/graphics/persistent_cache.h"
10#include "flutter/flutter_vma/flutter_skia_vma.h"
11#include "flutter/shell/common/context_options.h"
12#include "flutter/vulkan/vulkan_skia_proc_table.h"
13#include "flutter/vulkan/vulkan_utilities.h"
21#define VULKAN_SO_PATH "libvulkan.so"
23#include "flutter/vulkan/swiftshader_path.h"
32 std::shared_ptr<ShellTestVsyncClock> vsync_clock,
34 std::shared_ptr<ShellTestExternalViewEmbedder>
35 shell_test_external_view_embedder)
37 create_vsync_waiter_(
std::move(create_vsync_waiter)),
38 vsync_clock_(
std::move(vsync_clock)),
40 shell_test_external_view_embedder_(
41 std::move(shell_test_external_view_embedder)) {}
45std::unique_ptr<VsyncWaiter> ShellTestPlatformViewVulkan::CreateVSyncWaiter() {
46 return create_vsync_waiter_();
50 vsync_clock_->SimulateVSync();
54std::unique_ptr<Surface> ShellTestPlatformViewVulkan::CreateRenderingSurface() {
55 return std::make_unique<OffScreenSurface>(proc_table_,
56 shell_test_external_view_embedder_);
60std::shared_ptr<ExternalViewEmbedder>
61ShellTestPlatformViewVulkan::CreateExternalViewEmbedder() {
62 return shell_test_external_view_embedder_;
67 return [](DefaultPointerDataDispatcher::Delegate& delegate) {
68 return std::make_unique<SmoothPointerDataDispatcher>(delegate);
76ShellTestPlatformViewVulkan::OffScreenSurface::OffScreenSurface(
78 std::shared_ptr<ShellTestExternalViewEmbedder>
79 shell_test_external_view_embedder)
81 shell_test_external_view_embedder_(
82 std::move(shell_test_external_view_embedder)) {
83 if (!vk_ || !vk_->HasAcquiredMandatoryProcAddresses()) {
84 FML_DLOG(
ERROR) <<
"Proc table has not acquired mandatory proc addresses.";
93 application_ = std::make_unique<vulkan::VulkanApplication>(
97 if (!application_->IsValid() || !vk_->AreInstanceProcsSetup()) {
100 FML_DLOG(
ERROR) <<
"Instance proc addresses have not been set up.";
106 logical_device_ = application_->AcquireFirstCompatibleLogicalDevice();
108 if (logical_device_ ==
nullptr || !logical_device_->IsValid() ||
109 !vk_->AreDeviceProcsSetup()) {
112 FML_DLOG(
ERROR) <<
"Device proc addresses have not been set up.";
117 application_->GetAPIVersion(), application_->GetInstance(),
118 logical_device_->GetPhysicalDeviceHandle(), logical_device_->GetHandle(),
122 if (!CreateSkiaGrContext()) {
130bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() {
140 if (!this->CreateSkiaBackendContext(&backend_context, &features)) {
151 if (context ==
nullptr) {
163bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaBackendContext(
170 if (getProc ==
nullptr) {
175 if (!logical_device_->GetPhysicalDeviceFeatures(features)) {
180 context->
fInstance = application_->GetInstance();
182 context->
fDevice = logical_device_->GetHandle();
183 context->
fQueue = logical_device_->GetQueueHandle();
187 context->
fGetProc = std::move(getProc);
193ShellTestPlatformViewVulkan::OffScreenSurface::~OffScreenSurface() {}
195bool ShellTestPlatformViewVulkan::OffScreenSurface::IsValid() {
199std::unique_ptr<SurfaceFrame>
200ShellTestPlatformViewVulkan::OffScreenSurface::AcquireFrame(
205 image_info, 0,
nullptr);
212 SurfaceFrame::FramebufferInfo framebuffer_info;
213 framebuffer_info.supports_readback =
true;
215 return std::make_unique<SurfaceFrame>(std::move(
surface), framebuffer_info,
221 return context_.get();
224SkMatrix ShellTestPlatformViewVulkan::OffScreenSurface::GetRootTransformation()
@ kOpaque_SkAlphaType
pixel is opaque
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
void setResourceCacheLimit(size_t maxResourceBytes)
static sk_sp< VulkanMemoryAllocator > Make(uint32_t vulkan_api_version, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, const fml::RefPtr< vulkan::VulkanProcTable > &vk, bool mustUseCoherentHostVisibleMemory)
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> SubmitCallback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DLOG(severity)
#define FML_CHECK(condition)
SK_API sk_sp< GrDirectContext > MakeVulkan(const skgpu::VulkanBackendContext &, const GrContextOptions &)
SK_API GrDirectContext * GetContext(const SkImage *src)
unsigned useCenter Optional< SkMatrix > matrix
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...
std::function< std::unique_ptr< PointerDataDispatcher >(PointerDataDispatcher::Delegate &)> PointerDataDispatcherMaker
Signature for constructing PointerDataDispatcher.
@ kRender
The context is used to render to a texture or renderbuffer.
it will be possible to load the file into Perfetto s trace viewer 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
RefPtr< T > MakeRefCounted(Args &&... args)
flutter::DlCanvas DlCanvas
static const size_t kGrCacheMaxByteSize
GrVkGetProc CreateSkiaGetProc(const fml::RefPtr< vulkan::VulkanProcTable > &vk)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
sk_sp< VulkanMemoryAllocator > fMemoryAllocator
const VkPhysicalDeviceFeatures * fDeviceFeatures
uint32_t fGraphicsQueueIndex
skgpu::VulkanGetProc fGetProc
VkPhysicalDevice fPhysicalDevice
const skgpu::VulkanExtensions * fVkExtensions
#define VK_MAKE_VERSION(major, minor, patch)
#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME