@shopify/react-native-skia 2.2.11 → 2.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/cpp/api/JsiNativeBuffer.h +2 -0
  2. package/cpp/api/JsiSkAnimatedImage.h +6 -2
  3. package/cpp/api/JsiSkAnimatedImageFactory.h +6 -3
  4. package/cpp/api/JsiSkApi.h +2 -0
  5. package/cpp/api/JsiSkCanvas.h +2 -0
  6. package/cpp/api/JsiSkColorFilter.h +2 -0
  7. package/cpp/api/JsiSkColorFilterFactory.h +31 -23
  8. package/cpp/api/JsiSkContourMeasure.h +8 -4
  9. package/cpp/api/JsiSkContourMeasureIter.h +10 -4
  10. package/cpp/api/JsiSkData.h +5 -0
  11. package/cpp/api/JsiSkDataFactory.h +14 -7
  12. package/cpp/api/JsiSkFont.h +17 -10
  13. package/cpp/api/JsiSkFontMgr.h +6 -2
  14. package/cpp/api/JsiSkFontMgrFactory.h +5 -2
  15. package/cpp/api/JsiSkFontStyle.h +6 -3
  16. package/cpp/api/JsiSkHostObjects.h +21 -44
  17. package/cpp/api/JsiSkImage.h +17 -8
  18. package/cpp/api/JsiSkImageFactory.h +26 -13
  19. package/cpp/api/JsiSkImageFilter.h +2 -0
  20. package/cpp/api/JsiSkImageFilterFactory.h +160 -143
  21. package/cpp/api/JsiSkImageInfo.h +6 -3
  22. package/cpp/api/JsiSkMaskFilter.h +2 -0
  23. package/cpp/api/JsiSkMaskFilterFactory.h +7 -5
  24. package/cpp/api/JsiSkMatrix.h +6 -2
  25. package/cpp/api/JsiSkPaint.h +9 -4
  26. package/cpp/api/JsiSkParagraph.h +2 -0
  27. package/cpp/api/JsiSkParagraphBuilder.h +6 -3
  28. package/cpp/api/JsiSkParagraphBuilderFactory.h +6 -3
  29. package/cpp/api/JsiSkPath.h +33 -15
  30. package/cpp/api/JsiSkPathEffect.h +2 -0
  31. package/cpp/api/JsiSkPathEffectFactory.h +37 -32
  32. package/cpp/api/JsiSkPathFactory.h +22 -10
  33. package/cpp/api/JsiSkPicture.h +13 -2
  34. package/cpp/api/JsiSkPictureFactory.h +6 -2
  35. package/cpp/api/JsiSkPictureRecorder.h +14 -6
  36. package/cpp/api/JsiSkPoint.h +9 -5
  37. package/cpp/api/JsiSkRRect.h +13 -8
  38. package/cpp/api/JsiSkRSXform.h +14 -8
  39. package/cpp/api/JsiSkRect.h +13 -8
  40. package/cpp/api/JsiSkRuntimeEffect.h +10 -6
  41. package/cpp/api/JsiSkRuntimeEffectFactory.h +6 -3
  42. package/cpp/api/JsiSkRuntimeShaderBuilder.h +12 -6
  43. package/cpp/api/JsiSkSVG.h +24 -0
  44. package/cpp/api/JsiSkSVGFactory.h +8 -4
  45. package/cpp/api/JsiSkShader.h +2 -0
  46. package/cpp/api/JsiSkShaderFactory.h +34 -24
  47. package/cpp/api/JsiSkSkottie.h +29 -0
  48. package/cpp/api/JsiSkSurface.h +21 -5
  49. package/cpp/api/JsiSkSurfaceFactory.h +10 -6
  50. package/cpp/api/JsiSkTextBlob.h +12 -0
  51. package/cpp/api/JsiSkTextBlobFactory.h +18 -12
  52. package/cpp/api/JsiSkTypeface.h +19 -3
  53. package/cpp/api/JsiSkTypefaceFactory.h +6 -2
  54. package/cpp/api/JsiSkTypefaceFontProvider.h +10 -5
  55. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +6 -3
  56. package/cpp/api/JsiSkVertices.h +16 -5
  57. package/cpp/api/JsiSkiaContext.h +10 -6
  58. package/cpp/api/JsiSkottieFactory.h +6 -3
  59. package/cpp/api/JsiVideo.h +10 -5
  60. package/cpp/api/recorder/JsiRecorder.h +9 -4
  61. package/cpp/rnskia/RNSkJsiViewApi.h +5 -2
  62. package/package.json +1 -1
