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
cd99819e
Commit
cd99819e
authored
Jul 23, 2021
by
Nikolay Igotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaner locks.
parent
64946688
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
MetalRedrawer.kt
...Main/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
+14
-15
No files found.
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
View file @
cd99819e
...
@@ -60,6 +60,8 @@ internal class MetalRedrawer(
...
@@ -60,6 +60,8 @@ internal class MetalRedrawer(
private
suspend
fun
draw
()
{
private
suspend
fun
draw
()
{
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
val
handle
=
startRendering
()
val
handle
=
startRendering
()
synchronized
(
disposeLock
)
{
if
(!
isDisposed
)
if
(
layer
.
prepareDrawContext
())
{
if
(
layer
.
prepareDrawContext
())
{
// 2,3 GHz 8-Core Intel Core i9
// 2,3 GHz 8-Core Intel Core i9
//
//
...
@@ -72,12 +74,9 @@ internal class MetalRedrawer(
...
@@ -72,12 +74,9 @@ internal class MetalRedrawer(
//
//
// Executors.newSingleThreadExecutor().asCoroutineDispatcher(): 50 FPS, 150% CPU
// Executors.newSingleThreadExecutor().asCoroutineDispatcher(): 50 FPS, 150% CPU
// Dispatchers.IO: 50 FPS, 200% CPU
// Dispatchers.IO: 50 FPS, 200% CPU
synchronized
(
disposeLock
)
{
if
(!
isDisposed
)
{
layer
.
draw
()
layer
.
draw
()
}
}
}
}
}
endRendering
(
handle
)
endRendering
(
handle
)
}
}
// When window is not visible - it doesn't make sense to redraw fast to avoid battery drain.
// When window is not visible - it doesn't make sense to redraw fast to avoid battery drain.
...
...
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