@shopify/react-native-skia 0.1.183 → 0.1.184
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.
@@ -103,11 +103,29 @@ void RNSkMetalCanvasProvider::renderToCanvas(
|
|
103
103
|
// usage growing very fast in the simulator without this.
|
104
104
|
@autoreleasepool {
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
/* It is super important that we use the pattern of calling nextDrawable
|
107
|
+
inside this autoreleasepool and not depend on Skia's
|
108
|
+
SkSurface::MakeFromCAMetalLayer to encapsulate since we're seeing a lot of
|
109
|
+
drawables leaking if they're not done this way.
|
110
|
+
|
111
|
+
This is now reverted from:
|
112
|
+
(https://github.com/Shopify/react-native-skia/commit/2e2290f8e6dfc6921f97b79f779d920fbc1acceb)
|
113
|
+
back to the original implementation.
|
114
|
+
*/
|
115
|
+
id<CAMetalDrawable> currentDrawable = [_layer nextDrawable];
|
116
|
+
if (currentDrawable == nullptr) {
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
|
120
|
+
GrMtlTextureInfo fbInfo;
|
121
|
+
fbInfo.fTexture.retain((__bridge void *)currentDrawable.texture);
|
122
|
+
|
123
|
+
GrBackendRenderTarget backendRT(_layer.drawableSize.width,
|
124
|
+
_layer.drawableSize.height, 1, fbInfo);
|
125
|
+
|
126
|
+
auto skSurface = SkSurface::MakeFromBackendRenderTarget(
|
127
|
+
renderContext->skContext.get(), backendRT, kTopLeft_GrSurfaceOrigin,
|
128
|
+
kBGRA_8888_SkColorType, nullptr, nullptr);
|
111
129
|
|
112
130
|
if (skSurface == nullptr || skSurface->getCanvas() == nullptr) {
|
113
131
|
RNSkia::RNSkLogger::logToConsole(
|
@@ -120,11 +138,8 @@ void RNSkMetalCanvasProvider::renderToCanvas(
|
|
120
138
|
|
121
139
|
skSurface->flushAndSubmit();
|
122
140
|
|
123
|
-
id<CAMetalDrawable> currentDrawable =
|
124
|
-
(__bridge id<CAMetalDrawable>)drawableHandle;
|
125
141
|
id<MTLCommandBuffer> commandBuffer(
|
126
142
|
[renderContext->commandQueue commandBuffer]);
|
127
|
-
commandBuffer.label = @"PresentSkia";
|
128
143
|
[commandBuffer presentDrawable:currentDrawable];
|
129
144
|
[commandBuffer commit];
|
130
145
|
}
|
package/package.json
CHANGED