Unverified Commit 05382a7a authored by Aleksandr Veselov's avatar Aleksandr Veselov Committed by GitHub

SurfaceTest: destroy GL context immediately after use (#407)

Use abandon before destroy
parent 7e9e0beb
package org.jetbrains.skia
import org.jetbrains.skia.impl.*
import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.NativePointer
import org.jetbrains.skia.impl.RefCnt
import org.jetbrains.skia.impl.Stats
import org.jetbrains.skia.impl.reachabilityBarrier
class DirectContext internal constructor(ptr: NativePointer) : RefCnt(ptr) {
companion object {
......@@ -112,6 +109,10 @@ class DirectContext internal constructor(ptr: NativePointer) : RefCnt(ptr) {
}
}
fun <R> DirectContext.useContext(block: (ctx: DirectContext) -> R): R = use {
block(this).also { abandon() }
}
@ExternalSymbolName("org_jetbrains_skia_DirectContext__1nFlush")
private external fun DirectContext_nFlush(ptr: NativePointer): NativePointer
......
......@@ -115,7 +115,7 @@ class SurfaceTest {
}
val pixels = TestGlContext.run {
val ctx = DirectContext.makeGL()
DirectContext.makeGL().useContext { ctx ->
val imageInfo = ImageInfo.makeN32Premul(16, 16)
val surface = Surface.makeRenderTarget(ctx, budgeted = false, imageInfo)
......@@ -125,6 +125,7 @@ class SurfaceTest {
)
Bitmap.makeFromImage(surface.makeImageSnapshot(), ctx)
}
}
assertEquals(Color.RED, pixels.getColor(8, 8))
}
......
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