30 {
33 }
34
35 if (status_ == Status::kComplete) {
36 if (!cached_image_->image()) {
38 }
42 }
43
44
46
47 pending_callbacks_.emplace_back(dart_state, callback_handle);
48
49 if (status_ == Status::kInProgress) {
50
51
53 }
54
55 auto decoder = dart_state->GetImageDecoder();
56
57 if (!decoder) {
59 "Failed to access the internal image decoder "
60 "registry on this isolate. Please file a bug on "
61 "https://github.com/flutter/flutter/issues.");
62 }
63
64
65
66
67
70
71 decoder->Decode(
72 descriptor_, target_width_, target_height_,
73 [raw_codec_ref](
auto image,
auto decode_error) {
74 std::unique_ptr<fml::RefPtr<SingleFrameCodec>> codec_ref(raw_codec_ref);
76
77 auto state = codec->pending_callbacks_.front().dart_state().lock();
78
80
81
82
83 return;
84 }
85
87
89 auto canvas_image = fml::MakeRefCounted<CanvasImage>();
90 canvas_image->set_image(std::move(
image));
91
92 codec->cached_image_ = std::move(canvas_image);
93 }
94
95
96
97 codec->status_ = Status::kComplete;
98
99
101 codec->pending_callbacks_) {
103 {tonic::ToDart(codec->cached_image_),
104 tonic::ToDart(0), tonic::ToDart(decode_error)});
105 }
106 codec->pending_callbacks_.clear();
107 });
108
109
110
111 descriptor_ = nullptr;
112
113 status_ = Status::kInProgress;
114
116}
static UIDartState * Current()
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
sk_sp< const SkImage > image
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)