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
d2c7071e
Commit
d2c7071e
authored
Nov 11, 2020
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Swing integration support. Revert skija, skia_build.
parent
ccd10abf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
10 deletions
+145
-10
.project
samples/SkijaInjectSample/.project
+28
-0
SwingSkia.kt
...jectSample/src/main/kotlin/SkijaInjectSample/SwingSkia.kt
+54
-0
build.gradle.kts
skiko/build.gradle.kts
+1
-1
gradle.properties
skiko/gradle.properties
+4
-4
Library.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
+1
-1
drawlayer.m
skiko/src/jvmMain/objectiveC/macos/drawlayer.m
+57
-4
No files found.
samples/SkijaInjectSample/.project
0 → 100644
View file @
d2c7071e
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
SkijaInjectSample
</name>
<comment>
Project SkijaInjectSample created by Buildship.
</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.buildship.core.gradleprojectbuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.buildship.core.gradleprojectnature
</nature>
</natures>
<filteredResources>
<filter>
<id>
1605001915303
</id>
<name></name>
<type>
30
</type>
<matcher>
<id>
org.eclipse.core.resources.regexFilterMatcher
</id>
<arguments>
node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
samples/SkijaInjectSample/src/main/kotlin/SkijaInjectSample/SwingSkia.kt
0 → 100644
View file @
d2c7071e
package
SkijaInjectSample
import
java.awt.Dimension
import
java.awt.BorderLayout
import
java.awt.event.KeyEvent
import
java.awt.event.MouseEvent
import
java.awt.event.MouseMotionAdapter
import
javax.swing.JFrame
import
javax.swing.JButton
import
javax.swing.event.MouseInputAdapter
import
javax.swing.WindowConstants
import
org.jetbrains.skiko.Library
import
org.jetbrains.skiko.SkiaLayer
fun
Button
(
text
:
String
):
JButton
{
val
btn
=
JButton
(
text
)
btn
.
setPreferredSize
(
Dimension
(
100
,
100
))
return
btn
}
fun
SwingSkia
()
{
Library
.
load
(
"/"
,
"skiko"
)
val
window
=
JFrame
()
window
.
defaultCloseOperation
=
WindowConstants
.
EXIT_ON_CLOSE
window
.
title
=
"SwingSkiaWindow"
val
layer
=
SkiaLayer
()
window
.
contentPane
.
add
(
Button
(
"North"
),
BorderLayout
.
NORTH
)
window
.
contentPane
.
add
(
Button
(
"West"
),
BorderLayout
.
WEST
)
window
.
contentPane
.
add
(
Button
(
"East"
),
BorderLayout
.
EAST
)
window
.
contentPane
.
add
(
Button
(
"South"
),
BorderLayout
.
SOUTH
)
window
.
contentPane
.
add
(
layer
,
BorderLayout
.
CENTER
)
val
state
=
State
()
state
.
text
=
window
.
title
var
mouseX
=
0
var
mouseY
=
0
layer
.
renderer
=
Renderer
{
renderer
,
w
,
h
->
displayScene
(
renderer
,
w
,
h
,
mouseX
,
mouseY
,
state
)
}
layer
.
addMouseMotionListener
(
object
:
MouseMotionAdapter
()
{
override
fun
mouseMoved
(
event
:
MouseEvent
)
{
mouseX
=
event
.
x
mouseY
=
event
.
y
layer
.
display
()
}
})
window
.
setSize
(
800
,
600
)
window
.
setVisible
(
true
)
}
skiko/build.gradle.kts
View file @
d2c7071e
...
@@ -233,7 +233,7 @@ tasks.withType(CppCompile::class.java).configureEach {
...
@@ -233,7 +233,7 @@ tasks.withType(CppCompile::class.java).configureEach {
"-DSK_SHAPER_HARFBUZZ_AVAILABLE"
,
"-DSK_SHAPER_HARFBUZZ_AVAILABLE"
,
"-DSK_SUPPORT_OPENCL=0"
,
"-DSK_SUPPORT_OPENCL=0"
,
"-Dskija_EXPORTS"
,
"-Dskija_EXPORTS"
,
"-DSK_UNICODE_AVAILABLE"
,
//
"-DSK_UNICODE_AVAILABLE",
"-DNDEBUG"
"-DNDEBUG"
))
))
when
(
target
)
{
when
(
target
)
{
...
...
skiko/gradle.properties
View file @
d2c7071e
kotlin.code.style
=
official
kotlin.code.style
=
official
deploy.version
=
0.1
deploy.version
=
0.1
dependencies.skija.git.commit
=
20f2c58f121b7f858092781cf0ecf3657e167ce6
dependencies.skija.git.commit
=
11dc7805b8148df8f7b2c72651008b73bf06c00d
dependencies.skia.windows
=
m87-
4893488/Skia-m87-4893488-windows-Release-x64
dependencies.skia.windows
=
m87-
a0c82f0/Skia-m87-a0c82f0-windows-Release-x64b
dependencies.skia.linux
=
m87-
4893488/Skia-m87-4893488
-linux-Release-x64
dependencies.skia.linux
=
m87-
a0c82f0/Skia-m87-a0c82f0
-linux-Release-x64
dependencies.skia.macos
=
m87-
4893488/Skia-m87-4893488
-macos-Release-x64
dependencies.skia.macos
=
m87-
a0c82f0/Skia-m87-a0c82f0
-macos-Release-x64
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
View file @
d2c7071e
...
@@ -55,7 +55,7 @@ object Library {
...
@@ -55,7 +55,7 @@ object Library {
private
fun
miscSystemInit
()
{
private
fun
miscSystemInit
()
{
// we have to set this property to avoid render flickering.
// we have to set this property to avoid render flickering.
System
.
setProperty
(
"sun.awt.noerasebackground"
,
"true"
)
System
.
setProperty
(
"sun.awt.noerasebackground"
,
"true"
)
System
.
setProperty
(
"skija.staticLoad"
,
"false"
)
//
System.setProperty("skija.staticLoad", "false")
// setup menu look and feel
// setup menu look and feel
try
{
try
{
...
...
skiko/src/jvmMain/objectiveC/macos/drawlayer.m
View file @
d2c7071e
...
@@ -55,7 +55,7 @@ JavaVM *jvm = NULL;
...
@@ -55,7 +55,7 @@ JavaVM *jvm = NULL;
if
(
!
drawMethod
)
drawMethod
=
(
*
env
)
->
GetMethodID
(
env
,
wndClass
,
"draw"
,
"()V"
);
if
(
!
drawMethod
)
drawMethod
=
(
*
env
)
->
GetMethodID
(
env
,
wndClass
,
"draw"
,
"()V"
);
if
(
NULL
==
drawMethod
)
if
(
NULL
==
drawMethod
)
{
{
NSLog
(
@"The method
Window
.draw() not found!"
);
NSLog
(
@"The method
HardwareLayer
.draw() not found!"
);
return
;
return
;
}
}
(
*
env
)
->
CallVoidMethod
(
env
,
self
.
canvasGlobalRef
,
drawMethod
);
(
*
env
)
->
CallVoidMethod
(
env
,
self
.
canvasGlobalRef
,
drawMethod
);
...
@@ -101,6 +101,8 @@ JavaVM *jvm = NULL;
...
@@ -101,6 +101,8 @@ JavaVM *jvm = NULL;
{
{
wndClass
=
(
*
env
)
->
GetObjectClass
(
env
,
self
.
glLayer
.
canvasGlobalRef
);
wndClass
=
(
*
env
)
->
GetObjectClass
(
env
,
self
.
glLayer
.
canvasGlobalRef
);
}
}
// scale factor
static
jmethodID
contentScaleMethod
=
NULL
;
static
jmethodID
contentScaleMethod
=
NULL
;
if
(
!
contentScaleMethod
)
if
(
!
contentScaleMethod
)
{
{
...
@@ -108,13 +110,66 @@ JavaVM *jvm = NULL;
...
@@ -108,13 +110,66 @@ JavaVM *jvm = NULL;
}
}
if
(
NULL
==
contentScaleMethod
)
if
(
NULL
==
contentScaleMethod
)
{
{
NSLog
(
@"The method
Window
.getContentScale() not found!"
);
NSLog
(
@"The method
HardwareLayer
.getContentScale() not found!"
);
return
;
return
;
}
}
float
scaleFactor
=
(
*
env
)
->
CallFloatMethod
(
env
,
self
.
glLayer
.
canvasGlobalRef
,
contentScaleMethod
);
float
scaleFactor
=
(
*
env
)
->
CallFloatMethod
(
env
,
self
.
glLayer
.
canvasGlobalRef
,
contentScaleMethod
);
assert
(
scaleFactor
!=
0
);
assert
(
scaleFactor
!=
0
);
self
.
container
.
contentsScale
=
scaleFactor
;
self
.
container
.
contentsScale
=
scaleFactor
;
self
.
glLayer
.
contentsScale
=
scaleFactor
;
self
.
glLayer
.
contentsScale
=
scaleFactor
;
// size & position
static
jmethodID
getXMethod
=
NULL
;
if
(
!
getXMethod
)
{
getXMethod
=
(
*
env
)
->
GetMethodID
(
env
,
wndClass
,
"getX"
,
"()I"
);
}
if
(
NULL
==
getXMethod
)
{
NSLog
(
@"The method HardwareLayer.getX() not found!"
);
return
;
}
static
jmethodID
getYMethod
=
NULL
;
if
(
!
getYMethod
)
{
getYMethod
=
(
*
env
)
->
GetMethodID
(
env
,
wndClass
,
"getY"
,
"()I"
);
}
if
(
NULL
==
getYMethod
)
{
NSLog
(
@"The method HardwareLayer.getY() not found!"
);
return
;
}
static
jmethodID
getWidthMethod
=
NULL
;
if
(
!
getWidthMethod
)
{
getWidthMethod
=
(
*
env
)
->
GetMethodID
(
env
,
wndClass
,
"getWidth"
,
"()I"
);
}
if
(
NULL
==
getWidthMethod
)
{
NSLog
(
@"The method HardwareLayer.getWidth() not found!"
);
return
;
}
static
jmethodID
getHeightMethod
=
NULL
;
if
(
!
getHeightMethod
)
{
getHeightMethod
=
(
*
env
)
->
GetMethodID
(
env
,
wndClass
,
"getHeight"
,
"()I"
);
}
if
(
NULL
==
getHeightMethod
)
{
NSLog
(
@"The method HardwareLayer.getHeight() not found!"
);
return
;
}
int
x
=
(
*
env
)
->
CallIntMethod
(
env
,
self
.
glLayer
.
canvasGlobalRef
,
getXMethod
);
int
y
=
(
*
env
)
->
CallIntMethod
(
env
,
self
.
glLayer
.
canvasGlobalRef
,
getYMethod
);
int
w
=
(
*
env
)
->
CallIntMethod
(
env
,
self
.
glLayer
.
canvasGlobalRef
,
getWidthMethod
);
int
h
=
(
*
env
)
->
CallIntMethod
(
env
,
self
.
glLayer
.
canvasGlobalRef
,
getHeightMethod
);
y
=
(
int
)
self
.
container
.
frame
.
size
.
height
-
y
-
h
;
CGRect
boundsRect
=
CGRectMake
(
x
,
y
,
w
,
h
);
self
.
glLayer
.
frame
=
boundsRect
;
}
}
}
}
...
@@ -222,8 +277,6 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_updateLayer(JNIEnv
...
@@ -222,8 +277,6 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_updateLayer(JNIEnv
layersSet
.
glLayer
=
[
AWTGLLayer
new
];
layersSet
.
glLayer
=
[
AWTGLLayer
new
];
[
layersSet
.
container
addSublayer
:
layersSet
.
glLayer
];
[
layersSet
.
container
addSublayer
:
layersSet
.
glLayer
];
CGFloat
white
[]
=
{
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
};
layersSet
.
glLayer
.
backgroundColor
=
CGColorCreate
(
CGColorSpaceCreateDeviceRGB
(),
white
);
jobject
canvasGlobalRef
=
(
*
env
)
->
NewGlobalRef
(
env
,
canvas
);
jobject
canvasGlobalRef
=
(
*
env
)
->
NewGlobalRef
(
env
,
canvas
);
...
...
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