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 240 of file snapshot_controller_impeller.cc.

241 {
242 if (!GetDelegate().IsAiksContextInitialized()) {
243 return;
244 }
245 auto context = GetDelegate().GetAiksContext();
246 if (!context) {
247 return;
248 }
249 impeller::RuntimeEffectContents runtime_effect;
250 runtime_effect.SetRuntimeStage(runtime_stage);
251 runtime_effect.BootstrapShader(context->GetContentContext());
252}
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 254 of file snapshot_controller_impeller.cc.

255 {
257}
#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 117 of file snapshot_controller_impeller.cc.

121 {
122 std::shared_ptr<const fml::SyncSwitch> sync_switch =
124 sync_switch->Execute(
126 .SetIfTrue([&] {
127 std::shared_ptr<impeller::AiksContext> context =
129 if (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,
135 pixel_format));
136 },
137 [callback]() { callback(nullptr); });
138 } else {
139#if FML_OS_IOS_SIMULATOR
142 /*is_fake_image=*/true));
143#else
144 callback(nullptr);
145
146#endif // FML_OS_IOS_SIMULATOR
147 }
148 })
149 .SetIfFalse([&] {
150#if FML_OS_IOS_SIMULATOR
151 if (!GetDelegate().GetAiksContext()) {
154 /*is_fake_image=*/true));
155 return;
156 }
157#endif
158 callback(DoMakeRasterSnapshot(display_list, picture_size,
159 GetDelegate(), pixel_format));
160 }));
161}
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 163 of file snapshot_controller_impeller.cc.

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

References flutter::SnapshotController::GetDelegate().

◆ MakeRenderContextCurrent()

bool flutter::SnapshotControllerImpeller::MakeRenderContextCurrent ( )
overridevirtual

Implements flutter::SnapshotController.

Definition at line 259 of file snapshot_controller_impeller.cc.

259 {
260 const std::unique_ptr<Surface>& surface = GetDelegate().GetSurface();
261 if (!surface) {
262 // Some backends (such as Metal) can operate without a surface and do not
263 // require MakeRenderContextCurrent.
264 return true;
265 }
266 return surface->MakeRenderContextCurrent()->GetResult();
267}
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 171 of file snapshot_controller_impeller.cc.

173 {
174 auto aiks_context = GetDelegate().GetAiksContext();
175 if (!aiks_context) {
176 return nullptr;
177 }
178 auto context = aiks_context->GetContext();
179 if (!context) {
180 return nullptr;
181 }
182
186 desc.size = impeller::ISize(image->width(), image->height());
187 desc.mip_count = 1;
188
189 auto texture = context->GetResourceAllocator()->CreateTexture(desc);
190 if (!texture) {
191 return nullptr;
192 }
193
194 size_t byte_size = image->width() * image->height() * 4;
195 auto buffer = context->GetResourceAllocator()->CreateBuffer(
198 .size = byte_size,
199 });
200
201 if (!buffer) {
202 return nullptr;
203 }
204
205 {
206 uint8_t* map = buffer->OnGetContents();
207 if (!map) {
208 return nullptr;
209 }
210 SkImageInfo info =
211 SkImageInfo::Make(image->width(), image->height(),
212 kRGBA_8888_SkColorType, kPremul_SkAlphaType);
213 if (!image->readPixels(info, map, image->width() * 4, 0, 0)) {
214 return nullptr;
215 }
216 buffer->Flush(impeller::Range(0, byte_size));
217 }
218
219 auto command_buffer = context->CreateCommandBuffer();
220 if (!command_buffer) {
221 return nullptr;
222 }
223 auto blit_pass = command_buffer->CreateBlitPass();
224 if (!blit_pass) {
225 return nullptr;
226 }
227
228 blit_pass->AddCopy(
230 blit_pass->EncodeCommands();
231
232 if (!context->GetCommandQueue()->Submit({command_buffer}).ok()) {
233 return nullptr;
234 }
235
238}
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: