diff --git a/e2e-test/build.gradle.kts b/e2e-test/build.gradle.kts index cfb2fb727d..bff1d9b518 100644 --- a/e2e-test/build.gradle.kts +++ b/e2e-test/build.gradle.kts @@ -28,8 +28,6 @@ tasks.withType { korge { id = "com.sample.demo" -// useNewMemoryModel = true - // To enable all targets at once //targetAll() @@ -111,4 +109,4 @@ tasks { checkReferencesNative.dependsOn(runTask) } } -} \ No newline at end of file +} diff --git a/kds/src/nativeMain/kotlin/korlibs/datastructure/atomic/KdsAtomicRef.kt b/kds/src/nativeMain/kotlin/korlibs/datastructure/atomic/KdsAtomicRef.kt index 1985f40fce..5fd1c0ca18 100644 --- a/kds/src/nativeMain/kotlin/korlibs/datastructure/atomic/KdsAtomicRef.kt +++ b/kds/src/nativeMain/kotlin/korlibs/datastructure/atomic/KdsAtomicRef.kt @@ -4,8 +4,8 @@ import kotlin.native.concurrent.* // @TODO: Use AtomicReference actual class KdsAtomicRef actual constructor(initial: T) { - val ref = AtomicReference((initial.freeze())) + val ref = AtomicReference(initial) actual var value: T get() = ref.value - set(value) { ref.value = (value.freeze()) } + set(value) { ref.value = value } } diff --git a/kds/src/nativeMain/kotlin/korlibs/datastructure/concurrent/ConcurrentDeque.kt b/kds/src/nativeMain/kotlin/korlibs/datastructure/concurrent/ConcurrentDeque.kt index c0d4dea041..9b83588e73 100644 --- a/kds/src/nativeMain/kotlin/korlibs/datastructure/concurrent/ConcurrentDeque.kt +++ b/kds/src/nativeMain/kotlin/korlibs/datastructure/concurrent/ConcurrentDeque.kt @@ -1,21 +1,16 @@ package korlibs.datastructure.concurrent import kotlin.native.concurrent.AtomicReference -import kotlin.native.concurrent.freeze class ConcurrentDeque { - private val items = AtomicReference>(emptyList().freeze()) - - init { - this.freeze() - } + private val items = AtomicReference>(emptyList()) val size get() = items.value.size fun add(item: T) { do { val oldList = this.items.value - val newList = (oldList + item).freeze() + val newList = (oldList + item) } while (!this.items.compareAndSet(oldList, newList)) } @@ -26,7 +21,7 @@ class ConcurrentDeque { val oldList = this.items.value if (oldList.isEmpty()) return null val lastItem = oldList.first() - val newList = oldList.subList(1, oldList.size).freeze() + val newList = oldList.subList(1, oldList.size) if (this.items.compareAndSet(oldList, newList)) return lastItem } } diff --git a/kds/src/nativeMain/kotlin/korlibs/datastructure/iterators/Native.kt b/kds/src/nativeMain/kotlin/korlibs/datastructure/iterators/Native.kt index d1e862d3fe..ca052cf508 100644 --- a/kds/src/nativeMain/kotlin/korlibs/datastructure/iterators/Native.kt +++ b/kds/src/nativeMain/kotlin/korlibs/datastructure/iterators/Native.kt @@ -4,8 +4,7 @@ import kotlin.math.* import kotlin.native.concurrent.* @OptIn(ExperimentalStdlibApi::class) -actual val CONCURRENCY_COUNT: Int = if (Platform.memoryModel == MemoryModel.EXPERIMENTAL) Platform.getAvailableProcessors() else 1 -//actual val CONCURRENCY_COUNT: Int = 1 +actual val CONCURRENCY_COUNT: Int = Platform.getAvailableProcessors() val PARALLEL_WORKERS = if (CONCURRENCY_COUNT > 1) Array(CONCURRENCY_COUNT) { Worker.start() } else emptyArray() diff --git a/klogger/src/nativeMain/kotlin/korlibs/logger/atomic/KloggerAtomicRefNative.kt b/klogger/src/nativeMain/kotlin/korlibs/logger/atomic/KloggerAtomicRefNative.kt index d80cc386bc..8fa5de5a02 100644 --- a/klogger/src/nativeMain/kotlin/korlibs/logger/atomic/KloggerAtomicRefNative.kt +++ b/klogger/src/nativeMain/kotlin/korlibs/logger/atomic/KloggerAtomicRefNative.kt @@ -1,10 +1,9 @@ package korlibs.logger.atomic -import kotlin.native.concurrent.FreezableAtomicReference -import kotlin.native.concurrent.freeze +import kotlin.native.concurrent.* internal actual class KloggerAtomicRef actual constructor(initial: T) { - private val ref = FreezableAtomicReference(initial.freeze()) + private val ref = AtomicReference(initial) actual var value: T get() = ref.value @@ -16,7 +15,7 @@ internal actual class KloggerAtomicRef actual constructor(initial: T) { //synchronized(ref) { ref.set(ref.get()) } do { val old = ref.value - val new = block(old).freeze() + val new = block(old) } while (!ref.compareAndSet(old, new)) } } diff --git a/klogger/src/nativeTest/kotlin/korlibs.logger.test/LoggerMultithreadedTest.kt b/klogger/src/nativeTest/kotlin/korlibs.logger.test/LoggerMultithreadedTest.kt index a70f035262..c2d6ab3aed 100644 --- a/klogger/src/nativeTest/kotlin/korlibs.logger.test/LoggerMultithreadedTest.kt +++ b/klogger/src/nativeTest/kotlin/korlibs.logger.test/LoggerMultithreadedTest.kt @@ -3,8 +3,6 @@ package korlibs.logger.test import korlibs.logger.Logger import kotlin.native.concurrent.TransferMode import kotlin.native.concurrent.Worker -import kotlin.native.concurrent.freeze -import kotlin.native.concurrent.isFrozen import kotlin.test.* class LoggerMultithreadedTest { @@ -17,12 +15,9 @@ class LoggerMultithreadedTest { logger.level = Logger.Level.INFO logger.level } - val future = worker.execute(TransferMode.SAFE, { changeLoggerLevel.freeze() }) { it() } + val future = worker.execute(TransferMode.SAFE, { changeLoggerLevel }) { it() } val result = future.result - if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) { - assertTrue(logger.isFrozen) - } assertTrue { result == Logger.Level.INFO } assertTrue { logger.level == Logger.Level.INFO } @@ -33,12 +28,9 @@ class LoggerMultithreadedTest { logger2.level } val worker2 = Worker.start() - val future2 = worker2.execute(TransferMode.SAFE, { getLoggerLevel.freeze() }) { it() } + val future2 = worker2.execute(TransferMode.SAFE, { getLoggerLevel }) { it() } val result2 = future2.result - if (Platform.memoryModel != MemoryModel.EXPERIMENTAL) { - assertTrue(logger2.isFrozen) - } assertTrue { result2 == Logger.Level.INFO } assertTrue { logger2.level == Logger.Level.INFO } diff --git a/kmem/src/commonMain/kotlin/korlibs/memory/Platform.kt b/kmem/src/commonMain/kotlin/korlibs/memory/Platform.kt index cf3e21dca6..586ec98ff1 100644 --- a/kmem/src/commonMain/kotlin/korlibs/memory/Platform.kt +++ b/kmem/src/commonMain/kotlin/korlibs/memory/Platform.kt @@ -13,13 +13,10 @@ interface Platform { val buildVariant: BuildVariant /** - * JVM: true + * JVM, Android & K/N: true * Android: true * JS: false <-- workers have different heaps - * K/N: - * - new memory model: true - * - old memory model: false <-- frozen - * */ + **/ val hasMultithreadedSharedHeap: Boolean val isLittleEndian: Boolean get() = endian == Endian.LITTLE_ENDIAN @@ -87,6 +84,6 @@ interface Platform { override val buildVariant: BuildVariant, override val rawPlatformName: String, override val rawOsName: String, - override val hasMultithreadedSharedHeap: Boolean + override val hasMultithreadedSharedHeap: Boolean, ) : Platform } diff --git a/kmem/src/nativeMain/kotlin/korlibs/memory/atomic/KmemAtomicRef.kt b/kmem/src/nativeMain/kotlin/korlibs/memory/atomic/KmemAtomicRef.kt index 59d801508e..03557803a2 100644 --- a/kmem/src/nativeMain/kotlin/korlibs/memory/atomic/KmemAtomicRef.kt +++ b/kmem/src/nativeMain/kotlin/korlibs/memory/atomic/KmemAtomicRef.kt @@ -1,12 +1,11 @@ package korlibs.memory.atomic import kotlin.native.concurrent.AtomicReference -import kotlin.native.concurrent.freeze // @TODO: Use AtomicReference actual class KmemAtomicRef actual constructor(initial: T) { - val ref = AtomicReference(initial.freeze()) + val ref = AtomicReference(initial) actual var value: T get() = ref.value - set(value) { ref.value = value.freeze() } + set(value) { ref.value = value } } diff --git a/kmem/src/nativeMain/kotlin/korlibs/memory/internal/currentNative.kt b/kmem/src/nativeMain/kotlin/korlibs/memory/internal/currentNative.kt index 84c02d92f1..1b43c19729 100644 --- a/kmem/src/nativeMain/kotlin/korlibs/memory/internal/currentNative.kt +++ b/kmem/src/nativeMain/kotlin/korlibs/memory/internal/currentNative.kt @@ -34,7 +34,7 @@ internal actual val currentArch: Arch = when (Platform.cpuArchitecture) { internal actual val currentIsDebug: Boolean get() = Platform.isDebugBinary internal actual val currentIsLittleEndian: Boolean get() = Platform.isLittleEndian -internal actual val multithreadedSharedHeap: Boolean = Platform.memoryModel == MemoryModel.EXPERIMENTAL +internal actual val multithreadedSharedHeap: Boolean = true @SharedImmutable internal actual val currentRawPlatformName: String = "native-$currentOs-$currentArch-$currentBuildVariant" diff --git a/korau/src/mingwMain/kotlin/korlibs/audio/sound/WaveOutProcess.kt b/korau/src/mingwMain/kotlin/korlibs/audio/sound/WaveOutProcess.kt index 6382c245ab..a0d4c9c31f 100644 --- a/korau/src/mingwMain/kotlin/korlibs/audio/sound/WaveOutProcess.kt +++ b/korau/src/mingwMain/kotlin/korlibs/audio/sound/WaveOutProcess.kt @@ -35,7 +35,6 @@ import kotlin.native.concurrent.AtomicReference import kotlin.native.concurrent.Future import kotlin.native.concurrent.TransferMode import kotlin.native.concurrent.Worker -import kotlin.native.concurrent.freeze internal object WINMM : DynamicLibrary("winmm.dll") { val waveOutOpenExt by func<(phwo: LPHWAVEOUT?, uDeviceID: UINT, pwfx: LPCWAVEFORMATEX?, dwCallback: DWORD_PTR, dwInstance: DWORD_PTR, fdwOpen: DWORD) -> MMRESULT>() @@ -52,9 +51,6 @@ private object WaveOutEnd : WaveOutPart private object WaveOutFlush : WaveOutPart private class WaveOutReopen(val freq: Int) : WaveOutPart { - init { - this.freeze() - } } private interface WaveOutDataBase : WaveOutPart { @@ -63,14 +59,10 @@ private interface WaveOutDataBase : WaveOutPart { //private class WaveOutData(val data: ShortArray) : WaveOutDataBase { // override fun computeData(): ShortArray = data -// -// init { -// this.freeze() -// } //} internal class AtomicDouble(value: Double) { - val atomic = AtomicLong(value.toRawBits()).freeze() + val atomic = AtomicLong(value.toRawBits()) var value: Double get() = Double.fromBits(atomic.value) @@ -87,10 +79,6 @@ internal class WaveOutDataEx( .interleaved() .applyProps(pitch, panning, volume) .data - - init { - this.freeze() - } } class WaveOutProcess(val freq: Int, val nchannels: Int) { private val sPosition = AtomicLong(0L) @@ -107,11 +95,6 @@ class WaveOutProcess(val freq: Int, val nchannels: Int) { val length get() = sLength.value //val isCompleted get() = completed.value != 0L val pendingAudio get() = numPendingChunks.value != 0L || deque.size > 0 - - init { - freeze() - } - val pendingCommands get() = deque.size //fun addData(data: ShortArray) { diff --git a/korge-sandbox/src/commonMain/kotlin/samples/MainEmojiColrv1.kt b/korge-sandbox/src/commonMain/kotlin/samples/MainEmojiColrv1.kt index 16ba7f398f..f689960625 100644 --- a/korge-sandbox/src/commonMain/kotlin/samples/MainEmojiColrv1.kt +++ b/korge-sandbox/src/commonMain/kotlin/samples/MainEmojiColrv1.kt @@ -19,8 +19,8 @@ import korlibs.io.file.std.resourcesVfs class MainEmojiColrv1 : Scene() { override suspend fun SContainer.sceneMain() { - val font = resourcesVfs["twemoji-glyf_colr_1.ttf"].readTtfFont(preload = false).asFallbackOf(DefaultTtfFont) - val font2 = measureTime({resourcesVfs["noto-glyf_colr_1.ttf"].readTtfFont(preload = false).asFallbackOf(DefaultTtfFont)}) { + val font = resourcesVfs["twemoji-glyf_colr_1.ttf"].readTtfFont().asFallbackOf(DefaultTtfFont) + val font2 = measureTime({resourcesVfs["noto-glyf_colr_1.ttf"].readTtfFont().asFallbackOf(DefaultTtfFont)}) { println("Read font in... $it") } val font3 = SystemFont.getEmojiFont().asFallbackOf(DefaultTtfFont) diff --git a/korge-sandbox/src/commonMain/kotlin/samples/MainGraphicsText.kt b/korge-sandbox/src/commonMain/kotlin/samples/MainGraphicsText.kt index 81b8a6bdd9..95cdfb9631 100644 --- a/korge-sandbox/src/commonMain/kotlin/samples/MainGraphicsText.kt +++ b/korge-sandbox/src/commonMain/kotlin/samples/MainGraphicsText.kt @@ -12,7 +12,6 @@ import korlibs.image.text.* import korlibs.io.async.* import korlibs.io.file.std.* import korlibs.math.geom.* -import korlibs.math.geom.vector.* import kotlin.properties.* class MainGraphicsText : Scene() { diff --git a/korge-sandbox/src/commonMain/kotlin/samples/MainTextInput.kt b/korge-sandbox/src/commonMain/kotlin/samples/MainTextInput.kt index cac20345b1..e186793bda 100644 --- a/korge-sandbox/src/commonMain/kotlin/samples/MainTextInput.kt +++ b/korge-sandbox/src/commonMain/kotlin/samples/MainTextInput.kt @@ -24,7 +24,7 @@ class MainTextInput : Scene() { //sceneContainer.changeTo({ MainSWF().apply { init(it) } }) //image(atlas.bitmap) - val emojiFont = resourcesVfs["noto-glyf_colr_1.ttf"].readTtfFont(preload = false) + val emojiFont = resourcesVfs["noto-glyf_colr_1.ttf"].readTtfFont() val font = DefaultTtfFont.withFallback(emojiFont) uiTextInput("HELLO", width = 256.0, height = 64.0) { diff --git a/korge/src/commonMain/kotlin/korlibs/korge/resources/ResourcesExt.kt b/korge/src/commonMain/kotlin/korlibs/korge/resources/ResourcesExt.kt index 265de0e512..104dcbcd48 100644 --- a/korge/src/commonMain/kotlin/korlibs/korge/resources/ResourcesExt.kt +++ b/korge/src/commonMain/kotlin/korlibs/korge/resources/ResourcesExt.kt @@ -16,4 +16,4 @@ suspend fun resources(): Resources = injector().get() fun resourceBitmap(@ResourcePath path: String, mipmaps: Boolean = true, cache: ResourceCache = ResourceCache.LOCAL) = resource(cache) { root[path].readBitmapSlice().also { it.bmp.mipmaps(enable = mipmaps) } } fun resourceFont(@ResourcePath path: String, mipmaps: Boolean = true, cache: ResourceCache = ResourceCache.LOCAL) = resource(cache) { root[path].readFont(mipmaps = mipmaps) } fun resourceBitmapFont(@ResourcePath path: String, mipmaps: Boolean = true, cache: ResourceCache = ResourceCache.LOCAL) = resource(cache) { root[path].readBitmapFont(mipmaps = mipmaps) } -fun resourceTtfFont(@ResourcePath path: String, preload: Boolean = false, cache: ResourceCache = ResourceCache.LOCAL) = resource(cache) { root[path].readTtfFont(preload = preload) } +fun resourceTtfFont(@ResourcePath path: String, preload: Boolean = false, cache: ResourceCache = ResourceCache.LOCAL) = resource(cache) { root[path].readTtfFont() } diff --git a/korge/src/nativeTest/kotlin/korlibs/korge/KorgeMultithreadedTest.kt b/korge/src/nativeTest/kotlin/korlibs/korge/KorgeMultithreadedTest.kt index d583141636..22990da217 100644 --- a/korge/src/nativeTest/kotlin/korlibs/korge/KorgeMultithreadedTest.kt +++ b/korge/src/nativeTest/kotlin/korlibs/korge/KorgeMultithreadedTest.kt @@ -102,12 +102,11 @@ class KorgeMultithreadedTest { } fun runInWorker(block: () -> T): T { - block.freeze() block() val worker = Worker.start() return try { - worker.execute(TransferMode.SAFE, { block.freeze() }) { it().freeze() }.result + worker.execute(TransferMode.SAFE, { block }) { it() }.result } finally { worker.requestTermination(processScheduledJobs = false) } diff --git a/korim/src/commonMain/kotlin/korlibs/image/font/DefaultTtfFont.kt b/korim/src/commonMain/kotlin/korlibs/image/font/DefaultTtfFont.kt index 91b32d6a01..310599bb91 100644 --- a/korim/src/commonMain/kotlin/korlibs/image/font/DefaultTtfFont.kt +++ b/korim/src/commonMain/kotlin/korlibs/image/font/DefaultTtfFont.kt @@ -24,7 +24,7 @@ private var DefaultTtfFontOrNull: TtfFont? = null val DefaultTtfFont: TtfFont get() { if (DefaultTtfFontOrNull == null) { val res = measureTimeWithResult { - TtfFont(DefaultTtfFontBytes(), freeze = true, extName = "Default Font") + TtfFont(DefaultTtfFontBytes(), extName = "Default Font") //TtfFont(DefaultTtfFontBytes, preloadAllGlyphs = false, extName = "Default Font") } //println("Loaded DefaultTtfFont in... ${res.time}") diff --git a/korim/src/commonMain/kotlin/korlibs/image/font/FontExt.kt b/korim/src/commonMain/kotlin/korlibs/image/font/FontExt.kt index 434dc6df53..c83ffd1fdc 100644 --- a/korim/src/commonMain/kotlin/korlibs/image/font/FontExt.kt +++ b/korim/src/commonMain/kotlin/korlibs/image/font/FontExt.kt @@ -2,14 +2,12 @@ package korlibs.image.font import korlibs.memory.readS32BE import korlibs.image.format.ImageDecodingProps -import korlibs.image.format.ImageFormat -import korlibs.image.format.RegisteredImageFormats import korlibs.io.file.VfsFile suspend fun VfsFile.readFont(preload: Boolean = false, props: ImageDecodingProps = ImageDecodingProps.DEFAULT, mipmaps: Boolean = true): Font { val header = readRangeBytes(0 until 16) return when (header.readS32BE(0)) { - 0x74746366, 0x4F54544F, 0x00010000 -> readTtfFont(preload) + 0x74746366, 0x4F54544F, 0x00010000 -> readTtfFont() //0x504B0304 -> this.openAsZip { it.listRecursive().filter { it.extensionLC == "ttf" || it.extensionLC == "fnt" || it.extensionLC == "ttc" || it.extensionLC == "otf" }.firstOrNull()?.readFont() ?: error("Can't find TTF or FNT on zip") } else -> readBitmapFont(props, mipmaps) } diff --git a/korim/src/commonMain/kotlin/korlibs/image/font/NativeSystemFontProvider.kt b/korim/src/commonMain/kotlin/korlibs/image/font/NativeSystemFontProvider.kt index 150a025223..e6e57683c1 100644 --- a/korim/src/commonMain/kotlin/korlibs/image/font/NativeSystemFontProvider.kt +++ b/korim/src/commonMain/kotlin/korlibs/image/font/NativeSystemFontProvider.kt @@ -205,12 +205,12 @@ open class FolderBasedNativeSystemFontProvider( return _namesMapLC.value!! } - override fun loadFontByName(name: String, freeze: Boolean): TtfFont? = - runBlockingNoJs { namesMapLC[name.normalizeName()]?.let { TtfFont(it.readAll(), freeze = freeze) } } + override fun loadFontByName(name: String): TtfFont? = + runBlockingNoJs { namesMapLC[name.normalizeName()]?.let { TtfFont(it.readAll()) } } } abstract class TtfNativeSystemFontProvider() : NativeSystemFontProvider() { - abstract fun loadFontByName(name: String, freeze: Boolean = false): TtfFont? + abstract fun loadFontByName(name: String): TtfFont? abstract fun defaultFont(): TtfFont fun String.normalizeName() = this.toLowerCase().trim() @@ -220,7 +220,7 @@ abstract class TtfNativeSystemFontProvider() : NativeSystemFontProvider() { fun locateFontByName(name: String): TtfFont? { val normalizedName = name.normalizeName() - return ttfCache.getOrPut(normalizedName) { loadFontByName(name, freeze = false) } + return ttfCache.getOrPut(normalizedName) { loadFontByName(name) } } fun ttf(systemFont: SystemFont) = locateFontByName(systemFont.name) ?: defaultFont() @@ -262,6 +262,6 @@ open class FallbackNativeSystemFontProvider(val ttf: TtfFont) : TtfNativeSystemF val vfs = VfsFileFromData(ttf.getAllBytesUnsafe(), "ttf") override fun getTtfFromSystemFont(systemFont: SystemFont): TtfFont = ttf override fun listFontNamesWithFiles(): Map = mapOf(ttf.ttfCompleteName to vfs) - override fun loadFontByName(name: String, freeze: Boolean): TtfFont? = ttf + override fun loadFontByName(name: String): TtfFont? = ttf override fun defaultFont(): TtfFont = ttf } diff --git a/korim/src/commonMain/kotlin/korlibs/image/font/TtfFont.kt b/korim/src/commonMain/kotlin/korlibs/image/font/TtfFont.kt index 61d3302ecf..c62f732c4e 100644 --- a/korim/src/commonMain/kotlin/korlibs/image/font/TtfFont.kt +++ b/korim/src/commonMain/kotlin/korlibs/image/font/TtfFont.kt @@ -20,11 +20,10 @@ import kotlin.collections.set class TtfFont( d: ByteArray, - freeze: Boolean = false, extName: String? = null, onlyReadMetadata: Boolean = false, enableLigatures: Boolean = true, -) : BaseTtfFont(d, freeze, extName, onlyReadMetadata, enableLigatures) { +) : BaseTtfFont(d, extName, onlyReadMetadata, enableLigatures) { private val tablesByName = LinkedHashMap() init { @@ -69,18 +68,16 @@ class TtfFont( @OptIn(KorimInternal::class) abstract class BaseTtfFont( protected val s: FastByteArrayInputStream, - protected val freeze: Boolean = false, protected val extName: String? = null, protected val onlyReadMetadata: Boolean = false, protected val enableLigatures: Boolean = true, ) : VectorFont, Extra by Extra.Mixin() { constructor( d: ByteArray, - freeze: Boolean = false, extName: String? = null, onlyReadMetadata: Boolean = false, enableLigatures: Boolean = true - ) : this(d.openFastStream(), freeze, extName, onlyReadMetadata, enableLigatures) + ) : this(d.openFastStream(), extName, onlyReadMetadata, enableLigatures) fun getAllBytes() = s.getAllBytes() fun getAllBytesUnsafe() = s.getBackingArrayUnsafe() @@ -306,15 +303,6 @@ abstract class BaseTtfFont( //println("tablesByName=$tablesByName") - if (freeze) { - getAllGlyphs(cache = true).fastForEach { - it.metrics1px // Compute it - it.path // Compute it - } - } - - frozen = true - //substitutionsGlyphIds.fastForEach { from, subsMap -> // val fromCodePoint = getCodePointFromCharIndex(from) ?: -1 // val map = LinkedHashMap>() @@ -2219,12 +2207,10 @@ internal inline class Fixed(val data: Int) { } suspend fun VfsFile.readTtfFont( - preload: Boolean = false, onlyReadMetadata: Boolean = false, enableLigatures: Boolean = true, ): TtfFont = TtfFont( this.readAll(), - freeze = preload, extName = this.baseName, onlyReadMetadata = onlyReadMetadata, enableLigatures = enableLigatures diff --git a/korim/src/commonMain/kotlin/korlibs/image/font/WoffFont.kt b/korim/src/commonMain/kotlin/korlibs/image/font/WoffFont.kt index 745d36783a..bb230a7635 100644 --- a/korim/src/commonMain/kotlin/korlibs/image/font/WoffFont.kt +++ b/korim/src/commonMain/kotlin/korlibs/image/font/WoffFont.kt @@ -12,10 +12,9 @@ import korlibs.io.stream.openFastStream class WoffFont( d: ByteArray, - freeze: Boolean = false, extName: String? = null, onlyReadMetadata: Boolean = false, -) : BaseTtfFont(d, freeze, extName, onlyReadMetadata) { +) : BaseTtfFont(d, extName, onlyReadMetadata) { private val tablesByName = LinkedHashMap() init { @@ -71,6 +70,5 @@ class WoffFont( } suspend fun VfsFile.readWoffFont( - preload: Boolean = false, onlyReadMetadata: Boolean = false, -) = WoffFont(this.readAll(), freeze = preload, extName = this.baseName, onlyReadMetadata = onlyReadMetadata) +) = WoffFont(this.readAll(), extName = this.baseName, onlyReadMetadata = onlyReadMetadata) diff --git a/korim/src/commonTest/kotlin/korlibs/image/font/FontTest.kt b/korim/src/commonTest/kotlin/korlibs/image/font/FontTest.kt index 66315d36f5..7ee7979f8e 100644 --- a/korim/src/commonTest/kotlin/korlibs/image/font/FontTest.kt +++ b/korim/src/commonTest/kotlin/korlibs/image/font/FontTest.kt @@ -10,7 +10,6 @@ import korlibs.image.text.* import korlibs.io.async.* import korlibs.io.file.std.* import korlibs.math.geom.* -import korlibs.math.geom.vector.* import kotlin.test.* class FontTest { @@ -145,10 +144,10 @@ class FontTest { @Test fun testReadFont() = suspendTestNoBrowser { - val font1 = resourcesVfs["myfont.ttf"].readTtfFont(preload = true) - val font2 = resourcesVfs["myfont-bug.ttf"].readTtfFont(preload = true) - val font3 = resourcesVfs["myfont-bug2.ttf"].readTtfFont(preload = true) - val font4 = resourcesVfs["myfont-bug3.ttf"].readTtfFont(preload = true) + val font1 = resourcesVfs["myfont.ttf"].readTtfFont() + val font2 = resourcesVfs["myfont-bug.ttf"].readTtfFont() + val font3 = resourcesVfs["myfont-bug2.ttf"].readTtfFont() + val font4 = resourcesVfs["myfont-bug3.ttf"].readTtfFont() //font1.renderTextToBitmap(20.0, "Hello World!", border = 64, nativeRendering = false).bmp.showImageAndWait() //font4.renderTextToBitmap(64.0, "12 Hello World", nativeRendering = true).bmp.showImageAndWait() } @@ -156,7 +155,7 @@ class FontTest { @Test fun testReadOpenTypeFont() = suspendTestNoBrowser { //assertFailsWith { - val font1 = resourcesVfs["helvetica.otf"].readTtfFont(preload = true) + val font1 = resourcesVfs["helvetica.otf"].readTtfFont() logger.debug { "font1=$font1" } //} } diff --git a/korim/src/commonTest/kotlin/korlibs/image/font/TtfCIDFontTest.kt b/korim/src/commonTest/kotlin/korlibs/image/font/TtfCIDFontTest.kt index 87e60b9800..6ec7e95493 100644 --- a/korim/src/commonTest/kotlin/korlibs/image/font/TtfCIDFontTest.kt +++ b/korim/src/commonTest/kotlin/korlibs/image/font/TtfCIDFontTest.kt @@ -53,7 +53,7 @@ class TtfCIDFontTest { @Test fun testReadHeader() = suspendTest { - val font1 = resourcesVfs["helvetica.otf"].readTtfFont(preload = false) + val font1 = resourcesVfs["helvetica.otf"].readTtfFont() val cff = font1._cff assertNotNull(cff) diff --git a/korim/src/darwinMobileMain/kotlin/korlibs/image/format/NativeImageFormatProviderIos.kt b/korim/src/darwinMobileMain/kotlin/korlibs/image/format/NativeImageFormatProviderIos.kt index 94afc74cac..15518b8ca9 100644 --- a/korim/src/darwinMobileMain/kotlin/korlibs/image/format/NativeImageFormatProviderIos.kt +++ b/korim/src/darwinMobileMain/kotlin/korlibs/image/format/NativeImageFormatProviderIos.kt @@ -32,8 +32,8 @@ object UIImageNativeImageFormatProvider : BaseNativeImageFormatProvider() { data class Info(val data: ByteArray, val premultiplied: Boolean) return executeInImageIOWorker { worker -> - worker.execute(TransferMode.SAFE, { Info(if (data.isFrozen) data else data.copyOf().freeze(), premultiplied) }, { info -> - //return run { val info = Info(if (data.isFrozen) data else data.copyOf().freeze(), premultiplied) + worker.execute(TransferMode.SAFE, { Info(data.copyOf(), premultiplied) }, { info -> + //return run { val info = Info(data.copyOf(), premultiplied) val data = info.data val premultiplied = info.premultiplied val nsdata: NSData = data.usePinned { pin -> NSData.dataWithBytes(pin.addressOf(0), data.size.convert()) } diff --git a/korim/src/macosMain/kotlin/korlibs.image.format/ImageDecoder.kt b/korim/src/macosMain/kotlin/korlibs.image.format/ImageDecoder.kt index e005e11d1f..8b5e7ce7eb 100644 --- a/korim/src/macosMain/kotlin/korlibs.image.format/ImageDecoder.kt +++ b/korim/src/macosMain/kotlin/korlibs.image.format/ImageDecoder.kt @@ -21,7 +21,7 @@ object NSNativeImageFormatProvider : BaseNativeImageFormatProvider() { return executeInImageIOWorker { worker -> worker.execute( TransferMode.SAFE, - { Info(if (data.isFrozen) data else data.copyOf().freeze(), premultiplied) }, + { Info(data.copyOf(), premultiplied) }, { info -> val data = info.data val premultiplied = info.premultiplied diff --git a/korio/src/commonTest/kotlin/korlibs/io/compression/MyInflaterTest.kt b/korio/src/commonTest/kotlin/korlibs/io/compression/MyInflaterTest.kt index 26a248089b..e05e8ea69e 100644 --- a/korio/src/commonTest/kotlin/korlibs/io/compression/MyInflaterTest.kt +++ b/korio/src/commonTest/kotlin/korlibs/io/compression/MyInflaterTest.kt @@ -54,7 +54,7 @@ class MyInflaterTest { // On Windows new memory manager, there is a crash here in tests in CI. Happens frequently but it is not consistently. // - https://youtrack.jetbrains.com/issue/KT-52651/Native-korio-tests-crash-on-Windows-with-new-memory-manager-enabled // - https://discord.com/channels/728582275884908604/728616376910217258/1011220692202700841 - if (Platform.os.isWindows && Platform.runtime.isNative && Platform.hasMultithreadedSharedHeap) return + if (Platform.os.isWindows && Platform.runtime.isNative) return val compressed = "ED C2 31 0D 00 00 00 02 A0 4A 06 B2 7F 0E 53 F8 31 68 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9C 0D".unhexIgnoreSpaces val result = compressed.uncompress(Deflate) diff --git a/korio/src/concurrentMain/kotlin/korlibs/io/concurrent/createSingleThreadedDispatcher.kt b/korio/src/concurrentMain/kotlin/korlibs/io/concurrent/createSingleThreadedDispatcher.kt index aeb8403379..73d4dc4df7 100644 --- a/korio/src/concurrentMain/kotlin/korlibs/io/concurrent/createSingleThreadedDispatcher.kt +++ b/korio/src/concurrentMain/kotlin/korlibs/io/concurrent/createSingleThreadedDispatcher.kt @@ -1,17 +1,9 @@ package korlibs.io.concurrent -import korlibs.memory.Platform import kotlinx.coroutines.* -import kotlin.coroutines.* @OptIn(ExperimentalCoroutinesApi::class) actual fun Dispatchers.createFixedThreadDispatcher(name: String, threadCount: Int): CoroutineDispatcher { //println("Dispatchers.createSingleThreadedDispatcher['$name'] : Platform.hasMultithreadedSharedHeap=${Platform.hasMultithreadedSharedHeap}") - if (Platform.hasMultithreadedSharedHeap) { - return newFixedThreadPoolContext(threadCount, name) - //return newSingleThreadContext(name) - //return createRedirectedDispatcher(name, Dispatchers.Default) - } else { - return createRedirectedDispatcher(name, Dispatchers.Default) - } + return newFixedThreadPoolContext(threadCount, name) } diff --git a/korio/src/nativeTest/kotlin/korlibs/io/internal/TempBytesNativeTest.kt b/korio/src/nativeTest/kotlin/korlibs/io/internal/TempBytesNativeTest.kt index 5b92a156ec..e08c6d6b65 100644 --- a/korio/src/nativeTest/kotlin/korlibs/io/internal/TempBytesNativeTest.kt +++ b/korio/src/nativeTest/kotlin/korlibs/io/internal/TempBytesNativeTest.kt @@ -13,7 +13,7 @@ class TempBytesNativeTest { fun test() = suspendTest { val worker = Worker.start() try { - val result = worker.execute(TransferMode.SAFE, { 0.freeze() }) { + val result = worker.execute(TransferMode.SAFE, { 0 }) { runBlocking { val memory = MemorySyncStream().toAsync() memory.write16LE(11) @@ -22,7 +22,7 @@ class TempBytesNativeTest { val mem = ByteArray(1024) { (it % 16).toByte() } val mem2 = mem.compress(ZLib).uncompress(ZLib) - Triple(memory.readS16LE(), memory.size(), mem.contentEquals(mem2)).freeze() + Triple(memory.readS16LE(), memory.size(), mem.contentEquals(mem2)) } }.await() assertEquals(Triple(11, 2L, true), result)