Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] eagerly bootstrap content context. #52590

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions shell/platform/android/android_surface_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ AndroidSurfaceVulkanImpeller::AndroidSurfaceVulkanImpeller(
auto& context_vk =
impeller::ContextVK::Cast(*android_context->GetImpellerContext());
surface_context_vk_ = context_vk.CreateSurfaceContext();
eager_gpu_surface_ =
std::make_unique<GPUSurfaceVulkanImpeller>(surface_context_vk_);
}

AndroidSurfaceVulkanImpeller::~AndroidSurfaceVulkanImpeller() = default;
Expand All @@ -46,6 +48,14 @@ std::unique_ptr<Surface> AndroidSurfaceVulkanImpeller::CreateGPUSurface(
return nullptr;
}

if (eager_gpu_surface_) {
auto gpu_surface = std::move(eager_gpu_surface_);
if (!gpu_surface->IsValid()) {
return nullptr;
}
return gpu_surface;
}

std::unique_ptr<GPUSurfaceVulkanImpeller> gpu_surface =
std::make_unique<GPUSurfaceVulkanImpeller>(surface_context_vk_);

Expand Down
6 changes: 6 additions & 0 deletions shell/platform/android/android_surface_vulkan_impeller.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "flutter/shell/platform/android/android_context_vulkan_impeller.h"
#include "flutter/shell/platform/android/surface/android_native_window.h"
#include "flutter/shell/platform/android/surface/android_surface.h"
#include "shell/gpu/gpu_surface_vulkan_impeller.h"

namespace flutter {

Expand Down Expand Up @@ -49,6 +50,11 @@ class AndroidSurfaceVulkanImpeller : public AndroidSurface {
private:
std::shared_ptr<impeller::SurfaceContextVK> surface_context_vk_;
fml::RefPtr<AndroidNativeWindow> native_window_;
// The first GPU Surface is initialized as soon as the
// AndroidSurfaceVulkanImpeller is created. This ensures that the pipelines
// are bootstrapped as early as possible.
std::unique_ptr<GPUSurfaceVulkanImpeller> eager_gpu_surface_;

bool is_valid_ = false;

FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceVulkanImpeller);
Expand Down