@@ -25,6 +25,8 @@ public:
25
25
  : JsiSkWrappingSkPtrHostObject<SkImageFilter>(std::move(context),
26
26
  std::move(imageFilter)) {}
27
27
 
28
+ size_t getMemoryPressure() const override { return 4096; }
29
+
28
30
  EXPORT_JSI_API_TYPENAME(JsiSkImageFilter, ImageFilter)
29
31
  };
30
32
 
@@ -42,11 +42,11 @@ public:
42
42
  if (hasOptionalArgument(arguments, count, 4)) {
43
43
  cropRect = *JsiSkRect::fromValue(runtime, arguments[4]);
44
44
  }
45
- return jsi::Object::createFromHostObject(
46
- runtime, std::make_shared<JsiSkImageFilter>(
47
- getContext(),
48
- SkImageFilters::Blur(sigmaX, sigmaY, (SkTileMode)tileMode,
49
- imageFilter, cropRect)));
45
+ auto filter = std::make_shared<JsiSkImageFilter>(
46
+ getContext(), SkImageFilters::Blur(sigmaX, sigmaY, (SkTileMode)tileMode,
47
+ imageFilter, cropRect));
48
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
49
+ getContext());
50
50
  }
51
51
 
52
52
  JSI_HOST_FUNCTION(MakeColorFilter) {
@@ -59,11 +59,11 @@ public:
59
59
  if (hasOptionalArgument(arguments, count, 2)) {
60
60
  cropRect = *JsiSkRect::fromValue(runtime, arguments[2]);
61
61
  }
62
- return jsi::Object::createFromHostObject(
63
- runtime,
64
- std::make_shared<JsiSkImageFilter>(
65
- getContext(), SkImageFilters::ColorFilter(
66
- std::move(cf), std::move(input), cropRect)));
62
+ auto filter = std::make_shared<JsiSkImageFilter>(
63
+ getContext(),
64
+ SkImageFilters::ColorFilter(std::move(cf), std::move(input), cropRect));
65
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
66
+ getContext());
67
67
  }
68
68
 
69
69
  JSI_HOST_FUNCTION(MakeOffset) {
@@ -77,10 +77,10 @@ public:
77
77
  if (hasOptionalArgument(arguments, count, 3)) {
78
78
  cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
79
79
  }
80
- return jsi::Object::createFromHostObject(
81
- runtime, std::make_shared<JsiSkImageFilter>(
82
- getContext(),
83
- SkImageFilters::Offset(x, y, std::move(input), cropRect)));
80
+ auto filter = std::make_shared<JsiSkImageFilter>(
81
+ getContext(), SkImageFilters::Offset(x, y, std::move(input), cropRect));
82
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
83
+ getContext());
84
84
  }
85
85
 
86
86
  JSI_HOST_FUNCTION(MakeDisplacementMap) {
@@ -98,12 +98,12 @@ public:
98
98
  if (hasOptionalArgument(arguments, count, 5)) {
99
99
  cropRect = *JsiSkRect::fromValue(runtime, arguments[5]);
100
100
  }
101
- return jsi::Object::createFromHostObject(
102
- runtime,
103
- std::make_shared<JsiSkImageFilter>(
104
- getContext(), SkImageFilters::DisplacementMap(
105
- fXChannelSelector, fYChannelSelector, scale,
106
- std::move(in2), std::move(input), cropRect)));
101
+ auto filter = std::make_shared<JsiSkImageFilter>(
102
+ getContext(), SkImageFilters::DisplacementMap(
103
+ fXChannelSelector, fYChannelSelector, scale,
104
+ std::move(in2), std::move(input), cropRect));
105
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
106
+ getContext());
107
107
  }
108
108
 
109
109
  JSI_HOST_FUNCTION(MakeShader) {
@@ -117,10 +117,11 @@ public:
117
117
  if (hasOptionalArgument(arguments, count, 2)) {
118
118
  cropRect = *JsiSkRect::fromValue(runtime, arguments[2]);
119
119
  }
120
- return jsi::Object::createFromHostObject(
121
- runtime, std::make_shared<JsiSkImageFilter>(
122
- getContext(), SkImageFilters::Shader(std::move(shader),
123
- dither, cropRect)));
120
+ auto filter = std::make_shared<JsiSkImageFilter>(
121
+ getContext(),
122
+ SkImageFilters::Shader(std::move(shader), dither, cropRect));
123
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
124
+ getContext());
124
125
  }
125
126
 
126
127
  JSI_HOST_FUNCTION(MakeCompose) {
@@ -132,10 +133,11 @@ public:
132
133
  if (hasOptionalArgument(arguments, count, 1)) {
133
134
  inner = JsiSkImageFilter::fromValue(runtime, arguments[1]);
134
135
  }
135
- return jsi::Object::createFromHostObject(
136
- runtime, std::make_shared<JsiSkImageFilter>(
137
- getContext(), SkImageFilters::Compose(std::move(outer),
138
- std::move(inner))));
136
+ auto filter = std::make_shared<JsiSkImageFilter>(
137
+ getContext(),
138
+ SkImageFilters::Compose(std::move(outer), std::move(inner)));
139
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
140
+ getContext());
139
141
  }
140
142
 
141
143
  JSI_HOST_FUNCTION(MakeBlend) {
@@ -153,11 +155,12 @@ public:
153
155
  cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
154
156
  }
155
157
 
156
- return jsi::Object::createFromHostObject(
157
- runtime, std::make_shared<JsiSkImageFilter>(
158
- getContext(), SkImageFilters::Blend(
159
- std::move(mode), std::move(background),
160
- std::move(foreground), cropRect)));
158
+ auto filter = std::make_shared<JsiSkImageFilter>(
159
+ getContext(),
160
+ SkImageFilters::Blend(std::move(mode), std::move(background),
161
+ std::move(foreground), cropRect));
162
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
163
+ getContext());
161
164
  }
162
165
 
163
166
  JSI_HOST_FUNCTION(MakeDropShadow) {
@@ -174,11 +177,11 @@ public:
174
177
  if (hasOptionalArgument(arguments, count, 6)) {
175
178
  cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
176
179
  }
177
- return jsi::Object::createFromHostObject(
178
- runtime, std::make_shared<JsiSkImageFilter>(
179
- getContext(),
180
- SkImageFilters::DropShadow(dx, dy, sigmaX, sigmaY, color,
181
- std::move(input), cropRect)));
180
+ auto filter = std::make_shared<JsiSkImageFilter>(
181
+ getContext(), SkImageFilters::DropShadow(dx, dy, sigmaX, sigmaY, color,
182
+ std::move(input), cropRect));
183
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
184
+ getContext());
182
185
  }
183
186
 
184
187
  JSI_HOST_FUNCTION(MakeDropShadowOnly) {
@@ -195,11 +198,12 @@ public:
195
198
  if (hasOptionalArgument(arguments, count, 6)) {
196
199
  cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
197
200
  }
198
- return jsi::Object::createFromHostObject(
199
- runtime, std::make_shared<JsiSkImageFilter>(
200
- getContext(), SkImageFilters::DropShadowOnly(
201
- dx, dy, sigmaX, sigmaY, color,
202
- std::move(input), cropRect)));
201
+ auto filter = std::make_shared<JsiSkImageFilter>(
202
+ getContext(),
203
+ SkImageFilters::DropShadowOnly(dx, dy, sigmaX, sigmaY, color,
204
+ std::move(input), cropRect));
205
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
206
+ getContext());
203
207
  }
204
208
 
205
209
  JSI_HOST_FUNCTION(MakeErode) {
@@ -213,10 +217,11 @@ public:
213
217
  if (hasOptionalArgument(arguments, count, 3)) {
214
218
  cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
215
219
  }
216
- return jsi::Object::createFromHostObject(
217
- runtime, std::make_shared<JsiSkImageFilter>(
218
- getContext(), SkImageFilters::Erode(
219
- rx, ry, std::move(input), cropRect)));
220
+ auto filter = std::make_shared<JsiSkImageFilter>(
221
+ getContext(),
222
+ SkImageFilters::Erode(rx, ry, std::move(input), cropRect));
223
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
224
+ getContext());
220
225
  }
221
226
 
