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
80ef24e9
Unverified
Commit
80ef24e9
authored
Jul 31, 2023
by
Elijah Semyonov
Committed by
GitHub
Jul 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip presenting CAMetalDrawable for CAMetalLayer that changed size (#779)
parent
a662a791
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
MetalRedrawer.kt
...Main/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
+0
-2
MetalContextHandler.mm
skiko/src/awtMain/objectiveC/macos/MetalContextHandler.mm
+15
-1
No files found.
skiko/src/awtMain/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
View file @
80ef24e9
...
@@ -112,11 +112,9 @@ internal class MetalRedrawer(
...
@@ -112,11 +112,9 @@ internal class MetalRedrawer(
override
fun
redrawImmediately
()
{
override
fun
redrawImmediately
()
{
check
(!
isDisposed
)
{
"MetalRedrawer is disposed"
}
check
(!
isDisposed
)
{
"MetalRedrawer is disposed"
}
inDrawScope
{
inDrawScope
{
setVSyncEnabled
(
device
.
ptr
,
enabled
=
false
)
update
(
System
.
nanoTime
())
update
(
System
.
nanoTime
())
if
(!
isDisposed
)
{
// Redrawer may be disposed in user code, during `update`
if
(!
isDisposed
)
{
// Redrawer may be disposed in user code, during `update`
performDraw
()
performDraw
()
setVSyncEnabled
(
device
.
ptr
,
properties
.
isVsyncEnabled
)
}
}
}
}
}
}
...
...
skiko/src/awtMain/objectiveC/macos/MetalContextHandler.mm
View file @
80ef24e9
...
@@ -61,11 +61,25 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_context_MetalContextHandler_fini
...
@@ -61,11 +61,25 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_context_MetalContextHandler_fini
if (currentDrawable) {
if (currentDrawable) {
id<MTLCommandBuffer> commandBuffer = [device.queue commandBuffer];
id<MTLCommandBuffer> commandBuffer = [device.queue commandBuffer];
commandBuffer.label = @"Present";
commandBuffer.label = @"Present";
[commandBuffer presentDrawable:currentDrawable];
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
/// commands have completed, allow next waiting (if any) to start encoding new work to gpu
/// commands have completed, allow next waiting (if any) to start encoding new work to gpu
dispatch_semaphore_signal(device.inflightSemaphore);
dispatch_semaphore_signal(device.inflightSemaphore);
}];
}];
[commandBuffer addScheduledHandler:^(id<MTLCommandBuffer> buffer) {
int drawableWidth = currentDrawable.texture.width;
int drawableHeight = currentDrawable.texture.height;
int layerWidth = device.layer.drawableSize.width;
int layerHeight = device.layer.drawableSize.height;
/// Avoid presenting drawable on layer that has already changed size by the moment it was scheduled
if (drawableWidth == layerWidth && drawableHeight == layerHeight) {
[currentDrawable present];
}
}];
[commandBuffer commit];
[commandBuffer commit];
device.drawableHandle = nil;
device.drawableHandle = nil;
}
}
...
...
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