28 impeller::vk::UniqueImageView image_view,
32 image_view_(
std::move(image_view)) {}
37 impeller::vk::Image GetImage()
const override {
return image_; }
39 impeller::vk::ImageView GetImageView()
const override {
40 return image_view_.get();
43 impeller::vk::ImageView GetRenderTargetView()
const override {
44 return image_view_.get();
47 bool IsSwapchainImage()
const override {
return true; }
49 impeller::vk::Image image_;
50 impeller::vk::UniqueImageView image_view_;
55 std::shared_ptr<impeller::Context> context)
57 if (!context || !context->IsValid()) {
61 auto aiks_context = std::make_shared<impeller::AiksContext>(
63 if (!aiks_context->IsValid()) {
67 impeller_context_ = std::move(context);
68 aiks_context_ = std::move(aiks_context);
69 is_valid_ = !!aiks_context_;
81std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(
84 FML_LOG(ERROR) <<
"Vulkan surface was invalid.";
89 FML_LOG(ERROR) <<
"Vulkan surface was asked for an empty frame.";
93 if (delegate_ ==
nullptr) {
95 std::unique_ptr<impeller::Surface>
surface =
96 context_vk.AcquireNextSurface();
99 FML_LOG(ERROR) <<
"No surface available.";
111 ](SurfaceFrame& surface_frame,
DlCanvas* canvas)
mutable ->
bool {
116 auto display_list = surface_frame.BuildDisplayList();
118 FML_LOG(ERROR) <<
"Could not build display list for surface frame.";
123 aiks_context->GetContentContext(),
127 surface_frame.submit_info().frame_boundary
131 return std::make_unique<SurfaceFrame>(
133 SurfaceFrame::FramebufferInfo{},
144 if (!flutter_image.
image) {
145 FML_LOG(ERROR) <<
"Invalid VkImage given by the embedder.";
148 impeller::vk::Format vk_format =
149 static_cast<impeller::vk::Format
>(flutter_image.
format);
150 std::optional<impeller::PixelFormat>
format =
152 if (!
format.has_value()) {
153 FML_LOG(ERROR) <<
"Unsupported pixel format: "
154 << impeller::vk::to_string(vk_format);
163 impeller::vk::Image vk_image =
164 impeller::vk::Image(
reinterpret_cast<VkImage
>(flutter_image.
image));
174 impeller::vk::ImageViewCreateInfo view_info = {};
175 view_info.viewType = impeller::vk::ImageViewType::e2D;
177 view_info.subresourceRange.aspectMask =
178 impeller::vk::ImageAspectFlagBits::eColor;
179 view_info.subresourceRange.baseMipLevel = 0u;
180 view_info.subresourceRange.baseArrayLayer = 0u;
181 view_info.subresourceRange.levelCount = 1;
182 view_info.subresourceRange.layerCount = 1;
183 view_info.image = vk_image;
185 auto [result, image_view] =
186 context_vk.
GetDevice().createImageViewUnique(view_info);
187 if (result != impeller::vk::Result::eSuccess) {
188 FML_LOG(ERROR) <<
"Failed to create image view for provided image: "
189 << impeller::vk::to_string(result);
194 if (transients_ ==
nullptr || transients_size_ != frame_size) {
195 transients_ = std::make_shared<impeller::SwapchainTransientsVK>(
196 impeller_context_, desc,
198 transients_size_ = frame_size;
201 auto wrapped_onscreen = std::make_shared<WrappedTextureSourceVK>(
202 vk_image, std::move(image_view), desc);
204 transients_, wrapped_onscreen, [&]() ->
bool {
return true; });
213 ](SurfaceFrame& surface_frame,
DlCanvas* canvas)
mutable ->
bool {
218 auto display_list = surface_frame.BuildDisplayList();
220 FML_LOG(ERROR) <<
"Could not build display list for surface frame.";
233 [
image = flutter_image, delegate = delegate_,
234 impeller_context = impeller_context_,
235 wrapped_onscreen](
const SurfaceFrame&) ->
bool {
236 TRACE_EVENT0(
"flutter",
"GPUSurfaceVulkan::PresentImage");
244 auto cmd_buffer = context.CreateCommandBuffer();
246 auto vk_final_cmd_buffer =
251 impeller::vk::ImageLayout::eColorAttachmentOptimal;
254 impeller::vk::AccessFlagBits::eColorAttachmentWrite;
256 impeller::vk::PipelineStageFlagBits::eColorAttachmentOutput;
259 impeller::vk::PipelineStageFlagBits::eBottomOfPipe;
261 if (!wrapped_onscreen->SetLayout(barrier).ok()) {
265 if (!context.GetCommandQueue()->Submit({cmd_buffer}).ok()) {
270 return delegate->PresentImage(
reinterpret_cast<VkImage
>(
image.
image),
274 SurfaceFrame::FramebufferInfo framebuffer_info{.supports_readback =
true};
276 return std::make_unique<SurfaceFrame>(
nullptr,
288DlMatrix GPUSurfaceVulkanImpeller::GetRootTransformation()
const {
295GrDirectContext* GPUSurfaceVulkanImpeller::GetContext() {
301std::unique_ptr<GLContextResult>
302GPUSurfaceVulkanImpeller::MakeRenderContextCurrent() {
304 return std::make_unique<GLContextDefaultResult>(
true);
308bool GPUSurfaceVulkanImpeller::EnableRasterCache()
const {
313std::shared_ptr<impeller::AiksContext>
314GPUSurfaceVulkanImpeller::GetAiksContext()
const {
315 return aiks_context_;
Interface implemented by all platform surfaces that can present a Vulkan backing store to the "screen...
virtual FlutterVulkanImage AcquireImage(const DlISize &size)=0
Called by the engine to fetch a VkImage for writing the next frame.
~GPUSurfaceVulkanImpeller() override
GPUSurfaceVulkanImpeller(GPUSurfaceVulkanDelegate *delegate, std::shared_ptr< impeller::Context > context)
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> EncodeCallback
std::function< bool(SurfaceFrame &surface_frame)> SubmitCallback
WrappedTextureSourceVK(impeller::vk::Image image, impeller::vk::UniqueImageView image_view, impeller::TextureDescriptor desc)
~WrappedTextureSourceVK() override=default
static SurfaceContextVK & Cast(Context &base)
vk::CommandBuffer GetCommandBuffer() const
Retrieve the native command buffer from this object.
const vk::Device & GetDevice() const
void DisposeThreadLocalCachedResources() override
ISize GetRenderTargetSize() const
static std::unique_ptr< SurfaceVK > WrapSwapchainImage(const std::shared_ptr< SwapchainTransientsVK > &transients, const std::shared_ptr< TextureSourceVK > &swapchain_image, SwapCallback swap_callback)
Wrap the swapchain image in a Surface, which provides the additional configuration required for usage...
Abstract base class that represents a vkImage and an vkImageView.
static std::shared_ptr< TypographerContext > Make()
FlutterVulkanImage * image
uint32_t uint32_t * format
#define FML_LOG(severity)
impeller::Matrix DlMatrix
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
internal::CopyableLambda< T > MakeCopyable(T lambda)
constexpr std::optional< PixelFormat > VkFormatToImpellerFormat(vk::Format format)
constexpr vk::Format ToVKImageFormat(PixelFormat format)
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, Rect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
flutter::DlCanvas DlCanvas
FlutterVulkanImageHandle image
uint32_t format
The VkFormat of the image (for example: VK_FORMAT_R8G8B8A8_UNORM).
Defines an operations and memory access barrier on a resource.
vk::CommandBuffer cmd_buffer
vk::AccessFlags src_access
vk::PipelineStageFlags dst_stage
vk::ImageLayout new_layout
vk::PipelineStageFlags src_stage
vk::AccessFlags dst_access
static constexpr TRect MakeSize(const TSize< U > &size)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
CompressionType compression_type
#define TRACE_EVENT0(category_group, name)