22sk_sp<DlImage> DoMakeRasterSnapshot(
23 const sk_sp<DisplayList>& display_list,
25 const std::shared_ptr<impeller::AiksContext>& context,
32 auto max_size = context->GetContext()
33 ->GetResourceAllocator()
34 ->GetMaxTextureSizeSupported();
35 double scale_factor_x =
36 static_cast<double>(max_size.width) /
static_cast<double>(
size.width);
37 double scale_factor_y =
38 static_cast<double>(max_size.height) /
static_cast<double>(
size.height);
39 double scale_factor = std::min({1.0, scale_factor_x, scale_factor_y});
46 if (scale_factor < 1.0) {
47 render_target_size.width *= scale_factor;
48 render_target_size.height *= scale_factor;
51 std::optional<impeller::PixelFormat> impeller_pixel_format;
52 switch (pixel_format) {
54 impeller_pixel_format = std::nullopt;
68 impeller_pixel_format),
72sk_sp<DlImage> DoMakeRasterSnapshot(
73 const sk_sp<DisplayList>& display_list,
75 const SnapshotController::Delegate& delegate,
80 std::unique_ptr<Surface> pbuffer_surface;
81 std::unique_ptr<GLContextResult> context_result;
82 if (delegate.GetSurface()) {
83 context_result = delegate.GetSurface()->MakeRenderContextCurrent();
84 }
else if (delegate.GetSnapshotSurfaceProducer()) {
86 delegate.GetSnapshotSurfaceProducer()->CreateSnapshotSurface();
87 if (pbuffer_surface) {
88 context_result = pbuffer_surface->MakeRenderContextCurrent();
92 return DoMakeRasterSnapshot(display_list,
size, delegate.GetAiksContext(),
96sk_sp<DlImage> DoMakeRasterSnapshot(
97 sk_sp<DisplayList> display_list,
99 const std::shared_ptr<const fml::SyncSwitch>& sync_switch,
100 const std::shared_ptr<impeller::AiksContext>& context,
102 sk_sp<DlImage> result;
108 result = DoMakeRasterSnapshot(
109 display_list, picture_size, context,
118 sk_sp<DisplayList> display_list,
120 std::function<
void(
const sk_sp<DlImage>&)>
callback,
122 std::shared_ptr<const fml::SyncSwitch> sync_switch =
124 sync_switch->Execute(
127 std::shared_ptr<impeller::AiksContext> context =
130 context->GetContext()->StoreTaskForGPU(
131 [context, sync_switch, display_list = std::move(display_list),
132 picture_size,
callback, pixel_format] {
133 callback(DoMakeRasterSnapshot(display_list, picture_size,
134 sync_switch, context,
139#if FML_OS_IOS_SIMULATOR
150#if FML_OS_IOS_SIMULATOR
158 callback(DoMakeRasterSnapshot(display_list, picture_size,
164 sk_sp<DisplayList> display_list,
167 return DoMakeRasterSnapshot(display_list, picture_size,
GetDelegate(),
172 sk_sp<SkImage>
image,
178 auto context = aiks_context->GetContext();
189 auto texture = context->GetResourceAllocator()->CreateTexture(desc);
194 size_t byte_size =
image->width() *
image->height() * 4;
195 auto buffer = context->GetResourceAllocator()->CreateBuffer(
206 uint8_t* map =
buffer->OnGetContents();
211 SkImageInfo::Make(
image->width(),
image->height(),
212 kRGBA_8888_SkColorType, kPremul_SkAlphaType);
213 if (!
image->readPixels(info, map,
image->width() * 4, 0, 0)) {
219 auto command_buffer = context->CreateCommandBuffer();
220 if (!command_buffer) {
223 auto blit_pass = command_buffer->CreateBlitPass();
230 blit_pass->EncodeCommands();
232 if (!context->GetCommandQueue()->Submit({command_buffer}).ok()) {
241 const std::shared_ptr<impeller::RuntimeStage>& runtime_stage) {
255 sk_sp<SkImage>
image) {
266 return surface->MakeRenderContextCurrent()->GetResult();
virtual const std::unique_ptr< Surface > & GetSurface() const =0
virtual std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() const =0
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const =0
const Delegate & GetDelegate()
virtual bool MakeRenderContextCurrent() override
sk_sp< SkImage > ConvertToRasterImage(sk_sp< SkImage > image) override
sk_sp< DlImage > MakeRasterSnapshotSync(sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format) override
void CacheRuntimeStage(const std::shared_ptr< impeller::RuntimeStage > &runtime_stage) override
sk_sp< DlImage > MakeTextureImage(sk_sp< SkImage > image, SnapshotPixelFormat pixel_format) override
void MakeRasterSnapshot(sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(const sk_sp< DlImage > &)> callback, SnapshotPixelFormat pixel_format) override
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
bool BootstrapShader(const ContentContext &renderer) const
Load the runtime effect and ensure a default PSO is initialized.
void SetRuntimeStage(std::shared_ptr< RuntimeStage > runtime_stage)
FlutterVulkanImage * image
FlutterDesktopBinaryReply callback
#define FML_UNREACHABLE()
impeller::ISize32 DlISize
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 of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
std::shared_ptr< Texture > DisplayListToTexture(const sk_sp< flutter::DisplayList > &display_list, ISize size, AiksContext &context, bool reset_host_buffer, bool generate_mips, std::optional< PixelFormat > target_pixel_format)
Render the provided display list to a texture with the given size.
Represents the 2 code paths available when calling |SyncSwitchExecute|.
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
#define TRACE_EVENT0(category_group, name)