98 {
100 public:
103 : fSingleFrameAsset(
std::move(single_asset))
104 , fMultiFrameAsset (
std::move( multi_asset)) {}
105
106 private:
109 const char id[]) const override {
110 return strcmp(id, "single_frame")
111 ? fMultiFrameAsset
112 : fSingleFrameAsset;
113 }
114
116 fMultiFrameAsset;
117 };
118
121 bool deferred_image_loading) {
122 static constexpr char json[] = R"({
123 "v": "5.2.1",
124 "w": 100,
125 "h": 100,
126 "fr": 10,
127 "ip": 0,
128 "op": 100,
129 "assets": [
130 {
131 "id": "single_frame",
132 "p" : "single_frame.png",
133 "u" : "images/",
134 "w" : 500,
135 "h" : 500
136 },
137 {
138 "id": "multi_frame",
139 "p" : "multi_frame.png",
140 "u" : "images/",
141 "w" : 500,
142 "h" : 500
143 }
144 ],
145 "layers": [
146 {
147 "ty": 2,
148 "refId": "single_frame",
149 "ind": 0,
150 "ip": 0,
151 "op": 100,
152 "ks": {}
153 },
154 {
155 "ty": 2,
156 "refId": "multi_frame",
157 "ind": 1,
158 "ip": 0,
159 "op": 100,
160 "ks": {}
161 }
162 ]
163 })";
164
166
167 const auto flags = deferred_image_loading
169 : 0;
170 auto animation =
172 .setResourceProvider(sk_make_sp<TestResourceProvider>(std::move(single_asset),
173 std::move( multi_asset)))
175
177
178 return animation;
179 };
180
182 public:
183 explicit TestAsset(bool multi_frame) : fMultiFrame(multi_frame) {}
184
185 const std::vector<float>& requestedFrames() const { return fRequestedFrames; }
186
187 private:
189
191 fRequestedFrames.push_back(t);
192
194 }
195
196 const bool fMultiFrame;
197
198 std::vector<float> fRequestedFrames;
199 };
200
201 {
202 auto single_asset = sk_make_sp<TestAsset>(false),
203 multi_asset = sk_make_sp<TestAsset>(true);
204
205
206
207 auto animation = make_animation(single_asset, multi_asset, false);
208
212
213 animation->seekFrameTime(1);
217
218 animation->seekFrameTime(2);
222 }
223
224 {
225 auto single_asset = sk_make_sp<TestAsset>(false),
226 multi_asset = sk_make_sp<TestAsset>(true);
227
228
229 auto animation = make_animation(single_asset, multi_asset, true);
230
233
234 animation->seekFrameTime(1);
239
240 animation->seekFrameTime(2);
244 }
245}
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
sk_sp< SkImage > makeImageSnapshot()
virtual sk_sp< SkImage > getFrame(float t)
virtual bool isMultiFrame()=0
virtual sk_sp< ImageAsset > loadImageAsset(const char[], const char[], const char[]) const
FlutterSemanticsFlag flags
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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
static SkImageInfo MakeN32Premul(int width, int height)