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
81ed0544
Unverified
Commit
81ed0544
authored
Sep 03, 2021
by
Nikolay Igotti
Committed by
GitHub
Sep 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
External linking mechanism for native and JS (#159)
parent
b8510b66
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
10 deletions
+77
-10
build.gradle.kts
skiko/build.gradle.kts
+1
-3
BackendRenderTarget.kt
...mmonMain/kotlin/org/jetbrains/skia/BackendRenderTarget.kt
+12
-4
Expects.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
+5
-1
Actuals.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skia/Actuals.js.kt
+3
-1
BackendRenderTarget.cc
skiko/src/macosX64Main/cpp/common/BackendRenderTarget.cc
+53
-0
Actuals.native.kt
.../macosX64Main/kotlin/org/jetbrains/skia/Actuals.native.kt
+3
-1
No files found.
skiko/build.gradle.kts
View file @
81ed0544
...
@@ -121,8 +121,6 @@ kotlin {
...
@@ -121,8 +121,6 @@ kotlin {
if
(
supportNative
)
{
if
(
supportNative
)
{
val
nativeTarget
=
when
(
target
)
{
val
nativeTarget
=
when
(
target
)
{
"macos-x64"
,
"macos-arm64"
->
macosX64
()
"macos-x64"
,
"macos-arm64"
->
macosX64
()
// "linux-x64" -> linuxX64()
// "windows-x64" -> mingwX64()
else
->
null
else
->
null
}
}
nativeTarget
?.
apply
{
nativeTarget
?.
apply
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/BackendRenderTarget.kt
View file @
81ed0544
...
@@ -50,10 +50,18 @@ class BackendRenderTarget internal constructor(ptr: Long) : Managed(ptr, _Finali
...
@@ -50,10 +50,18 @@ class BackendRenderTarget internal constructor(ptr: Long) : Managed(ptr, _Finali
return
BackendRenderTarget
(
_nMakeDirect3D
(
width
,
height
,
texturePtr
,
format
,
sampleCnt
,
levelCnt
))
return
BackendRenderTarget
(
_nMakeDirect3D
(
width
,
height
,
texturePtr
,
format
,
sampleCnt
,
levelCnt
))
}
}
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
@JvmStatic
external
fun
_nMakeGL
(
width
:
Int
,
height
:
Int
,
sampleCnt
:
Int
,
stencilBits
:
Int
,
fbId
:
Int
,
fbFormat
:
Int
):
Long
@ExternalSymbolName
(
"BackendRenderTarget_nGetFinalizer"
)
@JvmStatic
external
fun
_nMakeMetal
(
width
:
Int
,
height
:
Int
,
texturePtr
:
Long
):
Long
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMakeDirect3D
(
@JvmStatic
@ExternalSymbolName
(
"BackendRenderTarget_nMakeGL"
)
external
fun
_nMakeGL
(
width
:
Int
,
height
:
Int
,
sampleCnt
:
Int
,
stencilBits
:
Int
,
fbId
:
Int
,
fbFormat
:
Int
):
Long
@JvmStatic
@ExternalSymbolName
(
"BackendRenderTarget_nMakeMetal"
)
external
fun
_nMakeMetal
(
width
:
Int
,
height
:
Int
,
texturePtr
:
Long
):
Long
@JvmStatic
@ExternalSymbolName
(
"BackendRenderTarget_nMakeDirect3D"
)
external
fun
_nMakeDirect3D
(
width
:
Int
,
width
:
Int
,
height
:
Int
,
height
:
Int
,
texturePtr
:
Long
,
texturePtr
:
Long
,
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
View file @
81ed0544
...
@@ -28,3 +28,7 @@ interface BooleanSupplier {
...
@@ -28,3 +28,7 @@ interface BooleanSupplier {
*/
*/
val
asBoolean
:
Boolean
val
asBoolean
:
Boolean
}
}
@OptIn
(
ExperimentalMultiplatform
::
class
)
@OptionalExpectation
expect
annotation
class
ExternalSymbolName
(
val
name
:
String
)
skiko/src/jsMain/kotlin/org/jetbrains/skia/Actuals.js.kt
View file @
81ed0544
...
@@ -21,3 +21,5 @@ actual class Matcher {
...
@@ -21,3 +21,5 @@ actual class Matcher {
actual
fun
defaultLanguageTag
():
String
=
TODO
()
actual
fun
defaultLanguageTag
():
String
=
TODO
()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
TODO
()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
TODO
()
actual
typealias
ExternalSymbolName
=
kotlin
.
js
.
JsName
skiko/src/macosX64Main/cpp/common/BackendRenderTarget.cc
0 → 100644
View file @
81ed0544
#include <iostream>
#include <jni.h>
#include "GrBackendSurface.h"
static
void
deleteBackendRenderTarget
(
GrBackendRenderTarget
*
rt
)
{
delete
rt
;
}
extern
"C"
jlong
BackendRenderTarget_nGetFinalizer
()
{
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
&
deleteBackendRenderTarget
));
}
extern
"C"
jlong
BackendRenderTarget_nMakeGL
(
jint
width
,
jint
height
,
jint
sampleCnt
,
jint
stencilBits
,
jint
fbId
,
jint
fbFormat
)
{
GrGLFramebufferInfo
glInfo
=
{
static_cast
<
unsigned
int
>
(
fbId
),
static_cast
<
unsigned
int
>
(
fbFormat
)
};
GrBackendRenderTarget
*
instance
=
new
GrBackendRenderTarget
(
width
,
height
,
sampleCnt
,
stencilBits
,
glInfo
);
return
reinterpret_cast
<
jlong
>
(
instance
);
}
extern
"C"
jlong
BackendRenderTarget_nMakeMetal
(
jint
width
,
jint
height
,
jlong
texturePtr
)
{
#ifdef SK_METAL
GrMTLHandle
texture
=
reinterpret_cast
<
GrMTLHandle
>
(
static_cast
<
uintptr_t
>
(
texturePtr
));
GrMtlTextureInfo
fbInfo
;
fbInfo
.
fTexture
.
retain
(
texture
);
GrBackendRenderTarget
*
instance
=
new
GrBackendRenderTarget
(
width
,
height
,
fbInfo
);
return
reinterpret_cast
<
jlong
>
(
instance
);
#else
return
0
;
#endif
}
#endif
#ifdef SK_DIRECT3D
#include "d3d/GrD3DTypes.h"
#endif
extern
"C"
jlong
BackendRenderTarget_MakeDirect3D
(
jint
width
,
jint
height
,
jlong
texturePtr
,
jint
format
,
jint
sampleCnt
,
jint
levelCnt
)
{
#
ifdef
SK_DIRECT3D
#ifdef SK_DIRECT3D
GrD3DTextureResourceInfo
texResInfo
=
{};
ID3D12Resource
*
resource
=
reinterpret_cast
<
ID3D12Resource
*>
(
static_cast
<
uintptr_t
>
(
texturePtr
));
texResInfo
.
fResource
.
retain
(
resource
);
texResInfo
.
fResourceState
=
D3D12_RESOURCE_STATE_COMMON
;
texResInfo
.
fFormat
=
static_cast
<
DXGI_FORMAT
>
(
format
);
texResInfo
.
fSampleCount
=
static_cast
<
uint32_t
>
(
sampleCnt
);
texResInfo
.
fLevelCount
=
static_cast
<
uint32_t
>
(
levelCnt
);
GrBackendRenderTarget
*
instance
=
new
GrBackendRenderTarget
(
width
,
height
,
texResInfo
);
return
reinterpret_cast
<
jlong
>
(
instance
);
#else
return
0
;
#endif
}
\ No newline at end of file
skiko/src/macosX64Main/kotlin/org/jetbrains/skia/Actuals.native.kt
View file @
81ed0544
...
@@ -21,3 +21,5 @@ actual class Matcher {
...
@@ -21,3 +21,5 @@ actual class Matcher {
actual
fun
defaultLanguageTag
():
String
=
TODO
()
actual
fun
defaultLanguageTag
():
String
=
TODO
()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
TODO
()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
TODO
()
actual
typealias
ExternalSymbolName
=
kotlin
.
native
.
SymbolName
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