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 MakeSkiaSnapshot (sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(const sk_sp< SkImage > &)> callback, SnapshotPixelFormat pixel_format) override
 
sk_sp< SkImage > MakeSkiaSnapshotSync (sk_sp< DisplayList > display_list, DlISize size, SnapshotPixelFormat pixel_format) override
 
void MakeImpellerSnapshot (sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(const std::shared_ptr< impeller::Texture > &)> callback, SnapshotPixelFormat pixel_format) override
 
std::shared_ptr< impeller::TextureMakeImpellerSnapshotSync (sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format) override
 
sk_sp< SkImage > MakeSkiaTextureImage (sk_sp< SkImage > image, SnapshotPixelFormat pixel_format) override
 
std::shared_ptr< impeller::TextureMakeImpellerTextureImage (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 245 of file snapshot_controller_impeller.cc.

246 {
247 if (!GetDelegate().IsAiksContextInitialized()) {
248 return;
249 }
250 auto context = GetDelegate().GetAiksContext();
251 if (!context) {
252 return;
253 }
254 impeller::RuntimeEffectContents runtime_effect(nullptr);
255 runtime_effect.SetRuntimeStage(runtime_stage);
256 runtime_effect.BootstrapShader(context->GetContentContext());
257}
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const =0

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

260 {
262}
#define FML_UNREACHABLE()
Definition logging.h:128

References FML_UNREACHABLE.

◆ MakeImpellerSnapshot()

void flutter::SnapshotControllerImpeller::MakeImpellerSnapshot ( sk_sp< DisplayList display_list,
DlISize  picture_size,
std::function< void(const std::shared_ptr< impeller::Texture > &)>  callback,
SnapshotPixelFormat  pixel_format 
)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 130 of file snapshot_controller_impeller.cc.

134 {
135 std::shared_ptr<const fml::SyncSwitch> sync_switch =
137 sync_switch->Execute(
139 .SetIfTrue([&] {
140 std::shared_ptr<impeller::AiksContext> context =
142 if (context) {
143 context->GetContext()->StoreTaskForGPU(
144 [context, sync_switch, display_list = std::move(display_list),
145 picture_size, callback, pixel_format] {
146 callback(DoMakeRasterSnapshot(display_list, picture_size,
147 sync_switch, context,
148 pixel_format));
149 },
150 [callback]() { callback(nullptr); });
151 } else {
152 callback(nullptr);
153 }
154 })
155 .SetIfFalse([&] {
156 callback(DoMakeRasterSnapshot(display_list, picture_size,
157 GetDelegate(), pixel_format));
158 }));
159}
virtual std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() const =0
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(), and flutter::SnapshotController::Delegate::GetIsGpuDisabledSyncSwitch().

◆ MakeImpellerSnapshotSync()

std::shared_ptr< impeller::Texture > flutter::SnapshotControllerImpeller::MakeImpellerSnapshotSync ( 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().

◆ MakeImpellerTextureImage()

std::shared_ptr< impeller::Texture > flutter::SnapshotControllerImpeller::MakeImpellerTextureImage ( sk_sp< SkImage >  image,
SnapshotPixelFormat  pixel_format 
)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 177 of file snapshot_controller_impeller.cc.

179 {
180 auto aiks_context = GetDelegate().GetAiksContext();
181 if (!aiks_context) {
182 return nullptr;
183 }
184 auto context = aiks_context->GetContext();
185 if (!context) {
186 return nullptr;
187 }
188
192 desc.size = impeller::ISize(image->width(), image->height());
193 desc.mip_count = 1;
194
195 auto texture = context->GetResourceAllocator()->CreateTexture(desc);
196 if (!texture) {
197 return nullptr;
198 }
199
200 size_t byte_size = image->width() * image->height() * 4;
201 auto buffer = context->GetResourceAllocator()->CreateBuffer(
204 .size = byte_size,
205 });
206
207 if (!buffer) {
208 return nullptr;
209 }
210
211 {
212 uint8_t* map = buffer->OnGetContents();
213 if (!map) {
214 return nullptr;
215 }
216 SkImageInfo info =
217 SkImageInfo::Make(image->width(), image->height(),
218 kRGBA_8888_SkColorType, kPremul_SkAlphaType);
219 if (!image->readPixels(info, map, image->width() * 4, 0, 0)) {
220 return nullptr;
221 }
222 buffer->Flush(impeller::Range(0, byte_size));
223 }
224
225 auto command_buffer = context->CreateCommandBuffer();
226 if (!command_buffer) {
227 return nullptr;
228 }
229 auto blit_pass = command_buffer->CreateBlitPass();
230 if (!blit_pass) {
231 return nullptr;
232 }
233
234 blit_pass->AddCopy(
236 blit_pass->EncodeCommands();
237
238 if (!context->GetCommandQueue()->Submit({command_buffer}).ok()) {
239 return nullptr;
240 }
241
242 return texture;
243}
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, impeller::TextureDescriptor::mip_count, impeller::TextureDescriptor::size, impeller::DeviceBufferDescriptor::storage_mode, impeller::TextureDescriptor::storage_mode, and texture.

◆ MakeRenderContextCurrent()

bool flutter::SnapshotControllerImpeller::MakeRenderContextCurrent ( )
overridevirtual

Implements flutter::SnapshotController.

Definition at line 264 of file snapshot_controller_impeller.cc.

264 {
265 const std::unique_ptr<Surface>& surface = GetDelegate().GetSurface();
266 if (!surface) {
267 // Some backends (such as Metal) can operate without a surface and do not
268 // require MakeRenderContextCurrent.
269 return true;
270 }
271 return surface->MakeRenderContextCurrent()->GetResult();
272}
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.

◆ MakeSkiaSnapshot()

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

Implements flutter::SnapshotController.

Definition at line 115 of file snapshot_controller_impeller.cc.

119 {
121}

References FML_UNREACHABLE.

◆ MakeSkiaSnapshotSync()

sk_sp< SkImage > flutter::SnapshotControllerImpeller::MakeSkiaSnapshotSync ( sk_sp< DisplayList display_list,
DlISize  size,
SnapshotPixelFormat  pixel_format 
)
overridevirtual

Implements flutter::SnapshotController.

Definition at line 123 of file snapshot_controller_impeller.cc.

126 {
128}

References FML_UNREACHABLE.

◆ MakeSkiaTextureImage()

sk_sp< SkImage > flutter::SnapshotControllerImpeller::MakeSkiaTextureImage ( 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 return nullptr;
174}

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