Flutter Engine
 
Loading...
Searching...
No Matches
embedder_test_context_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
6
7#include <memory>
8#include <utility>
9
10#include "flutter/fml/logging.h"
16#include "third_party/skia/include/core/SkSurface.h"
17
18namespace flutter::testing {
19
21 : EmbedderTestContext(std::move(assets_path)), surface_() {
22 vulkan_context_ = fml::MakeRefCounted<TestVulkanContext>();
26 .version = vulkan_context_->application_->GetAPIVersion(),
27 .instance = vulkan_context_->application_->GetInstance(),
28 .physical_device = vulkan_context_->device_->GetPhysicalDeviceHandle(),
29 .device = vulkan_context_->device_->GetHandle(),
30 .queue_family_index = vulkan_context_->device_->GetGraphicsQueueIndex(),
31 .queue = vulkan_context_->device_->GetQueueHandle(),
32 .get_instance_proc_address_callback =
34 .get_next_image_callback =
35 [](void* context,
36 const FlutterFrameInfo* frame_info) -> FlutterVulkanImage {
37 VkImage image =
38 reinterpret_cast<EmbedderTestContextVulkan*>(context)->GetNextImage(
39 {static_cast<int>(frame_info->size.width),
40 static_cast<int>(frame_info->size.height)});
41 return {
42 .struct_size = sizeof(FlutterVulkanImage),
43 .image = reinterpret_cast<uint64_t>(image),
44 .format = VK_FORMAT_R8G8B8A8_UNORM,
45 };
46 },
47 .present_image_callback = [](void* context,
48 const FlutterVulkanImage* image) -> bool {
49 return reinterpret_cast<EmbedderTestContextVulkan*>(context)
50 ->PresentImage(reinterpret_cast<VkImage>(image->image));
51 },
52 };
53}
54
56
60
65
67 return present_count_;
68}
69
71 return surface_->GetImage();
72}
73
76 [&]() { return surface_->GetSurfaceSnapshot(); });
77 present_count_++;
78 return true;
79}
80
82 void* user_data,
84 const char* name) {
85 auto proc_addr = reinterpret_cast<EmbedderTestContextVulkan*>(user_data)
86 ->vulkan_context_->vk_->GetInstanceProcAddr(
87 reinterpret_cast<VkInstance>(instance), name);
88 return reinterpret_cast<void*>(proc_addr);
89}
90
91void EmbedderTestContextVulkan::SetSurface(DlISize surface_size) {
92 FML_CHECK(surface_size_.IsEmpty());
93 surface_size_ = surface_size;
94 surface_ = TestVulkanSurface::Create(*vulkan_context_, surface_size_);
95}
96
97void EmbedderTestContextVulkan::SetupCompositor() {
98 FML_CHECK(!compositor_) << "Already set up a compositor in this context.";
99 FML_CHECK(surface_)
100 << "Set up the Vulkan surface before setting up a compositor.";
101 compositor_ = std::make_unique<EmbedderTestCompositorVulkan>(
102 surface_size_, vulkan_context_->GetGrDirectContext());
103}
104
105} // namespace flutter::testing
std::unique_ptr< EmbedderTestCompositor > compositor_
void FireRootSurfacePresentCallbackIfPresent(const std::function< sk_sp< SkImage >(void)> &image_callback)
static void * InstanceProcAddr(void *user_data, FlutterVulkanInstanceHandle instance, const char *name)
EmbedderTestContextType GetContextType() const override
void SetVulkanInstanceProcAddressCallback(FlutterVulkanInstanceProcAddressCallback callback)
static std::unique_ptr< TestVulkanSurface > Create(const TestVulkanContext &context, const DlISize &surface_size)
@ kVulkan
Definition embedder.h:86
void *(* FlutterVulkanInstanceProcAddressCallback)(void *, FlutterVulkanInstanceHandle, const char *)
Definition embedder.h:938
void * FlutterVulkanInstanceHandle
Alias for VkInstance.
Definition embedder.h:912
FlutterVulkanImage * image
VkInstance instance
Definition main.cc:64
FlutterDesktopBinaryReply callback
#define FML_CHECK(condition)
Definition logging.h:104
EGLSurface surface_
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
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
Definition ref_ptr.h:261
FlutterVulkanRendererConfig vulkan
Definition embedder.h:1036
FlutterRendererType type
Definition embedder.h:1031
FlutterVulkanImageHandle image
Definition embedder.h:931
uint32_t format
The VkFormat of the image (for example: VK_FORMAT_R8G8B8A8_UNORM).
Definition embedder.h:933
FlutterVulkanInstanceProcAddressCallback get_instance_proc_address_callback
Definition embedder.h:1006
size_t struct_size
The size of this struct. Must be sizeof(FlutterVulkanRendererConfig).
Definition embedder.h:956
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition size.h:123