222
227
  JSI_HOST_FUNCTION(MakeDilate) {
@@ -230,10 +235,11 @@ public:
230
235
  if (hasOptionalArgument(arguments, count, 3)) {
231
236
  cropRect = *JsiSkRect::fromValue(runtime, arguments[3]);
232
237
  }
233
- return jsi::Object::createFromHostObject(
234
- runtime, std::make_shared<JsiSkImageFilter>(
235
- getContext(), SkImageFilters::Dilate(
236
- rx, ry, std::move(input), cropRect)));
238
+ auto filter = std::make_shared<JsiSkImageFilter>(
239
+ getContext(),
240
+ SkImageFilters::Dilate(rx, ry, std::move(input), cropRect));
241
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
242
+ getContext());
237
243
  }
238
244
 
239
245
  JSI_HOST_FUNCTION(MakeRuntimeShader) {
@@ -248,10 +254,11 @@ public:
248
254
  if (hasOptionalArgument(arguments, count, 2)) {
249
255
  input = JsiSkImageFilter::fromValue(runtime, arguments[2]);
250
256
  }
251
- return jsi::Object::createFromHostObject(
252
- runtime, std::make_shared<JsiSkImageFilter>(
253
- getContext(), SkImageFilters::RuntimeShader(
254
- *rtb, childName, std::move(input))));
257
+ auto filter = std::make_shared<JsiSkImageFilter>(
258
+ getContext(),
259
+ SkImageFilters::RuntimeShader(*rtb, childName, std::move(input)));
260
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
261
+ getContext());
255
262
  }
256
263
 
257
264
  JSI_HOST_FUNCTION(MakeArithmetic) {
@@ -272,12 +279,12 @@ public:
272
279
  if (hasOptionalArgument(arguments, count, 7)) {
273
280
  cropRect = *JsiSkRect::fromValue(runtime, arguments[7]);
274
281
  }
275
- return jsi::Object::createFromHostObject(
276
- runtime, std::make_shared<JsiSkImageFilter>(
277
- getContext(),
278
- SkImageFilters::Arithmetic(
279
- k1, k2, k3, k4, enforcePMColor, std::move(background),
280
- std::move(foreground), cropRect)));
282
+ auto filter = std::make_shared<JsiSkImageFilter>(
283
+ getContext(), SkImageFilters::Arithmetic(
284
+ k1, k2, k3, k4, enforcePMColor, std::move(background),
285
+ std::move(foreground), cropRect));
286
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
287
+ getContext());
281
288
  }
282
289
 
283
290
  JSI_HOST_FUNCTION(MakeCrop) {
@@ -290,17 +297,18 @@ public:
290
297
  if (hasOptionalArgument(arguments, count, 2)) {
291
298
  imageFilter = JsiSkImageFilter::fromValue(runtime, arguments[2]);
292
299
  }
293
- return jsi::Object::createFromHostObject(
294
- runtime,
295
- std::make_shared<JsiSkImageFilter>(
296
- getContext(),
297
- SkImageFilters::Crop(rect, tileMode, std::move(imageFilter))));
300
+ auto filter = std::make_shared<JsiSkImageFilter>(
301
+ getContext(),
302
+ SkImageFilters::Crop(rect, tileMode, std::move(imageFilter)));
303
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
304
+ getContext());
298
305
  }
299
306
 
300
307
  JSI_HOST_FUNCTION(MakeEmpty) {
301
- return jsi::Object::createFromHostObject(
302
- runtime, std::make_shared<JsiSkImageFilter>(getContext(),
303
- SkImageFilters::Empty()));
308
+ auto filter = std::make_shared<JsiSkImageFilter>(getContext(),
309
+ SkImageFilters::Empty());
310
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
311
+ getContext());
304
312
  }
305
313
 
306
314
  inline SkPoint3 SkPoint3FromValue(jsi::Runtime &runtime,
@@ -325,11 +333,12 @@ public:
325
333
  if (hasOptionalArgument(arguments, count, 5)) {
326
334
  cropRect = *JsiSkRect::fromValue(runtime, arguments[5]);
327
335
  }
328
- return jsi::Object::createFromHostObject(
329
- runtime, std::make_shared<JsiSkImageFilter>(
330
- getContext(), SkImageFilters::DistantLitDiffuse(
331
- direction, lightColor, surfaceScale, kd,
332
- std::move(input), cropRect)));
336
+ auto filter = std::make_shared<JsiSkImageFilter>(
337
+ getContext(),
338
+ SkImageFilters::DistantLitDiffuse(direction, lightColor, surfaceScale,
339
+ kd, std::move(input), cropRect));
340
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
341
+ getContext());
333
342
  }
