Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
9f360dc0
Commit
9f360dc0
authored
Feb 19, 2021
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed crash when opening multiple windows and changing the size of one of them.
parent
09d549dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
directXRedrawer.cc
skiko/src/jvmMain/cpp/windows/directXRedrawer.cc
+14
-1
Direct3DContextHandler.kt
...lin/org/jetbrains/skiko/context/Direct3DContextHandler.kt
+0
-2
Direct3DRedrawer.kt
...n/kotlin/org/jetbrains/skiko/redrawer/Direct3DRedrawer.kt
+0
-1
No files found.
skiko/src/jvmMain/cpp/windows/directXRedrawer.cc
View file @
9f360dc0
#ifdef SK_DIRECT3D
#include <stdexcept>
#include <windows.h>
#include <jawt_md.h>
#include "jni_helpers.h"
...
...
@@ -21,6 +22,7 @@
if (!SUCCEEDED(result)) \
{ \
SkDebugf("Failed Direct3D call. Error: 0x%08x\n", result); \
throw std::exception("ERROR"); \
} \
} while (false)
...
...
@@ -189,6 +191,14 @@ HRESULT D3DCompile(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
,
jint
width
,
jint
height
)
{
DirectXDevice
*
d3dDevice
=
fromJavaPointer
<
DirectXDevice
*>
(
devicePtr
);
if
(
!
d3dDevice
->
isSizeEqualTo
(
width
,
height
))
{
GR_D3D_CALL_ERRCHECK
(
d3dDevice
->
swapChain
->
ResizeBuffers
(
BuffersCount
,
width
,
height
,
DXGI_FORMAT_R8G8B8A8_UNORM
,
0
));
d3dDevice
->
bufferWidth
=
width
;
d3dDevice
->
bufferHeight
=
height
;
}
d3dDevice
->
bufferIndex
=
d3dDevice
->
swapChain
->
GetCurrentBackBufferIndex
();
ID3D12Resource
*
buffer
;
GR_D3D_CALL_ERRCHECK
(
d3dDevice
->
swapChain
->
GetBuffer
(
d3dDevice
->
bufferIndex
,
IID_PPV_ARGS
(
&
buffer
)));
...
...
@@ -268,8 +278,9 @@ HRESULT D3DCompile(
swapChainDesc
.
BufferCount
=
BuffersCount
;
swapChainDesc
.
Format
=
DXGI_FORMAT_R8G8B8A8_UNORM
;
swapChainDesc
.
BufferUsage
=
DXGI_USAGE_RENDER_TARGET_OUTPUT
;
swapChainDesc
.
SwapEffect
=
DXGI_SWAP_EFFECT_FLIP_
DISCARD
;
swapChainDesc
.
SwapEffect
=
DXGI_SWAP_EFFECT_FLIP_
SEQUENTIAL
;
swapChainDesc
.
SampleDesc
.
Count
=
1
;
swapChainDesc
.
SampleDesc
.
Quality
=
0
;
swapChainDesc
.
Scaling
=
DXGI_SCALING_NONE
;
DXGI_SWAP_CHAIN_FULLSCREEN_DESC
swapChainFSDesc
=
{};
...
...
@@ -307,6 +318,8 @@ HRESULT D3DCompile(
surface
->
flush
(
SkSurface
::
BackendSurfaceAccess
::
kPresent
,
GrFlushInfo
());
fContext
->
flush
({});
fContext
->
submit
(
true
);
// 1 value in [Present(1, 0)] enables vblank wait so this is how vertical sync works in DirectX.
GR_D3D_CALL_ERRCHECK
(
d3dDevice
->
swapChain
->
Present
(
1
,
0
));
const
UINT64
fence
=
d3dDevice
->
fenceValue
;
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/context/Direct3DContextHandler.kt
View file @
9f360dc0
...
...
@@ -40,8 +40,6 @@ internal class Direct3DContextHandler(layer: SkiaLayer) : ContextHandler(layer)
val
w
=
(
layer
.
width
*
scale
).
toInt
().
coerceAtLeast
(
0
)
val
h
=
(
layer
.
height
*
scale
).
toInt
().
coerceAtLeast
(
0
)
directXRedrawer
.
resizeBuffers
(
device
,
w
,
h
)
renderTarget
=
directXRedrawer
.
makeRenderTarget
(
device
,
w
,
h
)
surface
=
Surface
.
makeFromBackendRenderTarget
(
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/Direct3DRedrawer.kt
View file @
9f360dc0
...
...
@@ -60,7 +60,6 @@ internal class Direct3DRedrawer(
external
fun
createDirectXDevice
(
windowHandle
:
Long
):
Long
external
fun
makeDirectXContext
(
device
:
Long
):
Long
external
fun
makeDirectXRenderTarget
(
device
:
Long
,
width
:
Int
,
height
:
Int
):
Long
external
fun
resizeBuffers
(
device
:
Long
,
width
:
Int
,
height
:
Int
)
external
fun
finishFrame
(
device
:
Long
,
context
:
Long
,
surface
:
Long
)
external
fun
disposeDevice
(
device
:
Long
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment