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
10bb62f3
Unverified
Commit
10bb62f3
authored
Nov 16, 2021
by
Shagen Ogandzhanian
Committed by
GitHub
Nov 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array serialization revisited (#387)
parent
30b588f5
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
197 additions
and
62 deletions
+197
-62
mppinterop.h
skiko/src/commonMain/cpp/common/include/mppinterop.h
+4
-0
mppinterop.cc
skiko/src/commonMain/cpp/common/mppinterop.cc
+7
-0
ManagedString.kt
...src/commonMain/kotlin/org/jetbrains/skia/ManagedString.kt
+1
-1
StdVectorDecoder.kt
.../commonMain/kotlin/org/jetbrains/skia/StdVectorDecoder.kt
+36
-0
Typeface.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
+57
-14
Native.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/impl/Native.kt
+6
-2
TypefaceTest.kt
...src/commonTest/kotlin/org/jetbrains/skiko/TypefaceTest.kt
+1
-3
ManagedString.cc
skiko/src/jvmMain/cpp/common/ManagedString.cc
+2
-5
StdVectorDecoder.cc
skiko/src/jvmMain/cpp/common/StdVectorDecoder.cc
+33
-0
Typeface.cc
skiko/src/jvmMain/cpp/common/Typeface.cc
+7
-11
ManagedString.cc
skiko/src/nativeJsMain/cpp/ManagedString.cc
+2
-4
StdVectorDecoder.cc
skiko/src/nativeJsMain/cpp/StdVectorDecoder.cc
+32
-0
Typeface.cc
skiko/src/nativeJsMain/cpp/Typeface.cc
+9
-22
No files found.
skiko/src/commonMain/cpp/common/include/mppinterop.h
View file @
10bb62f3
...
@@ -22,6 +22,10 @@ namespace skikoMpp {
...
@@ -22,6 +22,10 @@ namespace skikoMpp {
int
getClustersLength
(
SkTextBlob
*
instance
);
int
getClustersLength
(
SkTextBlob
*
instance
);
bool
getClusters
(
SkTextBlob
*
instance
,
int
*
clusters
);
bool
getClusters
(
SkTextBlob
*
instance
,
int
*
clusters
);
}
}
namespace
finalizers
{
void
deleteString
(
void
*
instance
);
}
}
}
namespace
skija
{
namespace
skija
{
...
...
skiko/src/commonMain/cpp/common/mppinterop.cc
View file @
10bb62f3
#include "mppinterop.h"
#include "mppinterop.h"
#include "RunRecordClone.hh"
#include "RunRecordClone.hh"
#include "src/utils/SkUTF.h"
#include "src/utils/SkUTF.h"
#include <iostream>
namespace
skikoMpp
{
namespace
skikoMpp
{
namespace
skrect
{
namespace
skrect
{
...
@@ -192,6 +193,12 @@ namespace skikoMpp {
...
@@ -192,6 +193,12 @@ namespace skikoMpp {
return
true
;
return
true
;
}
}
}
}
namespace
finalizers
{
void
deleteString
(
void
*
instance
)
{
delete
reinterpret_cast
<
SkString
*>
(
instance
);
}
}
}
}
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/ManagedString.kt
View file @
10bb62f3
...
@@ -62,7 +62,7 @@ class ManagedString internal constructor(ptr: NativePointer, managed: Boolean =
...
@@ -62,7 +62,7 @@ class ManagedString internal constructor(ptr: NativePointer, managed: Boolean =
}
}
@ExternalSymbolName
(
"org_jetbrains_skia_ManagedString__1nGetFinalizer"
)
@ExternalSymbolName
(
"org_jetbrains_skia_ManagedString__1nGetFinalizer"
)
private
external
fun
ManagedString_nGetFinalizer
():
NativePointer
internal
external
fun
ManagedString_nGetFinalizer
():
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_ManagedString__1nMake"
)
@ExternalSymbolName
(
"org_jetbrains_skia_ManagedString__1nMake"
)
private
external
fun
_nMake
(
s
:
InteropPointer
):
NativePointer
private
external
fun
_nMake
(
s
:
InteropPointer
):
NativePointer
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/StdVectorDecoder.kt
0 → 100644
View file @
10bb62f3
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_StdVectorDecoder__1nGetArraySize"
)
private
external
fun
StdVectorDecoder_nGetArraySize
(
array
:
NativePointer
):
Int
@ExternalSymbolName
(
"org_jetbrains_skia_StdVectorDecoder__1nDisposeArray"
)
private
external
fun
StdVectorDecoder_nDisposeArray
(
array
:
NativePointer
,
disposePtr
:
NativePointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_StdVectorDecoder__1nReleaseElement"
)
private
external
fun
StdVectorDecoder_nReleaseElement
(
array
:
NativePointer
,
index
:
Int
):
NativePointer
class
ArrayDecoder
(
private
val
ptr
:
NativePointer
,
private
val
disposePtr
:
NativePointer
)
{
fun
dispose
()
{
StdVectorDecoder_nDisposeArray
(
ptr
,
disposePtr
)
}
fun
release
(
index
:
Int
):
NativePointer
{
return
StdVectorDecoder_nReleaseElement
(
ptr
,
index
)
}
val
size
:
Int
get
()
=
StdVectorDecoder_nGetArraySize
(
ptr
)
}
inline
fun
<
T
>
arrayDecoderScope
(
arrayDecoderBlock
:
()
->
ArrayDecoder
,
block
:
(
arrayCode
:
ArrayDecoder
)
->
T
):
T
{
var
arrayDecoder
:
ArrayDecoder
?
=
null
return
try
{
arrayDecoder
=
arrayDecoderBlock
()
block
.
invoke
(
arrayDecoder
)
}
finally
{
arrayDecoder
?.
dispose
()
}
}
\ No newline at end of file
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
View file @
10bb62f3
package
org.jetbrains.skia
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.
*
import
org.jetbrains.skia.impl.
InteropPointer
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skiko.kotlinBackend
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.interopScope
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.withNullableResult
import
org.jetbrains.skia.impl.withResult
import
org.jetbrains.skia.impl.withStringResult
class
Typeface
internal
constructor
(
ptr
:
NativePointer
)
:
RefCnt
(
ptr
)
{
class
Typeface
internal
constructor
(
ptr
:
NativePointer
)
:
RefCnt
(
ptr
)
{
companion
object
{
companion
object
{
...
@@ -119,7 +128,13 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
...
@@ -119,7 +128,13 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
}
}
(
0
until
axisCount
).
map
{
i
->
(
0
until
axisCount
).
map
{
i
->
val
j
=
5
*
i
val
j
=
5
*
i
FontVariationAxis
(
axisData
[
j
],
Float
.
fromBits
(
axisData
[
j
+
1
]),
Float
.
fromBits
(
axisData
[
j
+
2
]),
Float
.
fromBits
(
axisData
[
j
+
3
]),
axisData
[
j
+
4
]
!=
0
)
FontVariationAxis
(
axisData
[
j
],
Float
.
fromBits
(
axisData
[
j
+
1
]),
Float
.
fromBits
(
axisData
[
j
+
2
]),
Float
.
fromBits
(
axisData
[
j
+
3
]),
axisData
[
j
+
4
]
!=
0
)
}.
toTypedArray
()
}.
toTypedArray
()
}
}
}
finally
{
}
finally
{
...
@@ -177,8 +192,9 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
...
@@ -177,8 +192,9 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
return
try
{
return
try
{
if
(
variations
.
size
==
0
)
return
this
if
(
variations
.
size
==
0
)
return
this
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
val
variationsData
=
variations
.
asList
().
flatMap
{
listOf
(
it
.
_tag
,
it
.
value
.
toRawBits
())}.
toIntArray
()
val
variationsData
=
variations
.
asList
().
flatMap
{
listOf
(
it
.
_tag
,
it
.
value
.
toRawBits
())
}.
toIntArray
()
val
ptr
=
interopScope
{
_nMakeClone
(
_ptr
,
toInterop
(
variationsData
),
2
*
variations
.
size
,
collectionIndex
)
}
val
ptr
=
interopScope
{
_nMakeClone
(
_ptr
,
toInterop
(
variationsData
),
2
*
variations
.
size
,
collectionIndex
)
}
require
(
ptr
!=
NullPointer
)
{
require
(
ptr
!=
NullPointer
)
{
"Failed to clone Typeface $this with $variations"
"Failed to clone Typeface $this with $variations"
}
}
...
@@ -339,12 +355,24 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
...
@@ -339,12 +355,24 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
* @return all of the family names specified by the font
* @return all of the family names specified by the font
*/
*/
val
familyNames
:
Array
<
FontFamilyName
>
val
familyNames
:
Array
<
FontFamilyName
>
get
()
=
try
{
get
()
{
return
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
_nGetFamilyNames
(
_ptr
)
arrayDecoderScope
({
ArrayDecoder
(
_nGetFamilyNames
(
_ptr
),
ManagedString_nGetFinalizer
())
})
{
arrayDecoder
->
val
size
=
arrayDecoder
.
size
(
0
until
size
/
2
).
map
{
i
->
val
name
=
withStringResult
(
arrayDecoder
.
release
(
2
*
i
))
val
language
=
withStringResult
(
arrayDecoder
.
release
(
2
*
i
+
1
))
FontFamilyName
(
name
,
language
)
}.
toTypedArray
()
}
}
finally
{
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
this
)
}
}
}
/**
/**
* @return the family name for this typeface. The language of the name is whatever the host platform chooses
* @return the family name for this typeface. The language of the name is whatever the host platform chooses
...
@@ -383,7 +411,12 @@ private external fun Typeface_nEquals(ptr: NativePointer, otherPtr: NativePointe
...
@@ -383,7 +411,12 @@ private external fun Typeface_nEquals(ptr: NativePointer, otherPtr: NativePointe
private
external
fun
Typeface_nMakeDefault
():
NativePointer
private
external
fun
Typeface_nMakeDefault
():
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetUTF32Glyphs"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetUTF32Glyphs"
)
private
external
fun
Typeface_nGetUTF32Glyphs
(
ptr
:
NativePointer
,
uni
:
InteropPointer
,
count
:
Int
,
glyphs
:
InteropPointer
)
private
external
fun
Typeface_nGetUTF32Glyphs
(
ptr
:
NativePointer
,
uni
:
InteropPointer
,
count
:
Int
,
glyphs
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetUTF32Glyph"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetUTF32Glyph"
)
private
external
fun
Typeface_nGetUTF32Glyph
(
ptr
:
NativePointer
,
unichar
:
Int
):
Short
private
external
fun
Typeface_nGetUTF32Glyph
(
ptr
:
NativePointer
,
unichar
:
Int
):
Short
...
@@ -419,7 +452,12 @@ internal external fun _nMakeFromFile(path: InteropPointer, index: Int): NativePo
...
@@ -419,7 +452,12 @@ internal external fun _nMakeFromFile(path: InteropPointer, index: Int): NativePo
private
external
fun
_nMakeFromData
(
dataPtr
:
NativePointer
,
index
:
Int
):
NativePointer
private
external
fun
_nMakeFromData
(
dataPtr
:
NativePointer
,
index
:
Int
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nMakeClone"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nMakeClone"
)
private
external
fun
_nMakeClone
(
ptr
:
NativePointer
,
variations
:
InteropPointer
,
variationsCount
:
Int
,
collectionIndex
:
Int
):
NativePointer
private
external
fun
_nMakeClone
(
ptr
:
NativePointer
,
variations
:
InteropPointer
,
variationsCount
:
Int
,
collectionIndex
:
Int
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetGlyphsCount"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetGlyphsCount"
)
private
external
fun
_nGetGlyphsCount
(
ptr
:
NativePointer
):
Int
private
external
fun
_nGetGlyphsCount
(
ptr
:
NativePointer
):
Int
...
@@ -443,10 +481,15 @@ private external fun _nGetTableData(ptr: NativePointer, tag: Int): NativePointer
...
@@ -443,10 +481,15 @@ private external fun _nGetTableData(ptr: NativePointer, tag: Int): NativePointer
private
external
fun
_nGetUnitsPerEm
(
ptr
:
NativePointer
):
Int
private
external
fun
_nGetUnitsPerEm
(
ptr
:
NativePointer
):
Int
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetKerningPairAdjustments"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetKerningPairAdjustments"
)
private
external
fun
_nGetKerningPairAdjustments
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
,
count
:
Int
,
adjustments
:
InteropPointer
):
Boolean
private
external
fun
_nGetKerningPairAdjustments
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
,
count
:
Int
,
adjustments
:
InteropPointer
):
Boolean
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetFamilyNames"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetFamilyNames"
)
private
external
fun
_nGetFamilyNames
(
ptr
:
NativePointer
):
Array
<
FontFamilyName
>
private
external
fun
_nGetFamilyNames
(
ptr
:
NativePointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetFamilyName"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetFamilyName"
)
private
external
fun
_nGetFamilyName
(
ptr
:
NativePointer
):
NativePointer
private
external
fun
_nGetFamilyName
(
ptr
:
NativePointer
):
NativePointer
\ No newline at end of file
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Native.kt
View file @
10bb62f3
...
@@ -135,8 +135,12 @@ inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPo
...
@@ -135,8 +135,12 @@ inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPo
*/
*/
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
inline
fun
withStringResult
(
block
:
()
->
NativePointer
):
String
{
inline
fun
withStringResult
(
block
:
()
->
NativePointer
):
String
{
val
string
=
ManagedString
(
block
())
return
ManagedString
(
block
()).
use
{
it
.
toString
()
}
return
string
.
toString
()
}
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
inline
fun
withStringResult
(
pointer
:
NativePointer
):
String
{
return
ManagedString
(
pointer
).
use
{
it
.
toString
()
}
}
}
/**
/**
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skiko/TypefaceTest.kt
View file @
10bb62f3
...
@@ -86,9 +86,7 @@ class TypefaceTest {
...
@@ -86,9 +86,7 @@ class TypefaceTest {
assertNull
(
jbMono
.
getKerningPairAdjustments
(
null
))
assertNull
(
jbMono
.
getKerningPairAdjustments
(
null
))
assertNull
(
jbMono
.
getKerningPairAdjustments
(
jbMono
.
getStringGlyphs
(
"TAV"
)))
assertNull
(
jbMono
.
getKerningPairAdjustments
(
jbMono
.
getStringGlyphs
(
"TAV"
)))
if
(
kotlinBackend
==
KotlinBackend
.
JVM
)
{
assertContentEquals
(
arrayOf
(
FontFamilyName
(
"Inter"
,
"en-US"
)),
interV
.
familyNames
)
assertContentEquals
(
arrayOf
(
FontFamilyName
(
"Inter"
,
"en-US"
)),
interV
.
familyNames
)
}
assertEquals
(
"Inter"
,
interV
.
familyName
)
assertEquals
(
"Inter"
,
interV
.
familyName
)
}
}
...
...
skiko/src/jvmMain/cpp/common/ManagedString.cc
View file @
10bb62f3
#include <jni.h>
#include <jni.h>
#include "interop.hh"
#include "interop.hh"
#include "mppinterop.h"
#include "SkString.h"
#include "SkString.h"
static
void
deleteString
(
SkString
*
instance
)
{
delete
instance
;
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_ManagedStringKt_ManagedString_1nGetFinalizer
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_ManagedStringKt_ManagedString_1nGetFinalizer
(
JNIEnv
*
env
,
jclass
jclass
)
{
(
JNIEnv
*
env
,
jclass
jclass
)
{
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
&
deleteString
));
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
&
skikoMpp
::
finalizers
::
deleteString
));
}
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_ManagedStringKt__1nMake
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_ManagedStringKt__1nMake
...
...
skiko/src/jvmMain/cpp/common/StdVectorDecoder.cc
0 → 100644
View file @
10bb62f3
#include <jni.h>
#include "interop.hh"
extern
"C"
JNIEXPORT
jint
JNICALL
Java_org_jetbrains_skia_StdVectorDecoderKt_StdVectorDecoder_1nGetArraySize
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
)
{
std
::
vector
<
void
*>*
vec
=
reinterpret_cast
<
std
::
vector
<
void
*>
*>
(
ptr
);
return
static_cast
<
jint
>
(
vec
->
size
());
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_StdVectorDecoderKt_StdVectorDecoder_1nReleaseElement
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jint
index
)
{
auto
&
vec
=
*
reinterpret_cast
<
std
::
vector
<
void
*>
*>
(
ptr
);
auto
res
=
vec
[
index
];
vec
[
index
]
=
nullptr
;
return
reinterpret_cast
<
jlong
>
(
res
);
}
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_StdVectorDecoderKt_StdVectorDecoder_1nDisposeArray
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jlong
disposePtr
)
{
std
::
vector
<
void
*>*
vec
=
reinterpret_cast
<
std
::
vector
<
void
*>
*>
(
ptr
);
void
(
*
dtor
)(
void
*
)
=
reinterpret_cast
<
void
(
*
)(
void
*
)
>
(
disposePtr
);
while
(
!
vec
->
empty
()){
auto
res
=
vec
->
back
();
if
(
res
!=
nullptr
)
{
dtor
(
res
);
}
vec
->
pop_back
();
}
delete
vec
;
}
\ No newline at end of file
skiko/src/jvmMain/cpp/common/Typeface.cc
View file @
10bb62f3
...
@@ -198,24 +198,20 @@ extern "C" JNIEXPORT jboolean JNICALL Java_org_jetbrains_skia_TypefaceKt__1nGetK
...
@@ -198,24 +198,20 @@ extern "C" JNIEXPORT jboolean JNICALL Java_org_jetbrains_skia_TypefaceKt__1nGetK
return
false
;
return
false
;
}
}
extern
"C"
JNIEXPORT
j
objectArray
JNICALL
Java_org_jetbrains_skia_TypefaceKt__1nGetFamilyNames
extern
"C"
JNIEXPORT
j
long
JNICALL
Java_org_jetbrains_skia_TypefaceKt__1nGetFamilyNames
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
)
{
SkTypeface
*
instance
=
reinterpret_cast
<
SkTypeface
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkTypeface
*
instance
=
reinterpret_cast
<
SkTypeface
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkTypeface
::
LocalizedStrings
*
iter
=
instance
->
createFamilyNameIterator
();
SkTypeface
::
LocalizedStrings
*
iter
=
instance
->
createFamilyNameIterator
();
std
::
vector
<
SkTypeface
::
LocalizedString
>
names
;
std
::
vector
<
SkTypeface
::
LocalizedString
>
names
;
SkTypeface
::
LocalizedString
name
;
SkTypeface
::
LocalizedString
name
;
std
::
vector
<
jlong
>*
res
=
new
std
::
vector
<
jlong
>
();
while
(
iter
->
next
(
&
name
))
{
while
(
iter
->
next
(
&
name
))
{
names
.
push_back
(
name
);
res
->
push_back
(
reinterpret_cast
<
jlong
>
(
new
SkString
(
name
.
fString
)));
}
res
->
push_back
(
reinterpret_cast
<
jlong
>
(
new
SkString
(
name
.
fLanguage
)));
iter
->
unref
();
jobjectArray
res
=
env
->
NewObjectArray
((
jsize
)
names
.
size
(),
skija
::
FontFamilyName
::
cls
,
nullptr
);
for
(
int
i
=
0
;
i
<
names
.
size
();
++
i
)
{
skija
::
AutoLocal
<
jstring
>
nameStr
(
env
,
javaString
(
env
,
names
[
i
].
fString
));
skija
::
AutoLocal
<
jstring
>
langStr
(
env
,
javaString
(
env
,
names
[
i
].
fLanguage
));
skija
::
AutoLocal
<
jobject
>
obj
(
env
,
env
->
NewObject
(
skija
::
FontFamilyName
::
cls
,
skija
::
FontFamilyName
::
ctor
,
nameStr
.
get
(),
langStr
.
get
()));
env
->
SetObjectArrayElement
(
res
,
i
,
obj
.
get
());
}
}
return
res
;
return
reinterpret_cast
<
jlong
>
(
res
);
}
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_TypefaceKt__1nGetFamilyName
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_TypefaceKt__1nGetFamilyName
...
...
skiko/src/nativeJsMain/cpp/ManagedString.cc
View file @
10bb62f3
...
@@ -3,14 +3,12 @@
...
@@ -3,14 +3,12 @@
#include "SkString.h"
#include "SkString.h"
#include "common.h"
#include "common.h"
#include "mppinterop.h"
static
void
deleteString
(
SkString
*
instance
)
{
delete
instance
;
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_ManagedString__1nGetFinalizer
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_ManagedString__1nGetFinalizer
()
{
()
{
return
reinterpret_cast
<
KNativePointer
>
(
(
&
deleteString
)
);
return
reinterpret_cast
<
KNativePointer
>
(
&
skikoMpp
::
finalizers
::
deleteString
);
}
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_ManagedString__1nMake
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_ManagedString__1nMake
...
...
skiko/src/nativeJsMain/cpp/StdVectorDecoder.cc
0 → 100644
View file @
10bb62f3
#include "common.h"
SKIKO_EXPORT
KInt
org_jetbrains_skia_StdVectorDecoder__1nGetArraySize
(
KNativePointer
ptr
)
{
std
::
vector
<
KNativePointer
>*
vec
=
reinterpret_cast
<
std
::
vector
<
KNativePointer
>
*>
(
ptr
);
return
vec
->
size
();
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_StdVectorDecoder__1nReleaseElement
(
KNativePointer
ptr
,
KInt
index
)
{
auto
&
vec
=
*
reinterpret_cast
<
std
::
vector
<
void
*>
*>
(
ptr
);
auto
res
=
vec
[
index
];
vec
[
index
]
=
nullptr
;
return
res
;
}
SKIKO_EXPORT
void
org_jetbrains_skia_StdVectorDecoder__1nDisposeArray
(
KNativePointer
ptr
,
KNativePointer
disposePtr
)
{
std
::
vector
<
KNativePointer
>*
vec
=
reinterpret_cast
<
std
::
vector
<
KNativePointer
>
*>
(
ptr
);
void
(
*
dtor
)(
void
*
)
=
reinterpret_cast
<
void
(
*
)(
void
*
)
>
(
disposePtr
);
while
(
!
vec
->
empty
()){
auto
res
=
vec
->
back
();
if
(
res
!=
nullptr
)
{
dtor
(
res
);
}
vec
->
pop_back
();
}
delete
vec
;
}
skiko/src/nativeJsMain/cpp/Typeface.cc
View file @
10bb62f3
...
@@ -190,34 +190,21 @@ SKIKO_EXPORT bool org_jetbrains_skia_Typeface__1nGetKerningPairAdjustments
...
@@ -190,34 +190,21 @@ SKIKO_EXPORT bool org_jetbrains_skia_Typeface__1nGetKerningPairAdjustments
return
false
;
return
false
;
}
}
SKIKO_EXPORT
KInteropPointer
Array
org_jetbrains_skia_Typeface__1nGetFamilyNames
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetFamilyNames
(
KNativePointer
ptr
)
{
(
KNativePointer
ptr
)
{
TODO
(
"implement org_jetbrains_skia_Typeface__1nGetFamilyNames"
);
SkTypeface
*
instance
=
reinterpret_cast
<
SkTypeface
*>
(
ptr
);
}
#if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Typeface__1nGetFamilyNames
(KNativePointer ptr) {
SkTypeface* instance = reinterpret_cast<SkTypeface*>((ptr));
SkTypeface
::
LocalizedStrings
*
iter
=
instance
->
createFamilyNameIterator
();
SkTypeface
::
LocalizedStrings
*
iter
=
instance
->
createFamilyNameIterator
();
std
::
vector
<
SkTypeface
::
LocalizedString
>
names
;
std
::
vector
<
SkTypeface
::
LocalizedString
>
names
;
SkTypeface
::
LocalizedString
name
;
SkTypeface
::
LocalizedString
name
;
std
::
vector
<
KInteropPointer
>*
res
=
new
std
::
vector
<
KInteropPointer
>
();
while
(
iter
->
next
(
&
name
))
{
while
(
iter
->
next
(
&
name
))
{
names.push_back(name);
res
->
push_back
(
reinterpret_cast
<
KInteropPointer
>
(
new
SkString
(
name
.
fString
)));
}
res
->
push_back
(
reinterpret_cast
<
KInteropPointer
>
(
new
SkString
(
name
.
fLanguage
)));
iter->unref();
KInteropPointerArray res = env->NewObjectArray((jsize) names.size(), skija::FontFamilyName::cls, nullptr);
for (int i = 0; i < names.size(); ++i) {
skija::AutoLocal<KInteropPointer> nameStr(env, javaString(env, names[i].fString));
skija::AutoLocal<KInteropPointer> langStr(env, javaString(env, names[i].fLanguage));
skija::AutoLocal<KInteropPointer> obj(env, env->NewObject(skija::FontFamilyName::cls, skija::FontFamilyName::ctor, nameStr.get(), langStr.get()));
env->SetObjectArrayElement(res, i, obj.get());
}
}
return res;
}
#endif
return
reinterpret_cast
<
KInteropPointer
>
(
res
);
}
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetFamilyName
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetFamilyName
(
KNativePointer
ptr
)
{
(
KNativePointer
ptr
)
{
...
...
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