Skip to content

Commit

Permalink
Use CreateSwapChainForHwnd without transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
MatkovIvan committed Mar 1, 2024
1 parent 0f1775d commit 4733b7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions skiko/src/awtMain/cpp/windows/directXRedrawer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ class DirectXDevice
device.reset(nullptr);
}

void initSwapChain(UINT width, UINT height) {
void initSwapChain(UINT width, UINT height, jboolean transparency) {
gr_cp<IDXGIFactory4> swapChainFactory4;
gr_cp<IDXGISwapChain1> swapChain1;
CreateDXGIFactory2(0, IID_PPV_ARGS(&swapChainFactory4));
HRESULT result = CreateSwapChainForComposition(swapChainFactory4.get(), width, height, &swapChain1);
if (FAILED(result)) {
HRESULT result = S_OK;
if (transparency) {
result = CreateSwapChainForComposition(swapChainFactory4.get(), width, height, &swapChain1);
}
if (!transparency || FAILED(result)) {
/*
* It's just a fallback path that added for compatibility.
* In this case transparency won't be supported.
Expand Down Expand Up @@ -360,12 +363,12 @@ extern "C"
}

JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_Direct3DRedrawer_initSwapChain(
JNIEnv *env, jobject redrawer, jlong devicePtr, jint width, jint height)
JNIEnv *env, jobject redrawer, jlong devicePtr, jint width, jint height, jboolean transparency)
{
__try
{
DirectXDevice *d3dDevice = fromJavaPointer<DirectXDevice *>(devicePtr);
d3dDevice->initSwapChain((UINT) width, (UINT) height);
d3dDevice->initSwapChain((UINT) width, (UINT) height, transparency);
}
__except(EXCEPTION_EXECUTE_HANDLER) {
auto code = GetExceptionCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal class Direct3DRedrawer(

fun changeSize(width: Int, height: Int): Boolean {
return if (!isSwapChainInitialized) {
initSwapChain(device, width, height)
initSwapChain(device, width, height, layer.transparency)
isSwapChainInitialized = true
true
} else {
Expand Down Expand Up @@ -134,7 +134,7 @@ internal class Direct3DRedrawer(
private external fun swap(device: Long, isVsyncEnabled: Boolean)
private external fun disposeDevice(device: Long)
private external fun getBufferIndex(device: Long): Int
private external fun initSwapChain(device: Long, width: Int, height: Int)
private external fun initSwapChain(device: Long, width: Int, height: Int, transparency: Boolean)
private external fun initFence(device: Long)
private external fun getAdapterName(adapter: Long): String
private external fun getAdapterMemorySize(adapter: Long): Long
Expand Down

0 comments on commit 4733b7e

Please sign in to comment.