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
b3af6583
Commit
b3af6583
authored
Feb 19, 2021
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set background color for DirectX swap chain buffers.
parent
e73285de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
9 deletions
+22
-9
directXRedrawer.cc
skiko/src/jvmMain/cpp/windows/directXRedrawer.cc
+3
-0
SkiaLayer.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
+14
-9
Direct3DContextHandler.kt
...lin/org/jetbrains/skiko/context/Direct3DContextHandler.kt
+4
-0
Direct3DRedrawer.kt
...n/kotlin/org/jetbrains/skiko/redrawer/Direct3DRedrawer.kt
+1
-0
No files found.
skiko/src/jvmMain/cpp/windows/directXRedrawer.cc
View file @
b3af6583
...
@@ -299,6 +299,9 @@ HRESULT D3DCompile(
...
@@ -299,6 +299,9 @@ HRESULT D3DCompile(
gr_cp
<
IDXGISwapChain1
>
swapChain
;
gr_cp
<
IDXGISwapChain1
>
swapChain
;
GR_D3D_CALL_ERRCHECK
(
swapChainFactory
->
CreateSwapChainForHwnd
(
d3dDevice
->
queue
.
get
(),
fWindow
,
&
swapChainDesc
,
&
swapChainFSDesc
,
nullptr
,
&
swapChain
));
GR_D3D_CALL_ERRCHECK
(
swapChainFactory
->
CreateSwapChainForHwnd
(
d3dDevice
->
queue
.
get
(),
fWindow
,
&
swapChainDesc
,
&
swapChainFSDesc
,
nullptr
,
&
swapChain
));
DXGI_RGBA
background
=
{
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
};
swapChain
->
SetBackgroundColor
(
&
background
);
GR_D3D_CALL_ERRCHECK
(
swapChain
->
QueryInterface
(
IID_PPV_ARGS
(
&
d3dDevice
->
swapChain
)));
GR_D3D_CALL_ERRCHECK
(
swapChain
->
QueryInterface
(
IID_PPV_ARGS
(
&
d3dDevice
->
swapChain
)));
GR_D3D_CALL_ERRCHECK
(
d3dDevice
->
device
->
CreateFence
(
0
,
D3D12_FENCE_FLAG_NONE
,
IID_PPV_ARGS
(
&
d3dDevice
->
fence
)));
GR_D3D_CALL_ERRCHECK
(
d3dDevice
->
device
->
CreateFence
(
0
,
D3D12_FENCE_FLAG_NONE
,
IID_PPV_ARGS
(
&
d3dDevice
->
fence
)));
d3dDevice
->
fenceEvent
=
CreateEvent
(
nullptr
,
FALSE
,
FALSE
,
nullptr
);
d3dDevice
->
fenceEvent
=
CreateEvent
(
nullptr
,
FALSE
,
FALSE
,
nullptr
);
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
View file @
b3af6583
...
@@ -45,7 +45,7 @@ open class SkiaLayer(
...
@@ -45,7 +45,7 @@ open class SkiaLayer(
contextHandler
=
createContextHandler
(
this
,
initialRenderApi
)
contextHandler
=
createContextHandler
(
this
,
initialRenderApi
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
initialRenderApi
,
properties
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
initialRenderApi
,
properties
)
redrawer
?.
syncSize
()
redrawer
?.
syncSize
()
redrawer
?.
redrawImmediately
(
)
draw
(
isBlank
=
true
)
}
}
override
fun
dispose
()
{
override
fun
dispose
()
{
...
@@ -109,22 +109,26 @@ open class SkiaLayer(
...
@@ -109,22 +109,26 @@ open class SkiaLayer(
}
}
}
}
override
fun
draw
()
{
override
fun
draw
()
=
draw
(
isBlank
=
false
)
fun
draw
(
isBlank
:
Boolean
)
{
check
(!
isDisposed
)
check
(!
isDisposed
)
contextHandler
?.
apply
{
contextHandler
?.
apply
{
if
(!
initContext
())
{
if
(!
initContext
())
{
fallbackToNextApi
()
fallbackToNextApi
()
return
return
}
}
initCanvas
()
if
(!
isBlank
)
{
clearCanvas
()
initCanvas
()
synchronized
(
pictureLock
)
{
clearCanvas
()
val
picture
=
picture
synchronized
(
pictureLock
)
{
if
(
picture
!=
null
)
{
val
picture
=
picture
drawOnCanvas
(
picture
.
instance
)
if
(
picture
!=
null
)
{
drawOnCanvas
(
picture
.
instance
)
}
}
}
flush
()
}
}
flush
()
}
}
}
}
...
@@ -145,6 +149,7 @@ open class SkiaLayer(
...
@@ -145,6 +149,7 @@ open class SkiaLayer(
private
fun
fallbackToNextApi
()
{
private
fun
fallbackToNextApi
()
{
val
nextApi
=
fallbackRenderApiQueue
.
removeAt
(
0
)
val
nextApi
=
fallbackRenderApiQueue
.
removeAt
(
0
)
println
(
"Falling back to $nextApi rendering..."
)
println
(
"Falling back to $nextApi rendering..."
)
contextHandler
?.
dispose
()
redrawer
?.
dispose
()
redrawer
?.
dispose
()
contextHandler
=
createContextHandler
(
this
,
nextApi
)
contextHandler
=
createContextHandler
(
this
,
nextApi
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
nextApi
,
properties
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
nextApi
,
properties
)
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/context/Direct3DContextHandler.kt
View file @
b3af6583
...
@@ -24,6 +24,10 @@ internal class Direct3DContextHandler(layer: SkiaLayer) : ContextHandler(layer)
...
@@ -24,6 +24,10 @@ internal class Direct3DContextHandler(layer: SkiaLayer) : ContextHandler(layer)
if
(
device
==
0L
)
{
if
(
device
==
0L
)
{
throw
Exception
(
"Failed to create DirectX12 device."
)
throw
Exception
(
"Failed to create DirectX12 device."
)
}
}
val
scale
=
layer
.
contentScale
val
w
=
(
layer
.
width
*
scale
).
toInt
().
coerceAtLeast
(
0
)
val
h
=
(
layer
.
height
*
scale
).
toInt
().
coerceAtLeast
(
0
)
directXRedrawer
.
resizeBuffers
(
device
,
w
,
h
)
context
=
directXRedrawer
.
makeContext
(
device
)
context
=
directXRedrawer
.
makeContext
(
device
)
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/Direct3DRedrawer.kt
View file @
b3af6583
...
@@ -66,6 +66,7 @@ internal class Direct3DRedrawer(
...
@@ -66,6 +66,7 @@ internal class Direct3DRedrawer(
external
fun
createDirectXDevice
(
windowHandle
:
Long
):
Long
external
fun
createDirectXDevice
(
windowHandle
:
Long
):
Long
external
fun
makeDirectXContext
(
device
:
Long
):
Long
external
fun
makeDirectXContext
(
device
:
Long
):
Long
external
fun
makeDirectXRenderTarget
(
device
:
Long
,
width
:
Int
,
height
:
Int
):
Long
external
fun
makeDirectXRenderTarget
(
device
:
Long
,
width
:
Int
,
height
:
Int
):
Long
external
fun
resizeBuffers
(
device
:
Long
,
width
:
Int
,
height
:
Int
)
private
external
fun
finishFrame
(
device
:
Long
,
context
:
Long
,
surface
:
Long
,
isVsyncEnabled
:
Boolean
)
private
external
fun
finishFrame
(
device
:
Long
,
context
:
Long
,
surface
:
Long
,
isVsyncEnabled
:
Boolean
)
external
fun
disposeDevice
(
device
:
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