Commit 44e81329 authored by Igor Demin's avatar Igor Demin

AWT.kt, awt_jni.cc. Refactoring

parent 07d5e63f
...@@ -14,7 +14,9 @@ extern "C" ...@@ -14,7 +14,9 @@ extern "C"
if (result == JNI_FALSE) if (result == JNI_FALSE)
{ {
return 0; return 0;
} else { }
else
{
return static_cast<jlong>(reinterpret_cast<uintptr_t>(awt)); return static_cast<jlong>(reinterpret_cast<uintptr_t>(awt));
} }
} }
......
...@@ -25,9 +25,11 @@ internal fun Component.getDrawingSurface() = DrawingSurface(this) ...@@ -25,9 +25,11 @@ internal fun Component.getDrawingSurface() = DrawingSurface(this)
internal class DrawingSurface( internal class DrawingSurface(
component: Component component: Component
) : AutoCloseable { ) : AutoCloseable {
val ptr = getDrawingSurface(awt, component).also { var ptr =
check(it != 0L) getDrawingSurface(awt, component).also {
} check(it != 0L)
}
private set
fun lock() = lockDrawingSurface(ptr) fun lock() = lockDrawingSurface(ptr)
...@@ -46,20 +48,24 @@ internal class DrawingSurface( ...@@ -46,20 +48,24 @@ internal class DrawingSurface(
override fun close() { override fun close() {
freeDrawingSurface(awt, ptr) freeDrawingSurface(awt, ptr)
ptr = 0
} }
} }
internal class DrawingSurfaceInfo( internal class DrawingSurfaceInfo(
private val drawingSurface: Long private val drawingSurface: Long
) : AutoCloseable { ) : AutoCloseable {
val ptr = getDrawingSurfaceInfo(drawingSurface).also { var ptr =
check(it != 0L) getDrawingSurfaceInfo(drawingSurface).also {
} check(it != 0L)
}
private set
val platformInfo: Long get() = getPlatformInfo(ptr) val platformInfo: Long get() = getPlatformInfo(ptr)
override fun close() { override fun close() {
freeDrawingSurfaceInfo(drawingSurface, ptr) freeDrawingSurfaceInfo(drawingSurface, ptr)
ptr = 0
} }
} }
......
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