334
343
 
335
344
  JSI_HOST_FUNCTION(MakePointLitDiffuse) {
@@ -345,11 +354,12 @@ public:
345
354
  if (hasOptionalArgument(arguments, count, 5)) {
346
355
  cropRect = *JsiSkRect::fromValue(runtime, arguments[5]);
347
356
  }
348
- return jsi::Object::createFromHostObject(
349
- runtime, std::make_shared<JsiSkImageFilter>(
350
- getContext(), SkImageFilters::PointLitDiffuse(
351
- location, lightColor, surfaceScale, kd,
352
- std::move(input), cropRect)));
357
+ auto filter = std::make_shared<JsiSkImageFilter>(
358
+ getContext(),
359
+ SkImageFilters::PointLitDiffuse(location, lightColor, surfaceScale, kd,
360
+ std::move(input), cropRect));
361
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
362
+ getContext());
353
363
  }
354
364
 
355
365
  JSI_HOST_FUNCTION(MakeSpotLitDiffuse) {
@@ -368,12 +378,13 @@ public:
368
378
  if (hasOptionalArgument(arguments, count, 8)) {
369
379
  cropRect = *JsiSkRect::fromValue(runtime, arguments[8]);
370
380
  }
371
- return jsi::Object::createFromHostObject(
372
- runtime, std::make_shared<JsiSkImageFilter>(
373
- getContext(), SkImageFilters::SpotLitDiffuse(
374
- location, target, falloffExponent,
381
+ auto filter = std::make_shared<JsiSkImageFilter>(
382
+ getContext(),
383
+ SkImageFilters::SpotLitDiffuse(location, target, falloffExponent,
375
384
  cutoffAngle, lightColor, surfaceScale,
376
- kd, std::move(input), cropRect)));
385
+ kd, std::move(input), cropRect));
386
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
387
+ getContext());
377
388
  }
378
389
 
379
390
  JSI_HOST_FUNCTION(MakeDistantLitSpecular) {
@@ -390,11 +401,12 @@ public:
390
401
  if (hasOptionalArgument(arguments, count, 6)) {
391
402
  cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
392
403
  }
393
- return jsi::Object::createFromHostObject(
394
- runtime, std::make_shared<JsiSkImageFilter>(
395
- getContext(), SkImageFilters::DistantLitSpecular(
396
- direction, lightColor, surfaceScale, ks,
397
- shininess, std::move(input), cropRect)));
404
+ auto filter = std::make_shared<JsiSkImageFilter>(
405
+ getContext(), SkImageFilters::DistantLitSpecular(
406
+ direction, lightColor, surfaceScale, ks, shininess,
407
+ std::move(input), cropRect));
408
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
409
+ getContext());
398
410
  }
399
411
 
400
412
  JSI_HOST_FUNCTION(MakePointLitSpecular) {
@@ -411,11 +423,12 @@ public:
411
423
  if (hasOptionalArgument(arguments, count, 6)) {
412
424
  cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
413
425
  }
414
- return jsi::Object::createFromHostObject(
415
- runtime, std::make_shared<JsiSkImageFilter>(
416
- getContext(), SkImageFilters::PointLitSpecular(
417
- location, lightColor, surfaceScale, ks,
418
- shininess, std::move(input), cropRect)));
426
+ auto filter = std::make_shared<JsiSkImageFilter>(
427
+ getContext(), SkImageFilters::PointLitSpecular(
428
+ location, lightColor, surfaceScale, ks, shininess,
429
+ std::move(input), cropRect));
430
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
431
+ getContext());
419
432
  }
420
433
 
421
434
  JSI_HOST_FUNCTION(MakeSpotLitSpecular) {
@@ -435,13 +448,13 @@ public:
435
448
  if (hasOptionalArgument(arguments, count, 9)) {
436
449
  cropRect = *JsiSkRect::fromValue(runtime, arguments[9]);
437
450
  }
438
- return jsi::Object::createFromHostObject(
439
- runtime,
440
- std::make_shared<JsiSkImageFilter>(
441
- getContext(),
442
- SkImageFilters::SpotLitSpecular(
443
- location, target, falloffExponent, cutoffAngle, lightColor,
444
- surfaceScale, ks, shininess, std::move(input), cropRect)));
451
+ auto filter = std::make_shared<JsiSkImageFilter>(
452
+ getContext(),
453
+ SkImageFilters::SpotLitSpecular(
454
+ location, target, falloffExponent, cutoffAngle, lightColor,
455
+ surfaceScale, ks, shininess, std::move(input), cropRect));
456
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
457
+ getContext());
445
458
  }
446
459
 
447
460
  JSI_HOST_FUNCTION(MakeImage) {
@@ -466,11 +479,12 @@ public:
466
479
  if (hasOptionalArgument(arguments, count, 4)) {
467
480
  mipmap = (SkMipmapMode)arguments[4].asNumber();
468
481
  }
469
- return jsi::Object::createFromHostObject(
470
- runtime, std::make_shared<JsiSkImageFilter>(
471
- getContext(), SkImageFilters::Image(
472
- std::move(image), srcRect, dstRect,
473
- SkSamplingOptions(filterMode, mipmap))));
482
+ auto filter = std::make_shared<JsiSkImageFilter>(
483
+ getContext(),
484
+ SkImageFilters::Image(std::move(image), srcRect, dstRect,
485
+ SkSamplingOptions(filterMode, mipmap)));
486
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
487
+ getContext());
474
488
  }
475
489
 
476
490
  JSI_HOST_FUNCTION(MakeMagnifier) {
@@ -493,12 +507,13 @@ public:
493
507
  if (hasOptionalArgument(arguments, count, 6)) {
494
508
  cropRect = *JsiSkRect::fromValue(runtime, arguments[6]);
495
509
  }
496
- return jsi::Object::createFromHostObject(
497
- runtime, std::make_shared<JsiSkImageFilter>(
498
- getContext(), SkImageFilters::Magnifier(
499
- lensBounds, zoomAmount, inset,
500
- SkSamplingOptions(filterMode, mipmap),
501
- input, cropRect)));
510
+ auto filter = std::make_shared<JsiSkImageFilter>(
511
+ getContext(),
512
+ SkImageFilters::Magnifier(lensBounds, zoomAmount, inset,
513
+ SkSamplingOptions(filterMode, mipmap), input,
514
+ cropRect));
515
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
516
+ getContext());
502
517
  }
503
518
 
504
519
  JSI_HOST_FUNCTION(MakeMatrixConvolution) {
@@ -524,12 +539,12 @@ public:
524
539
  if (hasOptionalArgument(arguments, count, 10)) {
525
540
  cropRect = *JsiSkRect::fromValue(runtime, arguments[10]);
526
541
  }
527
- return jsi::Object::createFromHostObject(
528
- runtime, std::make_shared<JsiSkImageFilter>(
529
- getContext(),
530
- SkImageFilters::MatrixConvolution(
531
- kernelSize, kernel.data(), gain, bias, kernelOffset,
532
- tileMode, convolveAlpha, std::move(input), cropRect)));
542
+ auto filter = std::make_shared<JsiSkImageFilter>(
543
+ getContext(), SkImageFilters::MatrixConvolution(
544
+ kernelSize, kernel.data(), gain, bias, kernelOffset,
545
+ tileMode, convolveAlpha, std::move(input), cropRect));
546
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
547
+ getContext());
533
548
  }
534
549
 
535
550
  JSI_HOST_FUNCTION(MakeMatrixTransform) {
@@ -546,12 +561,12 @@ public:
546
561
  if (hasOptionalArgument(arguments, count, 3)) {
547
562
  input = JsiSkImageFilter::fromValue(runtime, arguments[3]);
548
563
  }
549
- return jsi::Object::createFromHostObject(
550
- runtime,
551
- std::make_shared<JsiSkImageFilter>(
552
- getContext(), SkImageFilters::MatrixTransform(
553
- matrix, SkSamplingOptions(filterMode, mipmap),
554
- std::move(input))));
564
+ auto filter = std::make_shared<JsiSkImageFilter>(
565
+ getContext(),
566
+ SkImageFilters::MatrixTransform(
567
+ matrix, SkSamplingOptions(filterMode, mipmap), std::move(input)));
568
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
569
+ getContext());
555
570
  }
556
571
 
557
572
  JSI_HOST_FUNCTION(MakeMerge) {
@@ -570,11 +585,11 @@ public:
570
585
  if (hasOptionalArgument(arguments, count, 1)) {
571
586
  cropRect = *JsiSkRect::fromValue(runtime, arguments[1]);
572
587
  }
573
- return jsi::Object::createFromHostObject(
574
- runtime,
575
- std::make_shared<JsiSkImageFilter>(
576
- getContext(),
577
- SkImageFilters::Merge(filters.data(), filtersCount, cropRect)));
588
+ auto filter = std::make_shared<JsiSkImageFilter>(
589
+ getContext(),
590
+ SkImageFilters::Merge(filters.data(), filtersCount, cropRect));
591
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
592
+ getContext());
578
593
  }
579
594
 
580
595
  JSI_HOST_FUNCTION(MakePicture) {
@@ -585,10 +600,10 @@ public:
585
600
  } else {
586
601
  targetRect = picture ? picture->cullRect() : SkRect::MakeEmpty();
587
602
  }
588
- return jsi::Object::createFromHostObject(
589
- runtime, std::make_shared<JsiSkImageFilter>(
590
- getContext(),
591
- SkImageFilters::Picture(std::move(picture), targetRect)));
603
+ auto filter = std::make_shared<JsiSkImageFilter>(
604
+ getContext(), SkImageFilters::Picture(std::move(picture), targetRect));
605
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
606
+ getContext());
592
607
  }
593
608
 
594
609
  JSI_HOST_FUNCTION(MakeRuntimeShaderWithChildren) {
@@ -620,12 +635,12 @@ public:
620
635
  inputs.push_back(JsiSkImageFilter::fromValue(runtime, element));
621
636
  }
622
637
  }
623
- return jsi::Object::createFromHostObject(
624
- runtime, std::make_shared<JsiSkImageFilter>(
625
- getContext(),
626
- SkImageFilters::RuntimeShader(*rtb, maxSampleRadius,
627
- childNamesStringView.data(),
628
- inputs.data(), length)));
638
+ auto filter = std::make_shared<JsiSkImageFilter>(
639
+ getContext(), SkImageFilters::RuntimeShader(*rtb, maxSampleRadius,
640
+ childNamesStringView.data(),
641
+ inputs.data(), length));
642
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
643
+ getContext());
629
644
  }
630
645
 
631
646
  JSI_HOST_FUNCTION(MakeTile) {
@@ -635,10 +650,10 @@ public:
635
650
  if (hasOptionalArgument(arguments, count, 2)) {
636
651
  input = JsiSkImageFilter::fromValue(runtime, arguments[2]);
637
652
  }
638
- return jsi::Object::createFromHostObject(
639
- runtime,
640
- std::make_shared<JsiSkImageFilter>(
641
- getContext(), SkImageFilters::Tile(src, dst, std::move(input))));
653
+ auto filter = std::make_shared<JsiSkImageFilter>(
654
+ getContext(), SkImageFilters::Tile(src, dst, std::move(input)));
655
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, filter,
656
+ getContext());
642
657
  }
643
658
 
644
659
  JSI_EXPORT_FUNCTIONS(
@@ -672,6 +687,8 @@ public:
672
687
  JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakePointLitSpecular),
673
688
  JSI_EXPORT_FUNC(JsiSkImageFilterFactory, MakeSpotLitSpecular))
674
689
 
690
+ size_t getMemoryPressure() const override { return 2048; }
691
+
675
692
  explicit JsiSkImageFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
676
693
  : JsiSkHostObject(std::move(context)) {}
677
694
  };
@@ -52,9 +52,10 @@ public:
52
52
  static jsi::Value toValue(jsi::Runtime &runtime,
53
53
  std::shared_ptr<RNSkPlatformContext> context,
54
54
  const SkImageInfo &imageInfo) {
55
- return jsi::Object::createFromHostObject(
56
- runtime,
57
- std::make_shared<JsiSkImageInfo>(std::move(context), imageInfo));
55
+ auto imageInfoObj =
56
+ std::make_shared<JsiSkImageInfo>(std::move(context), imageInfo);
57
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, imageInfoObj,
58
+ context);
58
59
  }
59
60
 
60
61
  JSI_PROPERTY_GET(width) { return static_cast<double>(getObject()->width()); }
@@ -68,6 +69,8 @@ public:
68
69
  return static_cast<double>(getObject()->alphaType());
69
70
  }
70
71
 
72
+ size_t getMemoryPressure() const override { return sizeof(SkImageInfo); }
73
+
71
74
  JSI_API_TYPENAME(ImageInfo);
