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(
45 uint32_t array_layer)
const override {
47 return image_view_.get();
50 bool IsSwapchainImage()
const override {
return true; }
52 impeller::vk::Image image_;
53 impeller::vk::UniqueImageView image_view_;
58 std::shared_ptr<impeller::Context>
context)
64 auto aiks_context = std::make_shared<impeller::AiksContext>(
66 if (!aiks_context->IsValid()) {
70 impeller_context_ = std::move(
context);
71 aiks_context_ = std::move(aiks_context);
72 is_valid_ = !!aiks_context_;
84std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(
87 FML_LOG(ERROR) <<
"Vulkan surface was invalid.";
92 FML_LOG(ERROR) <<
"Vulkan surface was asked for an empty frame.";
96 if (delegate_ ==
nullptr) {
98 std::unique_ptr<impeller::Surface>
surface =
99 context_vk.AcquireNextSurface();
102 FML_LOG(ERROR) <<
"No surface available.";
114 ](SurfaceFrame& surface_frame,
DlCanvas* canvas)
mutable ->
bool {
119 auto display_list = surface_frame.BuildDisplayList();
121 FML_LOG(ERROR) <<
"Could not build display list for surface frame.";
126 aiks_context->GetContentContext(),
130 surface_frame.submit_info().frame_boundary
134 return std::make_unique<SurfaceFrame>(
136 SurfaceFrame::FramebufferInfo{},
147 if (!flutter_image.
image) {
148 FML_LOG(ERROR) <<
"Invalid VkImage given by the embedder.";
151 impeller::vk::Format vk_format =
152 static_cast<impeller::vk::Format
>(flutter_image.
format);
153 std::optional<impeller::PixelFormat>
format =
155 if (!
format.has_value()) {
156 FML_LOG(ERROR) <<
"Unsupported pixel format: "
157 << impeller::vk::to_string(vk_format);
166 impeller::vk::Image vk_image =
167 impeller::vk::Image(
reinterpret_cast<VkImage
>(flutter_image.
image));
177 impeller::vk::ImageViewCreateInfo view_info = {};
178 view_info.viewType = impeller::vk::ImageViewType::e2D;
180 view_info.subresourceRange.aspectMask =
181 impeller::vk::ImageAspectFlagBits::eColor;
182 view_info.subresourceRange.baseMipLevel = 0u;
183 view_info.subresourceRange.baseArrayLayer = 0u;
184 view_info.subresourceRange.levelCount = 1;
185 view_info.subresourceRange.layerCount = 1;
186 view_info.image = vk_image;
188 auto [result, image_view] =
189 context_vk.
GetDevice().createImageViewUnique(view_info);
190 if (result != impeller::vk::Result::eSuccess) {
191 FML_LOG(ERROR) <<
"Failed to create image view for provided image: "
192 << impeller::vk::to_string(result);
197 if (transients_ ==
nullptr || transients_size_ != frame_size) {
198 transients_ = std::make_shared<impeller::SwapchainTransientsVK>(
199 impeller_context_, desc,
201 transients_size_ = frame_size;
204 auto wrapped_onscreen = std::make_shared<WrappedTextureSourceVK>(
205 vk_image, std::move(image_view), desc);
207 transients_, wrapped_onscreen, [&]() ->
bool {
return true; });
216 ](SurfaceFrame& surface_frame,
DlCanvas* canvas)
mutable ->
bool {
221 auto display_list = surface_frame.BuildDisplayList();
223 FML_LOG(ERROR) <<
"Could not build display list for surface frame.";
236 [
image = flutter_image, delegate = delegate_,
237 impeller_context = impeller_context_,
238 wrapped_onscreen](
const SurfaceFrame&) ->
bool {
239 TRACE_EVENT0(
"flutter",
"GPUSurfaceVulkan::PresentImage");
247 auto cmd_buffer =
context.CreateCommandBuffer();
249 auto vk_final_cmd_buffer =
254 impeller::vk::ImageLayout::eColorAttachmentOptimal;
257 impeller::vk::AccessFlagBits::eColorAttachmentWrite;
259 impeller::vk::PipelineStageFlagBits::eColorAttachmentOutput;
262 impeller::vk::PipelineStageFlagBits::eBottomOfPipe;
264 if (!wrapped_onscreen->SetLayout(barrier).ok()) {
268 if (!
context.GetCommandQueue()->Submit({cmd_buffer}).ok()) {
273 return delegate->PresentImage(
reinterpret_cast<VkImage
>(
image.
image),
277 SurfaceFrame::FramebufferInfo framebuffer_info{.supports_readback =
true};
279 return std::make_unique<SurfaceFrame>(
nullptr,
291DlMatrix GPUSurfaceVulkanImpeller::GetRootTransformation()
const {
298GrDirectContext* GPUSurfaceVulkanImpeller::GetContext() {
304std::unique_ptr<GLContextResult>
305GPUSurfaceVulkanImpeller::MakeRenderContextCurrent() {
307 return std::make_unique<GLContextDefaultResult>(
true);
311bool GPUSurfaceVulkanImpeller::EnableRasterCache()
const {
316std::shared_ptr<impeller::AiksContext>
317GPUSurfaceVulkanImpeller::GetAiksContext()
const {
318 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
std::shared_ptr< ContextGLES > context
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)