Commit aba0903d authored by Roman Sedaikin's avatar Roman Sedaikin

Fixed disposing context in DirectX rendering.

parent 9f3566a5
......@@ -438,23 +438,9 @@ extern "C"
}
JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_Direct3DRedrawer_disposeDevice(
JNIEnv *env, jobject redrawer, jlong devicePtr, jlong contextPtr)
JNIEnv *env, jobject redrawer, jlong devicePtr)
{
DirectXDevice *d3dDevice = fromJavaPointer<DirectXDevice *>(devicePtr);
GrDirectContext *context = fromJavaPointer<GrDirectContext *>(contextPtr);
context->flush({});
context->submit(true);
for (int i = 0; i < BuffersCount; i++)
{
if (d3dDevice->fence->GetCompletedValue() < d3dDevice->fenceValues[i])
{
GR_D3D_CALL_ERRCHECK(d3dDevice->fence->SetEventOnCompletion(d3dDevice->fenceValues[i], d3dDevice->fenceEvent));
WaitForSingleObjectEx(d3dDevice->fenceEvent, INFINITE, FALSE);
}
}
delete d3dDevice;
}
......
......@@ -94,11 +94,7 @@ internal class Direct3DContextHandler(layer: SkiaLayer) : ContextHandler(layer)
}
override fun destroyContext() {
try {
directXRedrawer.disposeDevice(device, Native.getPtr(context!!))
} finally {
Reference.reachabilityFence(context!!)
}
directXRedrawer.disposeDevice(device)
context?.close()
}
......
......@@ -86,7 +86,7 @@ internal class Direct3DRedrawer(
external fun makeDirectXSurface(device: Long, context: Long, width: Int, height: Int, index: Int): Long
external fun resizeBuffers(device: Long, width: Int, height: Int)
private external fun finishFrame(device: Long, context: Long, surface: Long, isVsyncEnabled: Boolean)
external fun disposeDevice(device: Long, context: Long)
external fun disposeDevice(device: Long)
external fun getBufferIndex(device: Long): Int
external fun initSwapChain(device: Long)
external fun initFence(device: Long)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment