Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::SnapshotControllerImpeller Class Reference

#include <snapshot_controller_impeller.h>

Inheritance diagram for flutter::SnapshotControllerImpeller:
flutter::SnapshotController

Public Member Functions

 SnapshotControllerImpeller (const SnapshotController::Delegate &delegate)
 
void MakeRasterSnapshot (sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(const sk_sp< DlImage > &)> callback, SnapshotPixelFormat pixel_format) override
 
sk_sp< DlImageMakeRasterSnapshotSync (sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format) override
 
sk_sp< DlImageMakeTextureImage (sk_sp< SkImage > image, SnapshotPixelFormat pixel_format) override
 
sk_sp< SkImage > ConvertToRasterImage (sk_sp< SkImage > image) override
 
void CacheRuntimeStage (const std::shared_ptr< impeller::RuntimeStage > &runtime_stage) override
 
virtual bool MakeRenderContextCurrent () override
 
- Public Member Functions inherited from flutter::SnapshotController
virtual ~SnapshotController ()=default
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::SnapshotController
static std::unique_ptr< SnapshotControllerMake (const Delegate &delegate, const Settings &settings)
 
- Protected Member Functions inherited from flutter::SnapshotController
 SnapshotController (const Delegate &delegate)
 
const DelegateGetDelegate ()
 

Detailed Description

Definition at line 13 of file snapshot_controller_impeller.h.

Constructor & Destructor Documentation

◆ SnapshotControllerImpeller()

flutter::SnapshotControllerImpeller::SnapshotControllerImpeller ( const SnapshotController::Delegate delegate)
inlineexplicit

Definition at line 15 of file snapshot_controller_impeller.h.

17 : SnapshotController(delegate) {}
SnapshotController(const Delegate &delegate)

Member Function Documentation

◆ CacheRuntimeStage()

void flutter::SnapshotControllerImpeller::CacheRuntimeStage ( const std::shared_ptr< impeller::RuntimeStage > &  runtime_stage)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 239 of file snapshot_controller_impeller.cc.

240 {
241 if (!GetDelegate().IsAiksContextInitialized()) {
242 return;
243 }
244 auto context = GetDelegate().GetAiksContext();
245 if (!context) {
246 return;
247 }
248 impeller::RuntimeEffectContents runtime_effect;
249 runtime_effect.SetRuntimeStage(runtime_stage);
250 runtime_effect.BootstrapShader(context->GetContentContext());
251}
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const =0
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)

References impeller::RuntimeEffectContents::BootstrapShader(), flutter::SnapshotController::Delegate::GetAiksContext(), flutter::SnapshotController::GetDelegate(), and impeller::RuntimeEffectContents::SetRuntimeStage().

◆ ConvertToRasterImage()

sk_sp< SkImage > flutter::SnapshotControllerImpeller::ConvertToRasterImage ( sk_sp< SkImage >  image)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 253 of file snapshot_controller_impeller.cc.

254 {
256}
#define FML_UNREACHABLE()
Definition logging.h:128

References FML_UNREACHABLE.

◆ MakeRasterSnapshot()

void flutter::SnapshotControllerImpeller::MakeRasterSnapshot ( sk_sp< DisplayList display_list,
DlISize  picture_size,
std::function< void(const sk_sp< DlImage > &)>  callback,
SnapshotPixelFormat  pixel_format 
)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 116 of file snapshot_controller_impeller.cc.

120 {
121 std::shared_ptr<const fml::SyncSwitch> sync_switch =
123 sync_switch->Execute(
125 .SetIfTrue([&] {
126 std::shared_ptr<impeller::AiksContext> context =
128 if (context) {
129 context->GetContext()->StoreTaskForGPU(
130 [context, sync_switch, display_list = std::move(display_list),
131 picture_size, callback, pixel_format] {
132 callback(DoMakeRasterSnapshot(display_list, picture_size,
133 sync_switch, context,
134 pixel_format));
135 },
136 [callback]() { callback(nullptr); });
137 } else {
138#if FML_OS_IOS_SIMULATOR
141 /*is_fake_image=*/true));
142#else
143 callback(nullptr);
144
145#endif // FML_OS_IOS_SIMULATOR
146 }
147 })
148 .SetIfFalse([&] {
149#if FML_OS_IOS_SIMULATOR
150 if (!GetDelegate().GetAiksContext()) {
153 /*is_fake_image=*/true));
154 return;
155 }
156#endif
157 callback(DoMakeRasterSnapshot(display_list, picture_size,
158 GetDelegate(), pixel_format));
159 }));
160}
virtual std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() const =0
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterDesktopBinaryReply callback
Represents the 2 code paths available when calling |SyncSwitchExecute|.
Definition sync_switch.h:35

