Unverified Commit 000e45b8 authored by Nikolay Igotti's avatar Nikolay Igotti Committed by GitHub

Commoniazation, part 2. (#154)

parent a6cda39e
...@@ -79,10 +79,10 @@ class AnimationFrameInfo( ...@@ -79,10 +79,10 @@ class AnimationFrameInfo(
requiredFrame, requiredFrame,
duration, duration,
fullyReceived, fullyReceived,
ColorAlphaType.values().get(alphaTypeOrdinal), ColorAlphaType.values()[alphaTypeOrdinal],
hasAlphaWithinBounds, hasAlphaWithinBounds,
AnimationDisposalMode.values()[disposalMethodOrdinal], AnimationDisposalMode.values()[disposalMethodOrdinal],
BlendMode.values().get(blendModeOrdinal), BlendMode.values()[blendModeOrdinal],
frameRect frameRect
) )
/** /**
...@@ -251,16 +251,16 @@ class AnimationFrameInfo( ...@@ -251,16 +251,16 @@ class AnimationFrameInfo(
if (isHasAlphaWithinBounds != other.isHasAlphaWithinBounds) return false if (isHasAlphaWithinBounds != other.isHasAlphaWithinBounds) return false
val `this$_alphaType`: Any = alphaType val `this$_alphaType`: Any = alphaType
val `other$_alphaType`: Any = other.alphaType val `other$_alphaType`: Any = other.alphaType
if (if (`this$_alphaType` == null) `other$_alphaType` != null else `this$_alphaType` != `other$_alphaType`) return false if (`this$_alphaType` != `other$_alphaType`) return false
val `this$_disposalMethod`: Any = disposalMethod val `this$_disposalMethod`: Any = disposalMethod
val `other$_disposalMethod`: Any = other.disposalMethod val `other$_disposalMethod`: Any = other.disposalMethod
if (if (`this$_disposalMethod` == null) `other$_disposalMethod` != null else `this$_disposalMethod` != `other$_disposalMethod`) return false if (`this$_disposalMethod` != `other$_disposalMethod`) return false
val `this$_blendMode`: Any = blendMode val `this$_blendMode`: Any = blendMode
val `other$_blendMode`: Any = other.blendMode val `other$_blendMode`: Any = other.blendMode
if (if (`this$_blendMode` == null) `other$_blendMode` != null else `this$_blendMode` != `other$_blendMode`) return false if (`this$_blendMode` != `other$_blendMode`) return false
val `this$_frameRect`: Any = frameRect val `this$_frameRect`: Any = frameRect
val `other$_frameRect`: Any = other.frameRect val `other$_frameRect`: Any = other.frameRect
return if (if (`this$_frameRect` == null) `other$_frameRect` != null else `this$_frameRect` != `other$_frameRect`) false else true return `this$_frameRect` == `other$_frameRect`
} }
protected fun canEqual(other: Any?): Boolean { protected fun canEqual(other: Any?): Boolean {
...@@ -275,18 +275,18 @@ class AnimationFrameInfo( ...@@ -275,18 +275,18 @@ class AnimationFrameInfo(
result = result * PRIME + if (isFullyReceived) 79 else 97 result = result * PRIME + if (isFullyReceived) 79 else 97
result = result * PRIME + if (isHasAlphaWithinBounds) 79 else 97 result = result * PRIME + if (isHasAlphaWithinBounds) 79 else 97
val `$_alphaType`: Any = alphaType val `$_alphaType`: Any = alphaType
result = result * PRIME + (`$_alphaType`?.hashCode() ?: 43) result = result * PRIME + (`$_alphaType`.hashCode())
val `$_disposalMethod`: Any = disposalMethod val `$_disposalMethod`: Any = disposalMethod
result = result * PRIME + (`$_disposalMethod`?.hashCode() ?: 43) result = result * PRIME + `$_disposalMethod`.hashCode()
val `$_blendMode`: Any = blendMode val `$_blendMode`: Any = blendMode
result = result * PRIME + (`$_blendMode`?.hashCode() ?: 43) result = result * PRIME + `$_blendMode`.hashCode()
val `$_frameRect`: Any = frameRect val `$_frameRect`: Any = frameRect
result = result * PRIME + (`$_frameRect`?.hashCode() ?: 43) result = result * PRIME + `$_frameRect`.hashCode()
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "AnimationFrameInfo(_requiredFrame=" + requiredFrame + ", _duration=" + duration + ", _fullyReceived=" + isFullyReceived + ", _alphaType=" + alphaType + ", _hasAlphaWithinBounds=" + isHasAlphaWithinBounds + ", _disposalMethod=" + disposalMethod + ", _blendMode=" + blendMode + ", _frameRect=" + frameRect + ")" return "AnimationFrameInfo(_requiredFrame=$requiredFrame, _duration=$duration, _fullyReceived=$isFullyReceived, _alphaType=$alphaType, _hasAlphaWithinBounds=$isHasAlphaWithinBounds, _disposalMethod=$disposalMethod, _blendMode=$blendMode, _frameRect=$frameRect)"
} }
/** /**
......
...@@ -3,6 +3,7 @@ package org.jetbrains.skia ...@@ -3,6 +3,7 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.Library.Companion.staticLoad import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.Managed import org.jetbrains.skia.impl.Managed
import org.jetbrains.skia.impl.Stats import org.jetbrains.skia.impl.Stats
import kotlin.jvm.JvmStatic
class BackendRenderTarget internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR) { class BackendRenderTarget internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR) {
companion object { companion object {
......
...@@ -2,9 +2,9 @@ package org.jetbrains.skia ...@@ -2,9 +2,9 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.Library.Companion.staticLoad import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.Managed import org.jetbrains.skia.impl.Managed
import org.jetbrains.skia.impl.Native
import org.jetbrains.skia.impl.Stats import org.jetbrains.skia.impl.Stats
import java.lang.ref.Reference import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
/** /**
* *
...@@ -190,7 +190,7 @@ import java.lang.ref.Reference ...@@ -190,7 +190,7 @@ import java.lang.ref.Reference
* with punctuation or other non-word characters. * with punctuation or other non-word characters.
</blockquote> * </blockquote> *
*/ */
class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR), Cloneable { class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR) {
companion object { companion object {
/** /**
* DONE is returned by previous() and next() after all valid * DONE is returned by previous() and next() after all valid
...@@ -255,7 +255,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -255,7 +255,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
/** /**
* Returns a new BreakIterator instance for character breaks for the default locale. * Returns a new BreakIterator instance for character breaks for the default locale.
*/ */
@JvmOverloads
fun makeCharacterInstance(locale: String? = null): BreakIterator { fun makeCharacterInstance(locale: String? = null): BreakIterator {
Stats.onNativeCall() Stats.onNativeCall()
return BreakIterator(_nMake(0, locale)) // UBRK_CHARACTER return BreakIterator(_nMake(0, locale)) // UBRK_CHARACTER
...@@ -266,7 +265,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -266,7 +265,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
/** /**
* Returns a new BreakIterator instance for word breaks for the default locale. * Returns a new BreakIterator instance for word breaks for the default locale.
*/ */
@JvmOverloads
fun makeWordInstance(locale: String? = null): BreakIterator { fun makeWordInstance(locale: String? = null): BreakIterator {
Stats.onNativeCall() Stats.onNativeCall()
return BreakIterator(_nMake(1, locale)) // UBRK_WORD return BreakIterator(_nMake(1, locale)) // UBRK_WORD
...@@ -277,7 +275,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -277,7 +275,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
/** /**
* Returns a new BreakIterator instance for line breaks for the default locale. * Returns a new BreakIterator instance for line breaks for the default locale.
*/ */
@JvmOverloads
fun makeLineInstance(locale: String? = null): BreakIterator { fun makeLineInstance(locale: String? = null): BreakIterator {
Stats.onNativeCall() Stats.onNativeCall()
return BreakIterator(_nMake(2, locale)) // UBRK_LINE return BreakIterator(_nMake(2, locale)) // UBRK_LINE
...@@ -288,7 +285,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -288,7 +285,6 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
/** /**
* Returns a new BreakIterator instance for sentence breaks for the default locale. * Returns a new BreakIterator instance for sentence breaks for the default locale.
*/ */
@JvmOverloads
fun makeSentenceInstance(locale: String? = null): BreakIterator { fun makeSentenceInstance(locale: String? = null): BreakIterator {
Stats.onNativeCall() Stats.onNativeCall()
return BreakIterator(_nMake(3, locale)) // UBRK_SENTENCE return BreakIterator(_nMake(3, locale)) // UBRK_SENTENCE
...@@ -323,7 +319,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -323,7 +319,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
/** /**
* Create a copy of this iterator * Create a copy of this iterator
*/ */
public override fun clone(): BreakIterator { fun clone(): BreakIterator {
Stats.onNativeCall() Stats.onNativeCall()
return BreakIterator(_nClone(_ptr)) return BreakIterator(_nClone(_ptr))
} }
...@@ -342,7 +338,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -342,7 +338,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nCurrent(_ptr) _nCurrent(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -358,7 +354,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -358,7 +354,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nNext(_ptr) _nNext(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -402,7 +398,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -402,7 +398,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nPrevious(_ptr) _nPrevious(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -414,7 +410,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -414,7 +410,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nFirst(_ptr) _nFirst(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -426,7 +422,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -426,7 +422,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nLast(_ptr) _nLast(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -443,7 +439,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -443,7 +439,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nPreceding(_ptr, offset) _nPreceding(_ptr, offset)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -460,7 +456,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -460,7 +456,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nFollowing(_ptr, offset) _nFollowing(_ptr, offset)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -472,7 +468,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -472,7 +468,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nIsBoundary(_ptr, offset) _nIsBoundary(_ptr, offset)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
...@@ -493,7 +489,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -493,7 +489,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nGetRuleStatus(_ptr) _nGetRuleStatus(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
/** /**
...@@ -511,7 +507,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -511,7 +507,7 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats.onNativeCall() Stats.onNativeCall()
_nGetRuleStatuses(_ptr) _nGetRuleStatuses(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
/** /**
...@@ -521,10 +517,10 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol ...@@ -521,10 +517,10 @@ class BreakIterator internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
try { try {
Stats.onNativeCall() Stats.onNativeCall()
_text = U16String(text) _text = U16String(text)
_nSetText(_ptr, Native.Companion.getPtr(_text)) _nSetText(_ptr, getPtr(_text))
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
Reference.reachabilityFence(_text) reachabilityBarrier(_text)
} }
} }
......
...@@ -2,9 +2,9 @@ package org.jetbrains.skia ...@@ -2,9 +2,9 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.Library.Companion.staticLoad import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.RefCnt import org.jetbrains.skia.impl.RefCnt
import org.jetbrains.skia.impl.Native
import org.jetbrains.skia.impl.Stats import org.jetbrains.skia.impl.Stats
import java.lang.ref.Reference import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
class ColorFilter : RefCnt { class ColorFilter : RefCnt {
companion object { companion object {
...@@ -13,13 +13,13 @@ class ColorFilter : RefCnt { ...@@ -13,13 +13,13 @@ class ColorFilter : RefCnt {
Stats.onNativeCall() Stats.onNativeCall()
ColorFilter( ColorFilter(
_nMakeComposed( _nMakeComposed(
Native.Companion.getPtr(outer), getPtr(outer),
Native.Companion.getPtr(inner) getPtr(inner)
) )
) )
} finally { } finally {
Reference.reachabilityFence(outer) reachabilityBarrier(outer)
Reference.reachabilityFence(inner) reachabilityBarrier(inner)
} }
} }
...@@ -43,13 +43,13 @@ class ColorFilter : RefCnt { ...@@ -43,13 +43,13 @@ class ColorFilter : RefCnt {
ColorFilter( ColorFilter(
_nMakeLerp( _nMakeLerp(
t, t,
Native.Companion.getPtr(dst), getPtr(dst),
Native.Companion.getPtr(src) getPtr(src)
) )
) )
} finally { } finally {
Reference.reachabilityFence(dst) reachabilityBarrier(dst)
Reference.reachabilityFence(src) reachabilityBarrier(src)
} }
} }
...@@ -62,20 +62,20 @@ class ColorFilter : RefCnt { ...@@ -62,20 +62,20 @@ class ColorFilter : RefCnt {
} }
fun makeTable(table: ByteArray): ColorFilter { fun makeTable(table: ByteArray): ColorFilter {
assert(table.size == 256) { "Expected 256 elements, got " + table.size } require(table.size == 256) { "Expected 256 elements, got " + table.size }
return ColorFilter(_nMakeTable(table)) return ColorFilter(_nMakeTable(table))
} }
fun makeTableARGB(a: ByteArray?, r: ByteArray?, g: ByteArray?, b: ByteArray?): ColorFilter { fun makeTableARGB(a: ByteArray?, r: ByteArray?, g: ByteArray?, b: ByteArray?): ColorFilter {
assert(a == null || a.size == 256) { "Expected 256 elements in a[], got " + a!!.size } require(a == null || a.size == 256) { "Expected 256 elements in a[], got " + a!!.size }
assert(r == null || r.size == 256) { "Expected 256 elements in r[], got " + r!!.size } require(r == null || r.size == 256) { "Expected 256 elements in r[], got " + r!!.size }
assert(g == null || g.size == 256) { "Expected 256 elements in g[], got " + g!!.size } require(g == null || g.size == 256) { "Expected 256 elements in g[], got " + g!!.size }
assert(b == null || b.size == 256) { "Expected 256 elements in b[], got " + b!!.size } require(b == null || b.size == 256) { "Expected 256 elements in b[], got " + b!!.size }
return ColorFilter(_nMakeTableARGB(a, r, g, b)) return ColorFilter(_nMakeTableARGB(a, r, g, b))
} }
fun makeOverdraw(colors: IntArray): ColorFilter { fun makeOverdraw(colors: IntArray): ColorFilter {
assert(colors.size == 6) { "Expected 6 elements, got " + colors.size } require(colors.size == 6) { "Expected 6 elements, got " + colors.size }
return ColorFilter(_nMakeOverdraw(colors[0], colors[1], colors[2], colors[3], colors[4], colors[5])) return ColorFilter(_nMakeOverdraw(colors[0], colors[1], colors[2], colors[3], colors[4], colors[5]))
} }
......
...@@ -47,13 +47,13 @@ class ColorInfo(colorType: ColorType, alphaType: ColorAlphaType, colorSpace: Col ...@@ -47,13 +47,13 @@ class ColorInfo(colorType: ColorType, alphaType: ColorAlphaType, colorSpace: Col
if (!other.canEqual(this as Any)) return false if (!other.canEqual(this as Any)) return false
val `this$_colorType`: Any = colorType val `this$_colorType`: Any = colorType
val `other$_colorType`: Any = other.colorType val `other$_colorType`: Any = other.colorType
if (if (`this$_colorType` == null) `other$_colorType` != null else `this$_colorType` != `other$_colorType`) return false if (`this$_colorType` != `other$_colorType`) return false
val `this$_alphaType`: Any = alphaType val `this$_alphaType`: Any = alphaType
val `other$_alphaType`: Any = other.alphaType val `other$_alphaType`: Any = other.alphaType
if (if (`this$_alphaType` == null) `other$_alphaType` != null else `this$_alphaType` != `other$_alphaType`) return false if (`this$_alphaType` != `other$_alphaType`) return false
val `this$_colorSpace`: Any? = colorSpace val `this$_colorSpace`: Any? = colorSpace
val `other$_colorSpace`: Any? = other.colorSpace val `other$_colorSpace`: Any? = other.colorSpace
return if (if (`this$_colorSpace` == null) `other$_colorSpace` != null else `this$_colorSpace` != `other$_colorSpace`) false else true return !if (`this$_colorSpace` == null) `other$_colorSpace` != null else `this$_colorSpace` != `other$_colorSpace`
} }
protected fun canEqual(other: Any?): Boolean { protected fun canEqual(other: Any?): Boolean {
...@@ -64,16 +64,16 @@ class ColorInfo(colorType: ColorType, alphaType: ColorAlphaType, colorSpace: Col ...@@ -64,16 +64,16 @@ class ColorInfo(colorType: ColorType, alphaType: ColorAlphaType, colorSpace: Col
val PRIME = 59 val PRIME = 59
var result = 1 var result = 1
val `$_colorType`: Any = colorType val `$_colorType`: Any = colorType
result = result * PRIME + (`$_colorType`?.hashCode() ?: 43) result = result * PRIME + `$_colorType`.hashCode()
val `$_alphaType`: Any = alphaType val `$_alphaType`: Any = alphaType
result = result * PRIME + (`$_alphaType`?.hashCode() ?: 43) result = result * PRIME + `$_alphaType`.hashCode()
val `$_colorSpace`: Any? = colorSpace val `$_colorSpace`: Any? = colorSpace
result = result * PRIME + (`$_colorSpace`?.hashCode() ?: 43) result = result * PRIME + `$_colorSpace`.hashCode()
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "ColorInfo(_colorType=" + colorType + ", _alphaType=" + alphaType + ", _colorSpace=" + colorSpace + ")" return "ColorInfo(_colorType=$colorType, _alphaType=$alphaType, _colorSpace=$colorSpace)"
} }
fun withColorType(_colorType: ColorType): ColorInfo { fun withColorType(_colorType: ColorType): ColorInfo {
......
package org.jetbrains.skia package org.jetbrains.skia
import java.util.*
class ColorMatrix(vararg mat: Float) { class ColorMatrix(vararg mat: Float) {
val mat: FloatArray val mat: FloatArray
override fun equals(o: Any?): Boolean { override fun equals(o: Any?): Boolean {
...@@ -9,7 +7,7 @@ class ColorMatrix(vararg mat: Float) { ...@@ -9,7 +7,7 @@ class ColorMatrix(vararg mat: Float) {
if (o !is ColorMatrix) return false if (o !is ColorMatrix) return false
val other = o val other = o
if (!other.canEqual(this as Any)) return false if (!other.canEqual(this as Any)) return false
return if (!Arrays.equals(mat, other.mat)) false else true return mat.contentEquals(other.mat)
} }
protected fun canEqual(other: Any?): Boolean { protected fun canEqual(other: Any?): Boolean {
...@@ -19,16 +17,16 @@ class ColorMatrix(vararg mat: Float) { ...@@ -19,16 +17,16 @@ class ColorMatrix(vararg mat: Float) {
override fun hashCode(): Int { override fun hashCode(): Int {
val PRIME = 59 val PRIME = 59
var result = 1 var result = 1
result = result * PRIME + Arrays.hashCode(mat) result = result * PRIME + mat.contentHashCode()
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "ColorMatrix(_mat=" + Arrays.toString(mat) + ")" return "ColorMatrix(_mat=$mat)"
} }
init { init {
assert(mat.size == 20) { (if ("Expected 20 elements, got $mat" == null) null else mat.size)!! } require(mat.size == 20) { "Expected 20 elements, got $mat" }
this.mat = mat this.mat = mat
} }
} }
\ No newline at end of file
...@@ -3,7 +3,8 @@ package org.jetbrains.skia ...@@ -3,7 +3,8 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.Library.Companion.staticLoad import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.Managed import org.jetbrains.skia.impl.Managed
import org.jetbrains.skia.impl.Stats import org.jetbrains.skia.impl.Stats
import java.lang.ref.Reference import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
class ColorSpace : Managed { class ColorSpace : Managed {
companion object { companion object {
...@@ -40,8 +41,8 @@ class ColorSpace : Managed { ...@@ -40,8 +41,8 @@ class ColorSpace : Managed {
) )
) )
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
Reference.reachabilityFence(to) reachabilityBarrier(to)
} }
} }
...@@ -57,7 +58,7 @@ class ColorSpace : Managed { ...@@ -57,7 +58,7 @@ class ColorSpace : Managed {
Stats.onNativeCall() Stats.onNativeCall()
_nIsGammaCloseToSRGB(_ptr) _nIsGammaCloseToSRGB(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
/** /**
...@@ -68,7 +69,7 @@ class ColorSpace : Managed { ...@@ -68,7 +69,7 @@ class ColorSpace : Managed {
Stats.onNativeCall() Stats.onNativeCall()
_nIsGammaLinear(_ptr) _nIsGammaLinear(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
/** /**
...@@ -90,7 +91,7 @@ class ColorSpace : Managed { ...@@ -90,7 +91,7 @@ class ColorSpace : Managed {
Stats.onNativeCall() Stats.onNativeCall()
_nIsSRGB(_ptr) _nIsSRGB(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
private object _FinalizerHolder { private object _FinalizerHolder {
......
package org.jetbrains.skia package org.jetbrains.skia
import kotlin.jvm.JvmStatic
/** /**
* Describes how pixel bits encode color. A pixel may be an alpha mask, a * Describes how pixel bits encode color. A pixel may be an alpha mask, a
* grayscale, RGB, or ARGB. * grayscale, RGB, or ARGB.
...@@ -314,5 +316,19 @@ enum class ColorType { ...@@ -314,5 +316,19 @@ enum class ColorType {
* Native ARGB 32-bit encoding * Native ARGB 32-bit encoding
*/ */
var N32 = BGRA_8888 var N32 = BGRA_8888
@JvmStatic external fun _nIsAlwaysOpaque(value: Int): Boolean
} }
}
\ No newline at end of file /**
* Returns true if ColorType always decodes alpha to 1.0, making the pixel
* fully opaque. If true, ColorType does not reserve bits to encode alpha.
*
* @return true if alpha is always set to 1.0
*/
val isAlwaysOpaque: Boolean
get() {
return _nIsAlwaysOpaque(ordinal)
}
}
...@@ -3,7 +3,8 @@ package org.jetbrains.skia ...@@ -3,7 +3,8 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.Library.Companion.staticLoad import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.RefCnt import org.jetbrains.skia.impl.RefCnt
import org.jetbrains.skia.impl.Stats import org.jetbrains.skia.impl.Stats
import java.lang.ref.Reference import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
class DirectContext internal constructor(ptr: Long) : RefCnt(ptr) { class DirectContext internal constructor(ptr: Long) : RefCnt(ptr) {
companion object { companion object {
...@@ -114,7 +115,7 @@ class DirectContext internal constructor(ptr: Long) : RefCnt(ptr) { ...@@ -114,7 +115,7 @@ class DirectContext internal constructor(ptr: Long) : RefCnt(ptr) {
Stats.onNativeCall() Stats.onNativeCall()
_nAbandon(_ptr) _nAbandon(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
} }
\ No newline at end of file
...@@ -15,8 +15,4 @@ enum class GLBackendState(internal val _bit: Int) { ...@@ -15,8 +15,4 @@ enum class GLBackendState(internal val _bit: Int) {
1 shl 8 1 shl 8
), ),
FIXED_FUNCTION(1 shl 9), MISC(1 shl 10), PATH_RENDERING(1 shl 11); FIXED_FUNCTION(1 shl 9), MISC(1 shl 10), PATH_RENDERING(1 shl 11);
companion object {
internal val _values = values()
}
} }
\ No newline at end of file
package org.jetbrains.skia package org.jetbrains.skia
import kotlin.jvm.JvmStatic
class IRect internal constructor(val left: Int, val top: Int, val right: Int, val bottom: Int) { class IRect internal constructor(val left: Int, val top: Int, val right: Int, val bottom: Int) {
val width: Int val width: Int
get() = right - left get() = right - left
...@@ -8,9 +10,9 @@ class IRect internal constructor(val left: Int, val top: Int, val right: Int, va ...@@ -8,9 +10,9 @@ class IRect internal constructor(val left: Int, val top: Int, val right: Int, va
fun intersect(other: IRect): IRect? { fun intersect(other: IRect): IRect? {
return if (right <= other.left || other.right <= left || bottom <= other.top || other.bottom <= top) null else IRect( return if (right <= other.left || other.right <= left || bottom <= other.top || other.bottom <= top) null else IRect(
Math.max(left, other.left), Math.max(top, other.top), Math.min( maxOf(left, other.left), maxOf(top, other.top), minOf(
right, other.right right, other.right
), Math.min(bottom, other.bottom) ), minOf(bottom, other.bottom)
) )
} }
......
package org.jetbrains.skia package org.jetbrains.skia
import java.util.* import kotlin.jvm.JvmStatic
import kotlin.math.abs
class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val radii: FloatArray) : class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val radii: FloatArray) :
Rect(l, t, r, b) { Rect(l, t, r, b) {
...@@ -12,28 +13,26 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad ...@@ -12,28 +13,26 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad
break break
} }
} }
return if (becomesRect) Rect.Companion.makeLTRB( return if (becomesRect) makeLTRB(
left - spread, left - spread,
top - spread, top - spread,
Math.max(left - spread, right + spread), maxOf(left - spread, right + spread),
Math.max(top - spread, bottom + spread) maxOf(top - spread, bottom + spread)
) else { ) else {
val radii = Arrays.copyOf(radii, radii.size) val radii = radii.copyOf()
for (i in radii.indices) radii[i] = Math.max(0.0f, radii[i] + spread) for (i in radii.indices) radii[i] = maxOf(0.0f, radii[i] + spread)
RRect( RRect(
left - spread, left - spread,
top - spread, top - spread,
Math.max(left - spread, right + spread), maxOf(left - spread, right + spread),
Math.max(top - spread, bottom + spread), maxOf(top - spread, bottom + spread),
radii radii
) )
} }
} }
override fun toString(): String { override fun toString(): String {
return "RRect(_left=" + left + ", _top=" + top + ", _right=" + right + ", _bottom=" + bottom + ", _radii=" + Arrays.toString( return "RRect(_left=$left, _top=$top, _right=$right, _bottom=$bottom, _radii=$radii)"
radii
) + ")"
} }
override fun equals(o: Any?): Boolean { override fun equals(o: Any?): Boolean {
...@@ -42,7 +41,7 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad ...@@ -42,7 +41,7 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad
val other = o val other = o
if (!other.canEqual(this as Any)) return false if (!other.canEqual(this as Any)) return false
if (!super.equals(o)) return false if (!super.equals(o)) return false
return if (!Arrays.equals(radii, other.radii)) false else true return radii.contentEquals(other.radii)
} }
override fun canEqual(other: Any?): Boolean { override fun canEqual(other: Any?): Boolean {
...@@ -52,7 +51,7 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad ...@@ -52,7 +51,7 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad
override fun hashCode(): Int { override fun hashCode(): Int {
val PRIME = 59 val PRIME = 59
var result = super.hashCode() var result = super.hashCode()
result = result * PRIME + Arrays.hashCode(radii) result = result * PRIME + radii.contentHashCode()
return result return result
} }
...@@ -101,11 +100,11 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad ...@@ -101,11 +100,11 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad
} }
fun makeOvalLTRB(l: Float, t: Float, r: Float, b: Float): RRect { fun makeOvalLTRB(l: Float, t: Float, r: Float, b: Float): RRect {
return RRect(l, t, r, b, floatArrayOf(Math.abs(r - l) / 2.0f, Math.abs(b - t) / 2.0f)) return RRect(l, t, r, b, floatArrayOf(abs(r - l) / 2.0f, abs(b - t) / 2.0f))
} }
fun makePillLTRB(l: Float, t: Float, r: Float, b: Float): RRect { fun makePillLTRB(l: Float, t: Float, r: Float, b: Float): RRect {
return RRect(l, t, r, b, floatArrayOf(Math.min(Math.abs(r - l), Math.abs(t - b)) / 2.0f)) return RRect(l, t, r, b, floatArrayOf(minOf(abs(r - l), abs(t - b)) / 2.0f))
} }
fun makeXYWH(l: Float, t: Float, w: Float, h: Float, radius: Float): RRect { fun makeXYWH(l: Float, t: Float, w: Float, h: Float, radius: Float): RRect {
...@@ -151,7 +150,7 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad ...@@ -151,7 +150,7 @@ class RRect internal constructor(l: Float, t: Float, r: Float, b: Float, val rad
} }
fun makePillXYWH(l: Float, t: Float, w: Float, h: Float): RRect { fun makePillXYWH(l: Float, t: Float, w: Float, h: Float): RRect {
return RRect(l, t, l + w, t + h, floatArrayOf(Math.min(w, h) / 2.0f)) return RRect(l, t, l + w, t + h, floatArrayOf(minOf(w, h) / 2.0f))
} }
} }
} }
\ No newline at end of file
package org.jetbrains.skia package org.jetbrains.skia
import kotlin.jvm.JvmStatic
open class Rect internal constructor(val left: Float, val top: Float, val right: Float, val bottom: Float) { open class Rect internal constructor(val left: Float, val top: Float, val right: Float, val bottom: Float) {
val width: Float val width: Float
get() = right - left get() = right - left
...@@ -8,11 +10,11 @@ open class Rect internal constructor(val left: Float, val top: Float, val right: ...@@ -8,11 +10,11 @@ open class Rect internal constructor(val left: Float, val top: Float, val right:
fun intersect(other: Rect): Rect? { fun intersect(other: Rect): Rect? {
return if (right <= other.left || other.right <= left || bottom <= other.top || other.bottom <= top) null else Rect( return if (right <= other.left || other.right <= left || bottom <= other.top || other.bottom <= top) null else Rect(
Math.max( maxOf(
left, other.left left, other.left
), Math.max(top, other.top), Math.min( ), maxOf(top, other.top), minOf(
right, other.right right, other.right
), Math.min(bottom, other.bottom) ), minOf(bottom, other.bottom)
) )
} }
...@@ -38,11 +40,11 @@ open class Rect internal constructor(val left: Float, val top: Float, val right: ...@@ -38,11 +40,11 @@ open class Rect internal constructor(val left: Float, val top: Float, val right:
open fun inflate(spread: Float): Rect { open fun inflate(spread: Float): Rect {
return if (spread <= 0) makeLTRB( return if (spread <= 0) makeLTRB(
left - spread, top - spread, Math.max( left - spread, top - spread, maxOf(
left - spread, right + spread left - spread, right + spread
), Math.max(top - spread, bottom + spread) ), maxOf(top - spread, bottom + spread)
) else RRect.Companion.makeLTRB( ) else RRect.makeLTRB(
left - spread, top - spread, Math.max(left - spread, right + spread), Math.max( left - spread, top - spread, maxOf(left - spread, right + spread), maxOf(
top - spread, bottom + spread top - spread, bottom + spread
), spread ), spread
) )
...@@ -56,10 +58,10 @@ open class Rect internal constructor(val left: Float, val top: Float, val right: ...@@ -56,10 +58,10 @@ open class Rect internal constructor(val left: Float, val top: Float, val right:
if (o !is Rect) return false if (o !is Rect) return false
val other = o val other = o
if (!other.canEqual(this as Any)) return false if (!other.canEqual(this as Any)) return false
if (java.lang.Float.compare(left, other.left) != 0) return false if (left.compareTo(other.left) != 0) return false
if (java.lang.Float.compare(top, other.top) != 0) return false if (top.compareTo(other.top) != 0) return false
if (java.lang.Float.compare(right, other.right) != 0) return false if (right.compareTo(other.right) != 0) return false
return if (java.lang.Float.compare(bottom, other.bottom) != 0) false else true return bottom.compareTo(other.bottom) == 0
} }
protected open fun canEqual(other: Any?): Boolean { protected open fun canEqual(other: Any?): Boolean {
...@@ -69,15 +71,15 @@ open class Rect internal constructor(val left: Float, val top: Float, val right: ...@@ -69,15 +71,15 @@ open class Rect internal constructor(val left: Float, val top: Float, val right:
override fun hashCode(): Int { override fun hashCode(): Int {
val PRIME = 59 val PRIME = 59
var result = 1 var result = 1
result = result * PRIME + java.lang.Float.floatToIntBits(left) result = result * PRIME + left.toBits()
result = result * PRIME + java.lang.Float.floatToIntBits(top) result = result * PRIME + top.toBits()
result = result * PRIME + java.lang.Float.floatToIntBits(right) result = result * PRIME + right.toBits()
result = result * PRIME + java.lang.Float.floatToIntBits(bottom) result = result * PRIME + bottom.toBits()
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "Rect(_left=" + left + ", _top=" + top + ", _right=" + right + ", _bottom=" + bottom + ")" return "Rect(_left=$left, _top=$top, _right=$right, _bottom=$bottom)"
} }
companion object { companion object {
......
...@@ -3,7 +3,8 @@ package org.jetbrains.skia ...@@ -3,7 +3,8 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.Library.Companion.staticLoad import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.Managed import org.jetbrains.skia.impl.Managed
import org.jetbrains.skia.impl.Stats import org.jetbrains.skia.impl.Stats
import java.lang.ref.Reference import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
/** /**
* Kotlin mirror of std::vector&lt;jchar&gt; (UTF-16) * Kotlin mirror of std::vector&lt;jchar&gt; (UTF-16)
...@@ -28,7 +29,7 @@ class U16String internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder. ...@@ -28,7 +29,7 @@ class U16String internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats.onNativeCall() Stats.onNativeCall()
_nToString(_ptr) _nToString(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) reachabilityBarrier(this)
} }
} }
......
package org.jetbrains.skia.impl
expect class Library {
companion object {
fun staticLoad()
}
}
package org.jetbrains.skia.impl
expect abstract class Managed(ptr: Long, finalizer: Long, managed: Boolean = true) : Native {
open fun close()
}
\ No newline at end of file
package org.jetbrains.skia.impl
expect abstract class Native(ptr: Long) {
var _ptr: Long
companion object {
fun getPtr(n: Native?): Long
}
}
expect fun reachabilityBarrier(obj: Any?)
\ No newline at end of file
package org.jetbrains.skia.impl
expect abstract class RefCnt : Managed {
protected constructor(ptr: Long)
protected constructor(ptr: Long, allowClose: Boolean)
}
\ No newline at end of file
package org.jetbrains.skia.impl
expect object Stats {
fun onNativeCall()
fun onAllocated(className: String)
fun onDeallocated(className: String)
}
\ No newline at end of file
package org.jetbrains.skia
class Extensions {
companion object {
@JvmStatic
external fun _nIsAlwaysOpaque(value: Int): Boolean
}
}
/**
* Returns true if ColorType always decodes alpha to 1.0, making the pixel
* fully opaque. If true, ColorType does not reserve bits to encode alpha.
*
* @return true if alpha is always set to 1.0
*/
val ColorType.isAlwaysOpaque: Boolean
get() {
return Extensions._nIsAlwaysOpaque(ordinal)
}
...@@ -236,7 +236,7 @@ class ImageInfo(val colorInfo: ColorInfo, val width: Int, val height: Int) { ...@@ -236,7 +236,7 @@ class ImageInfo(val colorInfo: ColorInfo, val width: Int, val height: Int) {
* @return ImageInfo with [ColorType.N32] * @return ImageInfo with [ColorType.N32]
*/ */
fun makeN32(width: Int, height: Int, alphaType: ColorAlphaType): ImageInfo { fun makeN32(width: Int, height: Int, alphaType: ColorAlphaType): ImageInfo {
return ImageInfo(ColorInfo(ColorType.Companion.N32, alphaType, null), width, height) return ImageInfo(ColorInfo(ColorType.N32, alphaType, null), width, height)
} }
/** /**
...@@ -263,14 +263,14 @@ class ImageInfo(val colorInfo: ColorInfo, val width: Int, val height: Int) { ...@@ -263,14 +263,14 @@ class ImageInfo(val colorInfo: ColorInfo, val width: Int, val height: Int) {
* @return ImageInfo with [ColorType.N32] and [ColorAlphaType.PREMUL] * @return ImageInfo with [ColorType.N32] and [ColorAlphaType.PREMUL]
*/ */
fun makeN32Premul(width: Int, height: Int): ImageInfo { fun makeN32Premul(width: Int, height: Int): ImageInfo {
return ImageInfo(ColorInfo(ColorType.Companion.N32, ColorAlphaType.PREMUL, null), width, height) return ImageInfo(ColorInfo(ColorType.N32, ColorAlphaType.PREMUL, null), width, height)
} }
/** /**
* @return ImageInfo with [ColorType.N32] and [ColorAlphaType.PREMUL] * @return ImageInfo with [ColorType.N32] and [ColorAlphaType.PREMUL]
*/ */
fun makeN32Premul(width: Int, height: Int, colorSpace: ColorSpace?): ImageInfo { fun makeN32Premul(width: Int, height: Int, colorSpace: ColorSpace?): ImageInfo {
return ImageInfo(ColorInfo(ColorType.Companion.N32, ColorAlphaType.PREMUL, colorSpace), width, height) return ImageInfo(ColorInfo(ColorType.N32, ColorAlphaType.PREMUL, colorSpace), width, height)
} }
/** /**
......
...@@ -3,11 +3,11 @@ package org.jetbrains.skia.impl ...@@ -3,11 +3,11 @@ package org.jetbrains.skia.impl
import org.jetbrains.skiko.Library import org.jetbrains.skiko.Library
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
class Library { actual class Library {
companion object { actual companion object {
var loaded = AtomicBoolean(false) var loaded = AtomicBoolean(false)
@JvmStatic @JvmStatic
fun staticLoad() { actual fun staticLoad() {
if (!loaded.compareAndExchange(false, true)) { if (!loaded.compareAndExchange(false, true)) {
Library.load() Library.load()
} }
......
...@@ -70,6 +70,6 @@ object Log { ...@@ -70,6 +70,6 @@ object Log {
4 else if ("ERROR" == property) 4 else if ("ERROR" == property)
5 else if ("NONE" == property) 5 else if ("NONE" == property)
6 else 6 else
throw IllegalArgumentException("Unknown log level: " + property) throw IllegalArgumentException("Unknown log level: $property")
} }
} }
\ No newline at end of file
...@@ -2,10 +2,10 @@ package org.jetbrains.skia.impl ...@@ -2,10 +2,10 @@ package org.jetbrains.skia.impl
import java.lang.ref.Cleaner import java.lang.ref.Cleaner
abstract class Managed @JvmOverloads constructor(ptr: Long, finalizer: Long, managed: Boolean = true) : Native(ptr), actual abstract class Managed actual constructor(ptr: Long, finalizer: Long, managed: Boolean) : Native(ptr),
AutoCloseable { AutoCloseable {
private var _cleanable: Cleaner.Cleanable? = null private var _cleanable: Cleaner.Cleanable? = null
override fun close() { actual override fun close() {
if (0L == _ptr) throw RuntimeException("Object already closed: $javaClass, _ptr=$_ptr") else if (null == _cleanable) throw RuntimeException( if (0L == _ptr) throw RuntimeException("Object already closed: $javaClass, _ptr=$_ptr") else if (null == _cleanable) throw RuntimeException(
"Object is not managed in JVM, can't close(): $javaClass, _ptr=$_ptr" "Object is not managed in JVM, can't close(): $javaClass, _ptr=$_ptr"
) else { ) else {
......
...@@ -2,10 +2,10 @@ package org.jetbrains.skia.impl ...@@ -2,10 +2,10 @@ package org.jetbrains.skia.impl
import java.lang.ref.Reference import java.lang.ref.Reference
abstract class Native(ptr: Long) { actual abstract class Native actual constructor(ptr: Long) {
var _ptr: Long actual var _ptr: Long
override fun toString(): String { override fun toString(): String {
return javaClass.simpleName + "(_ptr=0x" + java.lang.Long.toString(_ptr, 16) + ")" return javaClass.simpleName + "(_ptr=0x" + _ptr.toString(16) + ")"
} }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
...@@ -30,8 +30,8 @@ abstract class Native(ptr: Long) { ...@@ -30,8 +30,8 @@ abstract class Native(ptr: Long) {
return java.lang.Long.hashCode(_ptr) return java.lang.Long.hashCode(_ptr)
} }
companion object { actual companion object {
fun getPtr(n: Native?): Long { actual fun getPtr(n: Native?): Long {
return n?._ptr ?: 0 return n?._ptr ?: 0
} }
} }
...@@ -40,4 +40,8 @@ abstract class Native(ptr: Long) { ...@@ -40,4 +40,8 @@ abstract class Native(ptr: Long) {
if (ptr == 0L) throw RuntimeException("Can't wrap nullptr") if (ptr == 0L) throw RuntimeException("Can't wrap nullptr")
_ptr = ptr _ptr = ptr
} }
}
actual fun reachabilityBarrier(obj: Any?) {
Reference.reachabilityFence(obj)
} }
\ No newline at end of file
...@@ -2,9 +2,9 @@ package org.jetbrains.skia.impl ...@@ -2,9 +2,9 @@ package org.jetbrains.skia.impl
import java.lang.ref.Reference import java.lang.ref.Reference
abstract class RefCnt : Managed { actual abstract class RefCnt : Managed {
protected constructor(ptr: Long) : super(ptr, _FinalizerHolder.PTR) {} protected actual constructor(ptr: Long) : super(ptr, _FinalizerHolder.PTR) {}
protected constructor(ptr: Long, allowClose: Boolean) : super(ptr, _FinalizerHolder.PTR, allowClose) {} protected actual constructor(ptr: Long, allowClose: Boolean) : super(ptr, _FinalizerHolder.PTR, allowClose)
val refCount: Int val refCount: Int
get() = try { get() = try {
......
...@@ -2,27 +2,23 @@ package org.jetbrains.skia.impl ...@@ -2,27 +2,23 @@ package org.jetbrains.skia.impl
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
object Stats { actual object Stats {
var enabled = false var enabled = false
var nativeCalls: Long = 0 var nativeCalls: Long = 0
var allocated: MutableMap<String, Int> = ConcurrentHashMap() var allocated: MutableMap<String, Int> = ConcurrentHashMap()
fun onNativeCall() { actual fun onNativeCall() {
if (enabled) nativeCalls++ if (enabled) nativeCalls++
} }
fun onAllocated(className: String) { actual fun onAllocated(className: String) {
if (enabled) allocated.merge(className, 1) { a: Int?, b: Int? -> if (enabled) allocated.merge(className, 1) { a: Int, b: Int ->
Integer.sum( a + b
a!!, b!!
)
} }
} }
fun onDeallocated(className: String) { actual fun onDeallocated(className: String) {
if (enabled) allocated.merge(className, -1) { a: Int?, b: Int? -> if (enabled) allocated.merge(className, -1) { a: Int, b: Int ->
Integer.sum( a + b
a!!, b!!
)
} }
} }
} }
\ No newline at end of file
...@@ -63,7 +63,7 @@ class DecorationStyle( ...@@ -63,7 +63,7 @@ class DecorationStyle(
if (java.lang.Float.compare(thicknessMultiplier, other.thicknessMultiplier) != 0) return false if (java.lang.Float.compare(thicknessMultiplier, other.thicknessMultiplier) != 0) return false
val `this$_lineStyle`: Any = lineStyle val `this$_lineStyle`: Any = lineStyle
val `other$_lineStyle`: Any = other.lineStyle val `other$_lineStyle`: Any = other.lineStyle
return if (if (`this$_lineStyle` == null) `other$_lineStyle` != null else `this$_lineStyle` != `other$_lineStyle`) false else true return `this$_lineStyle` == `other$_lineStyle`
} }
protected fun canEqual(other: Any?): Boolean { protected fun canEqual(other: Any?): Boolean {
...@@ -85,7 +85,7 @@ class DecorationStyle( ...@@ -85,7 +85,7 @@ class DecorationStyle(
} }
override fun toString(): String { override fun toString(): String {
return "DecorationStyle(_underline=" + _underline + ", _overline=" + _overline + ", _lineThrough=" + _lineThrough + ", _gaps=" + _gaps + ", _color=" + color + ", _lineStyle=" + lineStyle + ", _thicknessMultiplier=" + thicknessMultiplier + ")" return "DecorationStyle(_underline=$_underline, _overline=$_overline, _lineThrough=$_lineThrough, _gaps=$_gaps, _color=$color, _lineStyle=$lineStyle, _thicknessMultiplier=$thicknessMultiplier)"
} }
fun withUnderline(_underline: Boolean): DecorationStyle { fun withUnderline(_underline: Boolean): DecorationStyle {
......
...@@ -16,7 +16,7 @@ class BidiRun( ...@@ -16,7 +16,7 @@ class BidiRun(
val other = o val other = o
if (!other.canEqual(this as Any)) return false if (!other.canEqual(this as Any)) return false
if (end != other.end) return false if (end != other.end) return false
return if (level != other.level) false else true return level == other.level
} }
protected fun canEqual(other: Any?): Boolean { protected fun canEqual(other: Any?): Boolean {
...@@ -32,6 +32,6 @@ class BidiRun( ...@@ -32,6 +32,6 @@ class BidiRun(
} }
override fun toString(): String { override fun toString(): String {
return "BidiRun(_end=" + end + ", _level=" + level + ")" return "BidiRun(_end=$end, _level=$level)"
} }
} }
\ No newline at end of file
package org.jetbrains.skia.impl
actual class Library {
actual companion object {
actual fun staticLoad() {
TODO()
}
}
}
package org.jetbrains.skia.impl
actual abstract class Managed actual constructor(ptr: Long, finalizer: Long, managed: Boolean) : Native(ptr) {
actual open fun close() {
TODO()
}
}
\ No newline at end of file
package org.jetbrains.skia.impl
actual abstract class Native actual constructor(ptr: Long) {
actual var _ptr: Long
actual companion object {
actual fun getPtr(n: Native?): Long {
return n?._ptr ?: 0
}
}
init {
if (ptr == 0L) throw RuntimeException("Can't wrap nullptr")
_ptr = ptr
}
}
actual fun reachabilityBarrier(obj: Any?) {
TODO()
}
\ No newline at end of file
package org.jetbrains.skia.impl
actual abstract class RefCnt : Managed {
actual protected constructor(ptr: Long): super(ptr, 0L, false) { TODO() }
actual protected constructor(ptr: Long, allowClose: Boolean): super(ptr, 0, allowClose) { TODO() }
}
\ No newline at end of file
package org.jetbrains.skia.impl
actual object Stats {
actual fun onNativeCall() {
TODO()
}
actual fun onAllocated(className: String) {
TODO()
}
actual fun onDeallocated(className: String) {
TODO()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment