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"
20#define VULKAN_SO_PATH "libvulkan.so"
22#include "flutter/vulkan/swiftshader_path.h"
31 std::shared_ptr<ShellTestVsyncClock> vsync_clock,
33 std::shared_ptr<ShellTestExternalViewEmbedder>
34 shell_test_external_view_embedder)
36 create_vsync_waiter_(
std::move(create_vsync_waiter)),
37 vsync_clock_(
std::move(vsync_clock)),
39 shell_test_external_view_embedder_(
40 std::move(shell_test_external_view_embedder)) {}
45 return create_vsync_waiter_();
49 vsync_clock_->SimulateVSync();
54 return std::make_unique<OffScreenSurface>(proc_table_,
55 shell_test_external_view_embedder_);
59std::shared_ptr<ExternalViewEmbedder>
61 return shell_test_external_view_embedder_;
67 return std::make_unique<SmoothPointerDataDispatcher>(delegate);
75ShellTestPlatformViewVulkan::OffScreenSurface::OffScreenSurface(
77 std::shared_ptr<ShellTestExternalViewEmbedder>
78 shell_test_external_view_embedder)
80 shell_test_external_view_embedder_(
81 std::move(shell_test_external_view_embedder)) {
82 if (!vk_ || !vk_->HasAcquiredMandatoryProcAddresses()) {
83 FML_DLOG(
ERROR) <<
"Proc table has not acquired mandatory proc addresses.";
88 std::vector<std::string> extensions = {
92 application_ = std::make_unique<vulkan::VulkanApplication>(
96 if (!application_->IsValid() || !vk_->AreInstanceProcsSetup()) {
99 FML_DLOG(
ERROR) <<
"Instance proc addresses have not been set up.";
105 logical_device_ = application_->AcquireFirstCompatibleLogicalDevice();
107 if (logical_device_ ==
nullptr || !logical_device_->IsValid() ||
108 !vk_->AreDeviceProcsSetup()) {
111 FML_DLOG(
ERROR) <<
"Device proc addresses have not been set up.";
116 application_->GetAPIVersion(), application_->GetInstance(),
117 logical_device_->GetPhysicalDeviceHandle(), logical_device_->GetHandle(),
121 if (!CreateSkiaGrContext()) {
129bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() {
132 if (!CreateSkiaBackendContext(&backend_context)) {
143 if (context ==
nullptr) {
155bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaBackendContext(
159 if (getProc ==
nullptr) {
164 uint32_t skia_features = 0;
165 if (!logical_device_->GetPhysicalDeviceFeaturesSkia(&skia_features)) {
170 context->
fInstance = application_->GetInstance();
172 context->
fDevice = logical_device_->GetHandle();
173 context->
fQueue = logical_device_->GetQueueHandle();
178 context->
fGetProc = std::move(getProc);
185ShellTestPlatformViewVulkan::OffScreenSurface::~OffScreenSurface() {}
187bool ShellTestPlatformViewVulkan::OffScreenSurface::IsValid() {
191std::unique_ptr<SurfaceFrame>
192ShellTestPlatformViewVulkan::OffScreenSurface::AcquireFrame(
197 image_info, 0,
nullptr);
199 DlCanvas* canvas) ->
bool {
204 SurfaceFrame::FramebufferInfo framebuffer_info;
205 framebuffer_info.supports_readback =
true;
207 return std::make_unique<SurfaceFrame>(std::move(
surface), framebuffer_info,
212GrDirectContext* ShellTestPlatformViewVulkan::OffScreenSurface::GetContext() {
213 return context_.get();
216SkMatrix ShellTestPlatformViewVulkan::OffScreenSurface::GetRootTransformation()
@ kOpaque_SkAlphaType
pixel is opaque
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static sk_sp< VulkanMemoryAllocator > Make(uint32_t vulkan_api_version, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, const fml::RefPtr< vulkan::VulkanProcTable > &vk, bool mustUseCoherentHostVisibleMemory)
The interface for Engine to implement.
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> SubmitCallback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DLOG(severity)
SK_API sk_sp< GrDirectContext > MakeVulkan(const GrVkBackendContext &, const GrContextOptions &)
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.
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
static const size_t kGrCacheMaxByteSize
GrVkGetProc CreateSkiaGetProc(const fml::RefPtr< vulkan::VulkanProcTable > &vk)
bool fOwnsInstanceAndDevice
VkPhysicalDevice fPhysicalDevice
uint32_t fGraphicsQueueIndex
skgpu::VulkanGetProc fGetProc
sk_sp< skgpu::VulkanMemoryAllocator > fMemoryAllocator
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
#define VK_MAKE_VERSION(major, minor, patch)
#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME