@shopify/react-native-skia 2.4.19 → 2.4.20
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.
- package/cpp/api/JsiSkImage.h +14 -19
- package/cpp/api/JsiSkPicture.h +13 -18
- package/cpp/api/JsiSkSurface.h +13 -18
- package/package.json +1 -1
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -289,31 +289,26 @@ public:
|
|
|
289
289
|
std::move(image)) {
|
|
290
290
|
// Get the dispatcher for the current thread
|
|
291
291
|
_dispatcher = Dispatcher::getDispatcher();
|
|
292
|
-
// Process any pending operations
|
|
292
|
+
// Process any pending operations (e.g. deletions of previous resources)
|
|
293
293
|
_dispatcher->processQueue();
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
protected:
|
|
297
|
-
void releaseResources() override {
|
|
298
|
-
// Queue deletion on the creation thread if needed
|
|
299
|
-
auto image = getObjectUnchecked();
|
|
300
|
-
if (image && _dispatcher) {
|
|
301
|
-
_dispatcher->run([image]() {
|
|
302
|
-
// Image will be deleted when this lambda is destroyed
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
// Clear the object
|
|
306
|
-
JsiSkWrappingSkPtrHostObject<SkImage>::releaseResources();
|
|
307
|
-
}
|
|
308
|
-
|
|
309
296
|
public:
|
|
310
297
|
~JsiSkImage() override {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
298
|
+
if (!isDisposed()) {
|
|
299
|
+
// This JSI Object is being deleted from a GC, which might happen
|
|
300
|
+
// on a separate Thread. GPU resources (like SkImage) must be deleted
|
|
301
|
+
// on the same Thread they were created on, so in this case we schedule
|
|
302
|
+
// deletion to run on the Thread this Object was created on.
|
|
303
|
+
auto image = getObjectUnchecked();
|
|
304
|
+
if (image && _dispatcher) {
|
|
305
|
+
_dispatcher->run([image]() {
|
|
306
|
+
// Image will be deleted when this lambda is destroyed, on the
|
|
307
|
+
// original Thread.
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
releaseResources();
|
|
314
311
|
}
|
|
315
|
-
// Use the same cleanup path as dispose()
|
|
316
|
-
releaseResources();
|
|
317
312
|
}
|
|
318
313
|
|
|
319
314
|
size_t getMemoryPressure() const override {
|
package/cpp/api/JsiSkPicture.h
CHANGED
|
@@ -34,27 +34,22 @@ public:
|
|
|
34
34
|
_dispatcher->processQueue();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
protected:
|
|
38
|
-
void releaseResources() override {
|
|
39
|
-
// Queue deletion on the creation thread if needed
|
|
40
|
-
auto picture = getObjectUnchecked();
|
|
41
|
-
if (picture && _dispatcher) {
|
|
42
|
-
_dispatcher->run([picture]() {
|
|
43
|
-
// Picture will be deleted when this lambda is destroyed
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Clear the object
|
|
47
|
-
JsiSkWrappingSkPtrHostObject<SkPicture>::releaseResources();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
37
|
public:
|
|
51
38
|
~JsiSkPicture() override {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
if (!isDisposed()) {
|
|
40
|
+
// This JSI Object is being deleted from a GC, which might happen
|
|
41
|
+
// on a separate Thread. GPU resources (like SkPicture) must be deleted
|
|
42
|
+
// on the same Thread they were created on, so in this case we schedule
|
|
43
|
+
// deletion to run on the Thread this Object was created on.
|
|
44
|
+
auto picture = getObjectUnchecked();
|
|
45
|
+
if (picture && _dispatcher) {
|
|
46
|
+
_dispatcher->run([picture]() {
|
|
47
|
+
// Picture will be deleted when this lambda is destroyed, on the
|
|
48
|
+
// original Thread.
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
releaseResources();
|
|
55
52
|
}
|
|
56
|
-
// Use the same cleanup path as dispose()
|
|
57
|
-
releaseResources();
|
|
58
53
|
}
|
|
59
54
|
|
|
60
55
|
JSI_HOST_FUNCTION(makeShader) {
|
package/cpp/api/JsiSkSurface.h
CHANGED
|
@@ -45,27 +45,22 @@ public:
|
|
|
45
45
|
_dispatcher->processQueue();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
protected:
|
|
49
|
-
void releaseResources() override {
|
|
50
|
-
// Queue deletion on the creation thread if needed
|
|
51
|
-
auto surface = getObjectUnchecked();
|
|
52
|
-
if (surface && _dispatcher) {
|
|
53
|
-
_dispatcher->run([surface]() {
|
|
54
|
-
// Surface will be deleted when this lambda is destroyed
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
// Clear the object
|
|
58
|
-
JsiSkWrappingSkPtrHostObject<SkSurface>::releaseResources();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
48
|
public:
|
|
62
49
|
~JsiSkSurface() override {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
if (!isDisposed()) {
|
|
51
|
+
// This JSI Object is being deleted from a GC, which might happen
|
|
52
|
+
// on a separate Thread. GPU resources (like SkSurface) must be deleted
|
|
53
|
+
// on the same Thread they were created on, so in this case we schedule
|
|
54
|
+
// deletion to run on the Thread this Object was created on.
|
|
55
|
+
auto surface = getObjectUnchecked();
|
|
56
|
+
if (surface && _dispatcher) {
|
|
57
|
+
_dispatcher->run([surface]() {
|
|
58
|
+
// Surface will be deleted when this lambda is destroyed, on the
|
|
59
|
+
// original Thread.
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
releaseResources();
|
|
66
63
|
}
|
|
67
|
-
// Use the same cleanup path as dispose()
|
|
68
|
-
releaseResources();
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
EXPORT_JSI_API_TYPENAME(JsiSkSurface, Surface)
|