References callback, flutter::SnapshotController::Delegate::GetAiksContext(), flutter::SnapshotController::GetDelegate(), flutter::SnapshotController::Delegate::GetIsGpuDisabledSyncSwitch(), flutter::DlImage::kRaster, and impeller::DlImageImpeller::Make().

◆ MakeRasterSnapshotSync()

sk_sp< DlImage > flutter::SnapshotControllerImpeller::MakeRasterSnapshotSync ( sk_sp< DisplayList display_list,
DlISize  picture_size,
SnapshotPixelFormat  pixel_format 
)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 162 of file snapshot_controller_impeller.cc.

165 {
166 return DoMakeRasterSnapshot(display_list, picture_size, GetDelegate(),
167 pixel_format);
168}

References flutter::SnapshotController::GetDelegate().

◆ MakeRenderContextCurrent()

bool flutter::SnapshotControllerImpeller::MakeRenderContextCurrent ( )
overridevirtual

Implements flutter::SnapshotController.

Definition at line 258 of file snapshot_controller_impeller.cc.

258 {
259 const std::unique_ptr<Surface>& surface = GetDelegate().GetSurface();
260 if (!surface) {
261 // Some backends (such as Metal) can operate without a surface and do not
262 // require MakeRenderContextCurrent.
263 return true;
264 }
265 return surface->MakeRenderContextCurrent()->GetResult();
266}
virtual const std::unique_ptr< Surface > & GetSurface() const =0
VkSurfaceKHR surface
Definition main.cc:65

References flutter::SnapshotController::GetDelegate(), flutter::SnapshotController::Delegate::GetSurface(), and surface.

◆ MakeTextureImage()

sk_sp< DlImage > flutter::SnapshotControllerImpeller::MakeTextureImage ( sk_sp< SkImage >  image,
SnapshotPixelFormat  pixel_format 
)
overridevirtual

Creates a texture-backed DlImage from the provided SkImage.

This is primarily used by decodeImageFromPixelsSync to upload pixels to the GPU synchronously.

Implements flutter::SnapshotController.

Definition at line 170 of file snapshot_controller_impeller.cc.

172 {
173 auto aiks_context = GetDelegate().GetAiksContext();
174 if (!aiks_context) {
175 return nullptr;
176 }
177 auto context = aiks_context->GetContext();
178 if (!context) {
179 return nullptr;
180 }
181
185 desc.size = impeller::ISize(image->width(), image->height());
186 desc.mip_count = 1;
187
188 auto texture = context->GetResourceAllocator()->CreateTexture(desc);
189 if (!texture) {
190 return nullptr;
191 }
192
193 size_t byte_size = image->width() * image->height() * 4;
194 auto buffer = context->GetResourceAllocator()->CreateBuffer(
197 .size = byte_size,
198 });
199
200 if (!buffer) {
201 return nullptr;
202 }
203
204 {
205 uint8_t* map = buffer->OnGetContents();
206 if (!map) {
207 return nullptr;
208 }
209 SkImageInfo info =
210 SkImageInfo::Make(image->width(), image->height(),
211 kRGBA_8888_SkColorType, kPremul_SkAlphaType);
212 if (!image->readPixels(info, map, image->width() * 4, 0, 0)) {
213 return nullptr;
214 }
215 buffer->Flush(impeller::Range(0, byte_size));
216 }
217
218 auto command_buffer = context->CreateCommandBuffer();
219 if (!command_buffer) {
220 return nullptr;
221 }
222 auto blit_pass = command_buffer->CreateBlitPass();
223 if (!blit_pass) {
224 return nullptr;
225 }
226
227 blit_pass->AddCopy(
229 blit_pass->EncodeCommands();
230
231 if (!context->GetCommandQueue()->Submit({command_buffer}).ok()) {
232 return nullptr;
233 }
234
237}
FlutterVulkanImage * image
FlTexture * texture
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
Definition switch_defs.h:98
ISize64 ISize
Definition size.h:162
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...

References flutter::buffer, impeller::TextureDescriptor::format, flutter::SnapshotController::Delegate::GetAiksContext(), flutter::SnapshotController::GetDelegate(), image, impeller::kDevicePrivate, impeller::kHostVisible, impeller::kR8G8B8A8UNormInt, flutter::DlImage::kRaster, impeller::DlImageImpeller::Make(), impeller::TextureDescriptor::mip_count, impeller::TextureDescriptor::size, impeller::DeviceBufferDescriptor::storage_mode, impeller::TextureDescriptor::storage_mode, and texture.


The documentation for this class was generated from the following files: