142 {
143
145
148 }
149
151 return tonic::ToDart(
"Image dimensions for scene were invalid.");
152 }
153
155 auto image_callback = std::make_unique<tonic::DartPersistentValue>(
156 dart_state, raw_image_callback);
157 auto unref_queue = dart_state->GetSkiaUnrefQueue();
158 auto ui_task_runner = dart_state->GetTaskRunners().GetUITaskRunner();
159 auto raster_task_runner = dart_state->GetTaskRunners().GetRasterTaskRunner();
160 auto snapshot_delegate = dart_state->GetSnapshotDelegate();
161
162
163
164
165
166
167 auto ui_task =
168
169
172 auto dart_state = image_callback->dart_state().lock();
173 if (!dart_state) {
174
175 return;
176 }
178
181 return;
182 }
183
184 if (!
image->isUIThreadSafe()) {
185
189 }
190
192 dart_image->set_image(
image);
194
195
197
198
199
200 image_callback.reset();
201 });
202
203
205 raster_task_runner,
208 layer_tree = std::move(layer_tree)]() mutable {
212 if (layer_tree) {
213 FML_DCHECK(picture_bounds == layer_tree->frame_size());
214 snapshot_display_list =
216 snapshot_delegate->GetTextureRegistry(),
217 snapshot_delegate->GetGrContext());
218 }
219 snapshot_delegate->MakeRasterSnapshot(
220 snapshot_display_list, picture_bounds,
223 ui_task_runner, [ui_task,
image]() { ui_task(
image); });
224 });
225 }));
226
228}
static fml::RefPtr< CanvasImage > Create()
static sk_sp< DlImageGPU > Make(SkiaGPUObject< SkImage > image)
static UIDartState * Current()
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
sk_sp< const SkImage > image
internal::CopyableLambda< T > MakeCopyable(T lambda)
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeWH(float w, float h)