72
75
 
73
76
  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkImageInfo, width),
@@ -25,6 +25,8 @@ public:
25
25
  : JsiSkWrappingSkPtrHostObject<SkMaskFilter>(std::move(context),
26
26
  std::move(maskFilter)) {}
27
27
 
28
+ size_t getMemoryPressure() const override { return 2048; }
29
+
28
30
  EXPORT_JSI_API_TYPENAME(JsiSkMaskFilter, MaskFilter)
29
31
  };
30
32
 
@@ -25,13 +25,15 @@ public:
25
25
  int blurStyle = arguments[0].asNumber();
26
26
  float sigma = arguments[1].asNumber();
27
27
  bool respectCTM = arguments[2].getBool();
28
- return jsi::Object::createFromHostObject(
29
- runtime,
30
- std::make_shared<JsiSkMaskFilter>(
31
- getContext(),
32
- SkMaskFilter::MakeBlur((SkBlurStyle)blurStyle, sigma, respectCTM)));
28
+ auto maskFilter = std::make_shared<JsiSkMaskFilter>(
29
+ getContext(),
30
+ SkMaskFilter::MakeBlur((SkBlurStyle)blurStyle, sigma, respectCTM));
31
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(runtime, maskFilter,
32
+ getContext());
33
33
  }
34
34
 
35
+ size_t getMemoryPressure() const override { return 1024; }
36
+
35
37
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMaskFilterFactory, MakeBlur))
36
38
 
37
39
  explicit JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
@@ -166,6 +166,8 @@ public:
166
166
  }
167
167
  }
168
168
 
169
+ size_t getMemoryPressure() const override { return sizeof(SkMatrix); }
170
+
169
171
  static const jsi::HostFunctionType
170
172
  createCtor(std::shared_ptr<RNSkPlatformContext> context) {
171
173
  return JSI_HOST_FUNCTION_LAMBDA {
@@ -175,8 +177,10 @@ public:
175
177
  } else {
176
178
  matrix = SkMatrix::I();
177
179
  }
178
- return jsi::Object::createFromHostObject(
179
- runtime, std::make_shared<JsiSkMatrix>(std::move(context), matrix));
180
+ auto hostObjectInstance =
181
+ std::make_shared<JsiSkMatrix>(context, std::move(matrix));
182
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
183
+ runtime, hostObjectInstance, context);
180
184
  };
181
185
  }
182
186
  };
@@ -35,8 +35,10 @@ public:
35
35
 
36
36
  JSI_HOST_FUNCTION(copy) {
37
37
  const auto *paint = getObject().get();
38
- return jsi::Object::createFromHostObject(
39
- runtime, std::make_shared<JsiSkPaint>(getContext(), SkPaint(*paint)));
38
+ auto hostObjectInstance =
39
+ std::make_shared<JsiSkPaint>(getContext(), SkPaint(*paint));
40
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
41
+ runtime, hostObjectInstance, getContext());
40
42
  }
41
43
 
42
44
  JSI_HOST_FUNCTION(reset) {
@@ -206,6 +208,8 @@ public:
206
208
  setObject(std::make_shared<SkPaint>(std::move(paint)));
207
209
  }
208
210
 
211
+ size_t getMemoryPressure() const override { return sizeof(SkPaint); }
212
+
209
213
  /**
210
214
  * Creates the function for construction a new instance of the SkPaint
211
215
  * wrapper
@@ -219,8 +223,9 @@ public:
219
223
  auto paint = SkPaint();
220
224
  paint.setAntiAlias(true);
221
225
  // Return the newly constructed object
222
- return jsi::Object::createFromHostObject(
223
- runtime, std::make_shared<JsiSkPaint>(std::move(context), paint));
226
+ auto hostObjectInstance = std::make_shared<JsiSkPaint>(context, paint);
227
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
228
+ runtime, hostObjectInstance, context);
224
229
  };
225
230
  }
226
231
  };
@@ -171,6 +171,8 @@ public:
171
171
  JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics),
172
172
  JSI_EXPORT_FUNC(JsiSkParagraph, dispose))
173
173
 
174
+ size_t getMemoryPressure() const override { return 8192; }
175
+
174
176
  explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
175
177
  para::ParagraphBuilder *paragraphBuilder)
176
178
  : JsiSkWrappingSharedPtrHostObject<para::Paragraph>(