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
40cd2b02
Commit
40cd2b02
authored
Mar 18, 2021
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored resizing in MetalRedrawer.
parent
1bb1711b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
MetalRedrawer.kt
...Main/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
+3
-2
MetalRedrawer.mm
skiko/src/jvmMain/objectiveC/macos/MetalRedrawer.mm
+9
-7
No files found.
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
View file @
40cd2b02
...
...
@@ -49,11 +49,12 @@ internal class MetalRedrawer(
}
override
fun
syncSize
()
{
val
globalPosition
=
convertPoint
(
layer
,
layer
.
x
,
layer
.
y
,
getRootPane
(
layer
))
val
rootPane
=
getRootPane
(
layer
)
val
globalPosition
=
convertPoint
(
layer
,
layer
.
x
,
layer
.
y
,
rootPane
)
setContentScale
(
device
,
layer
.
contentScale
)
resizeLayers
(
device
,
globalPosition
.
x
,
globalPosition
.
y
,
rootPane
.
height
-
globalPosition
.
y
-
layer
.
height
,
layer
.
width
.
coerceAtLeast
(
0
),
layer
.
height
.
coerceAtLeast
(
0
)
)
...
...
skiko/src/jvmMain/objectiveC/macos/MetalRedrawer.mm
View file @
40cd2b02
...
...
@@ -82,15 +82,10 @@ JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_makeMeta
JNIEnv * env, jobject redrawer, jlong devicePtr, jint width, jint height)
{
MetalDevice *device = (MetalDevice *) devicePtr;
device.layer.drawableSize = CGRectMake(0, 0, width, height).size;
id<CAMetalDrawable> currentDrawable = [device.layer nextDrawable];
GrMtlTextureInfo info;
info.fTexture.retain(currentDrawable.texture);
GrBackendRenderTarget* renderTarget = new GrBackendRenderTarget(width, height, 0, info);
device.drawableHandle = currentDrawable;
return (jlong) renderTarget;
...
...
@@ -135,10 +130,13 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_resizeLay
JNIEnv *env, jobject redrawer, jlong devicePtr, jint x, jint y, jint width, jint height)
{
MetalDevice *device = (MetalDevice *) devicePtr;
y = (int)device.container.frame.size.height - y - height;
float scale = device.layer.contentsScale;
CGRect frame = CGRectMake(x, y, width, height);
CGSize drawableSize = CGSizeMake(width * scale, height * scale);
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
device.layer.frame = CGRectMake(x, y, width, height);
device.layer.frame = frame;
device.layer.drawableSize = drawableSize;
[CATransaction commit];
[CATransaction flush];
}
...
...
@@ -146,9 +144,13 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_resizeLay
JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_setContentScale(JNIEnv *env, jobject obj, jlong devicePtr, jfloat contentScale)
{
MetalDevice *device = (MetalDevice *) devicePtr;
if (device.layer.contentsScale == contentScale) {
return;
}
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
assert(contentScale != 0);
device.container.contentsScale = contentScale;
device.layer.contentsScale = contentScale;
[CATransaction commit];
[CATransaction flush];
...
...
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