Unverified Commit b2ef7847 authored by Oleksandr Karpovich's avatar Oleksandr Karpovich Committed by GitHub

add ImageFilter implementations (#318)

* add ImageFilterTest.kt: blur test

* add ImageFilterTest.kt: AlphaThreshold

* add ImageFilterTest.kt: Arithmetic

* add ImageFilterTest.kt: small refactoring

* add ImageFilterTest.kt: blend

* add ImageFilterTest.kt: colorFilter

* add ImageFilterTest.kt: compose

* add ImageFilterTest.kt: displacementMap

* add ImageFilterTest.kt: dropShadow

* add ImageFilterTest.kt: dropShadowOnly

* add ImageFilterTest.kt: makeImage

* add ImageFilterTest.kt: magnifier

* add ImageFilterTest.kt: MatrixConvolution

* add ImageFilterTest.kt: MatrixTransform

* add ImageFilterTest.kt: makeMerge

* add ImageFilterTest.kt: makeOffset

* add ImageFilterTest.kt: makePaint

* add ImageFilterTest.kt: makeTile

* add ImageFilterTest.kt: makeDilate

* add ImageFilterTest.kt: makeErode

* add ImageFilterTest.kt: makeDistantLitDiffuse

* add ImageFilterTest.kt: makePointLitDiffuse

* add ImageFilterTest.kt: makeSpotLitDiffuse

* add ImageFilterTest.kt: makeDistantLitSpecular

* add ImageFilterTest.kt: makePointLitSpecular

* add ImageFilterTest.kt: makeSpotLitSpecular
Co-authored-by: 's avatarOleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
parent 4ceb8f1c
......@@ -29,6 +29,11 @@ class IRect internal constructor(val left: Int, val top: Int, val right: Int, va
return Rect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
}
// This is a helper to pass IRect instance through interop border
internal fun serializeToIntArray(): IntArray {
return intArrayOf(left, top, right, bottom)
}
override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is IRect) return false
......
......@@ -14,13 +14,16 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeAlphaThreshold(
getPtr(
r
), innerMin, outerMax, getPtr(input), crop
getPtr(r),
innerMin, outerMax, getPtr(input),
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(r)
reachabilityBarrier(input)
......@@ -39,6 +42,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeArithmetic(
k1,
......@@ -48,9 +52,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
enforcePMColor,
getPtr(bg),
getPtr(fg),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(bg)
reachabilityBarrier(fg)
......@@ -60,14 +65,16 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makeBlend(blendMode: BlendMode, bg: ImageFilter?, fg: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeBlend(
blendMode.ordinal,
getPtr(bg),
getPtr(fg),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(bg)
reachabilityBarrier(fg)
......@@ -83,15 +90,17 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeBlur(
sigmaX,
sigmaY,
mode.ordinal,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -100,13 +109,14 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makeColorFilter(f: ColorFilter?, input: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeColorFilter(
getPtr(
f
), getPtr(input), crop
getPtr(f), getPtr(input),
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(f)
reachabilityBarrier(input)
......@@ -139,6 +149,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeDisplacementMap(
x.ordinal,
......@@ -146,9 +157,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
scale,
getPtr(displacement),
getPtr(color),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(displacement)
reachabilityBarrier(color)
......@@ -166,6 +178,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeDropShadow(
dx,
......@@ -174,9 +187,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
sigmaY,
color,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -193,6 +207,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeDropShadowOnly(
dx,
......@@ -201,9 +216,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
sigmaY,
color,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -240,6 +256,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makeMagnifier(r: Rect, inset: Float, input: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeMagnifier(
r.left,
......@@ -248,9 +265,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
r.bottom,
inset,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -284,7 +302,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
tileMode.ordinal,
convolveAlpha,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
}
)
......@@ -317,7 +335,13 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
Stats.onNativeCall()
val filterPtrs = NativePointerArray(filters.size)
for (i in filters.indices) filterPtrs[i] = getPtr(filters[i])
ImageFilter(_nMakeMerge(toInterop(filterPtrs), crop))
ImageFilter(
_nMakeMerge(
filters = toInterop(filterPtrs),
filtersLength = filters.size,
crop = toInterop(crop?.serializeToIntArray())
)
)
} finally {
reachabilityBarrier(filters)
}
......@@ -327,14 +351,15 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makeOffset(dx: Float, dy: Float, input: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeOffset(
dx,
dy,
dx, dy,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -343,13 +368,14 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makePaint(paint: Paint?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakePaint(
getPtr(
paint
), crop
paint = getPtr(paint),
crop = toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(paint)
}
......@@ -379,14 +405,16 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makeDilate(rx: Float, ry: Float, input: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeDilate(
rx,
ry,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -395,14 +423,15 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun makeErode(rx: Float, ry: Float, input: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeErode(
rx,
ry,
rx, ry,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -420,18 +449,18 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeDistantLitDiffuse(
x,
y,
z,
x, y, z,
lightColor,
surfaceScale,
kd,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -449,18 +478,18 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakePointLitDiffuse(
x,
y,
z,
x, y, z,
lightColor,
surfaceScale,
kd,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -483,23 +512,21 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeSpotLitDiffuse(
x0,
y0,
z0,
x1,
y1,
z1,
x0, y0, z0,
x1, y1, z1,
falloffExponent,
cutoffAngle,
lightColor,
surfaceScale,
kd,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -518,6 +545,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeDistantLitSpecular(
x,
......@@ -528,9 +556,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
ks,
shininess,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -549,19 +578,19 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakePointLitSpecular(
x,
y,
z,
x, y, z,
lightColor,
surfaceScale,
ks,
shininess,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -585,14 +614,11 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeSpotLitSpecular(
x0,
y0,
z0,
x1,
y1,
z1,
x0, y0, z0,
x1, y1, z1,
falloffExponent,
cutoffAngle,
lightColor,
......@@ -600,9 +626,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
ks,
shininess,
getPtr(input),
crop
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(input)
}
......@@ -620,7 +647,7 @@ private external fun _nMakeAlphaThreshold(
innerMin: Float,
outerMax: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeArithmetic")
......@@ -632,15 +659,15 @@ private external fun _nMakeArithmetic(
enforcePMColor: Boolean,
bg: NativePointer,
fg: NativePointer,
crop: IRect?
crop: InteropPointer?
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeBlend")
private external fun _nMakeBlend(blendMode: Int, bg: NativePointer, fg: NativePointer, crop: IRect?): NativePointer
private external fun _nMakeBlend(blendMode: Int, bg: NativePointer, fg: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeBlur")
private external fun _nMakeBlur(sigmaX: Float, sigmaY: Float, tileMode: Int, input: NativePointer, crop: IRect?): NativePointer
private external fun _nMakeBlur(sigmaX: Float, sigmaY: Float, tileMode: Int, input: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeColorFilter")
private external fun _nMakeColorFilter(colorFilterPtr: NativePointer, input: NativePointer, crop: IRect?): NativePointer
private external fun _nMakeColorFilter(colorFilterPtr: NativePointer, input: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeCompose")
private external fun _nMakeCompose(outer: NativePointer, inner: NativePointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeDisplacementMap")
......@@ -650,7 +677,7 @@ private external fun _nMakeDisplacementMap(
scale: Float,
displacement: NativePointer,
color: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeDropShadow")
......@@ -661,7 +688,7 @@ private external fun _nMakeDropShadow(
sigmaY: Float,
color: Int,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeDropShadowOnly")
......@@ -672,7 +699,7 @@ private external fun _nMakeDropShadowOnly(
sigmaY: Float,
color: Int,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeImage")
......@@ -698,7 +725,7 @@ private external fun _nMakeMagnifier(
b: Float,
inset: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeMatrixConvolution")
......@@ -713,17 +740,17 @@ private external fun _nMakeMatrixConvolution(
tileMode: Int,
convolveAlpha: Boolean,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeMatrixTransform")
private external fun _nMakeMatrixTransform(matrix: InteropPointer, samplingModeVal1: Int, samplingModeVal2: Int, input: NativePointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeMerge")
private external fun _nMakeMerge(filters: InteropPointer, crop: IRect?): NativePointer
private external fun _nMakeMerge(filters: InteropPointer, filtersLength: Int, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeOffset")
private external fun _nMakeOffset(dx: Float, dy: Float, input: NativePointer, crop: IRect?): NativePointer
private external fun _nMakeOffset(dx: Float, dy: Float, input: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakePaint")
private external fun _nMakePaint(paint: NativePointer, crop: IRect?): NativePointer
private external fun _nMakePaint(paint: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakePicture")
private external fun _nMakePicture(picture: NativePointer, l: Float, t: Float, r: Float, b: Float): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeTile")
......@@ -740,9 +767,9 @@ private external fun _nMakeTile(
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeDilate")
private external fun _nMakeDilate(rx: Float, ry: Float, input: NativePointer, crop: IRect?): NativePointer
private external fun _nMakeDilate(rx: Float, ry: Float, input: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeErode")
private external fun _nMakeErode(rx: Float, ry: Float, input: NativePointer, crop: IRect?): NativePointer
private external fun _nMakeErode(rx: Float, ry: Float, input: NativePointer, crop: InteropPointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeDistantLitDiffuse")
private external fun _nMakeDistantLitDiffuse(
x: Float,
......@@ -752,7 +779,7 @@ private external fun _nMakeDistantLitDiffuse(
surfaceScale: Float,
kd: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakePointLitDiffuse")
......@@ -764,7 +791,7 @@ private external fun _nMakePointLitDiffuse(
surfaceScale: Float,
kd: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeSpotLitDiffuse")
......@@ -781,7 +808,7 @@ private external fun _nMakeSpotLitDiffuse(
surfaceScale: Float,
kd: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeDistantLitSpecular")
......@@ -794,7 +821,7 @@ private external fun _nMakeDistantLitSpecular(
ks: Float,
shininess: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakePointLitSpecular")
......@@ -807,7 +834,7 @@ private external fun _nMakePointLitSpecular(
ks: Float,
shininess: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeSpotLitSpecular")
......@@ -825,5 +852,5 @@ private external fun _nMakeSpotLitSpecular(
ks: Float,
shininess: Float,
input: NativePointer,
crop: IRect?
crop: InteropPointer
): NativePointer
package org.jetbrains.skia
import org.jetbrains.skia.impl.use
import org.jetbrains.skia.util.assertContentDifferent
import org.jetbrains.skiko.tests.runTest
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
class ImageFilterTest {
private val originalBytes: ByteArray by lazy {
renderAndReturnBytes(imageFilter = null)
}
private fun renderAndReturnBytes(imageFilter: ImageFilter? = null): ByteArray {
return Surface.makeRasterN32Premul(20, 20).use {
val paint = Paint().apply {
setStroke(true)
strokeWidth = 2f
}
val region = Region().apply {
op(IRect(3, 3, 18, 18), Region.Op.UNION)
}
paint.imageFilter = imageFilter
it.canvas.drawRegion(region, paint)
val image = it.makeImageSnapshot()
Bitmap.makeFromImage(image).readPixels()!!
}
}
private fun imageFilterTest(imageFilter: () -> ImageFilter) = runTest {
val modifiedPixels = renderAndReturnBytes(imageFilter = imageFilter())
assertEquals(originalBytes.size, modifiedPixels.size)
// we don't check the actual content of the pixels, we only assume they're different when ImageFilter applied
assertContentDifferent(
array1 = originalBytes,
array2 = modifiedPixels,
message = "pixels with applied ImageFilter should be different"
)
}
@Test
fun alphaThreshold() = imageFilterTest {
ImageFilter.makeAlphaThreshold(
Region().apply {
setRect(IRect(5, 5, 10, 10))
},
innerMin = 0.9f,
outerMax = 0.2f,
input = null,
crop = null
)
}
@Test
fun arithmetic() = imageFilterTest {
ImageFilter.makeArithmetic(
k1 = 0.5f, k2 = 0.5f, k3 = 0.5f, k4 = 0.5f, enforcePMColor = true,
bg = null, fg = null, crop = null
)
}
@Test
fun blend() = imageFilterTest {
val region = Region().apply {
setRect(IRect(5, 5, 10, 10))
}
ImageFilter.makeBlend(
blendMode = BlendMode.COLOR,
bg = ImageFilter.makeBlur(2f, 2f, mode = FilterTileMode.CLAMP),
fg = ImageFilter.makeAlphaThreshold(r = region, innerMin = 0.5f, outerMax = 0.5f, input = null, crop = null),
crop = null
)
}
@Test
fun blur() = imageFilterTest {
ImageFilter.makeBlur(
1f, 1f, FilterTileMode.CLAMP, crop = IRect(5, 5, 10, 10)
)
}
@Test
fun colorFilter() = imageFilterTest {
ImageFilter.makeColorFilter(
f = ColorFilter.luma,
input = null, crop = null
)
}
@Test
fun compose() = imageFilterTest {
val inner = ImageFilter.makeBlur(
1f, 1f, FilterTileMode.CLAMP, crop = IRect(5, 5, 10, 10)
)
val outer = ImageFilter.makeColorFilter(
f = ColorFilter.luma,
input = null, crop = null
)
ImageFilter.makeCompose(
inner = inner,
outer = outer
)
}
@Test
fun displacementMap() = imageFilterTest {
val colorFilter = ImageFilter.makeColorFilter(
f = ColorFilter.luma,
input = null, crop = null
)
ImageFilter.makeDisplacementMap(
x = ColorChannel.R,
y = ColorChannel.G,
scale = 2f,
displacement = null,
color = colorFilter,
crop = null
)
}
@Test
fun dropShadow() = imageFilterTest {
ImageFilter.makeDropShadow(
dx = 2f, dy = 2f, sigmaX = 2f, sigmaY = 2f, color = Color.BLACK,
input = null, crop = null
)
}
@Test
fun dropShadowOnly() = imageFilterTest {
ImageFilter.makeDropShadowOnly(
dx = 2f, dy = 2f, sigmaX = 1f, sigmaY = 2f,
color = Color.BLACK, input = null, crop = null
)
}
@Test
fun makeImage() = imageFilterTest {
val bitmap = Bitmap()
bitmap.setImageInfo(ImageInfo.makeN32Premul(5, 5))
bitmap.installPixels(ByteArray(100) { -1 })
ImageFilter.makeImage(
Image.makeFromBitmap(bitmap)
)
}
@Test
fun makeMagnifier() = imageFilterTest {
ImageFilter.makeMagnifier(
r = Rect(0f, 0f, 15f, 15f),
input = null,
crop = null,
inset = 2f
)
}
@Test
fun makeMatrixConvolution() = imageFilterTest {
ImageFilter.makeMatrixConvolution(
kernelH = 2,
kernelW = 2,
kernel = floatArrayOf(0.5f, 1f, 0.2f, 1.2f),
gain = 1f,
bias = 0f,
offsetX = 1,
offsetY = 1,
tileMode = FilterTileMode.CLAMP,
convolveAlpha = true,
input = null,
crop = null
)
}
@Test // TODO: use SamplingMode._packAs2Ints after PR(316) gets merged
fun makeMatrixTransform() = imageFilterTest {
ImageFilter.makeMatrixTransform(
Matrix33.makeTranslate(2f, 2f),
mode = SamplingMode.LINEAR,
input = null
)
}
@Test
fun makeMerge() = imageFilterTest {
val filter1 = ImageFilter.makeMagnifier(
r = Rect(0f, 0f, 15f, 15f),
input = null,
crop = null,
inset = 2f
)
val filter2 = ImageFilter.makeColorFilter(
f = ColorFilter.luma,
input = null, crop = null
)
val filter3 = ImageFilter.makeBlur(
1f, 1f, FilterTileMode.CLAMP, crop = IRect(5, 5, 10, 10)
)
ImageFilter.makeMerge(
filters = arrayOf(filter1, filter2, filter3),
crop = IRect(2, 2, 12, 12)
)
}
@Test
fun makeOffset() = imageFilterTest {
ImageFilter.makeOffset(dx = 2f, dy = 2f, input = null, crop = null)
}
@Test
fun makePaint() = imageFilterTest {
ImageFilter.makePaint(
paint = Paint().setStroke(false).setColor4f(Color4f(Color.RED), colorSpace = null),
crop = null
)
}
@Test
fun makeTile() = imageFilterTest {
ImageFilter.makeTile(
src = Rect(0f, 0f, 3f, 3f),
dst = Rect(5f, 5f, 19f, 19f),
input = null
)
}
@Test
fun makeDilate() = imageFilterTest {
ImageFilter.makeDilate(
rx = 10f, ry = 10f, input = null, crop = null
)
}
@Test
fun makeErode() = imageFilterTest {
ImageFilter.makeErode(
rx = 5f, ry = 5f, input = null, crop = null
)
}
@Test
fun makeDistantLitDiffuse() = imageFilterTest {
ImageFilter.makeDistantLitDiffuse(
x = 2f, y = 2f, z = 2f, lightColor = Color.RED,
surfaceScale = 2f, kd = 1f, input = null, crop = IRect(5, 5, 10, 10)
)
}
@Test
fun makePointLitDiffuse() = imageFilterTest {
ImageFilter.makePointLitDiffuse(
x = 2f, y = 2f, z = 2f, lightColor = Color.RED,
surfaceScale = 2f, kd = 1f, input = null, crop = IRect(5, 5, 10, 10)
)
}
@Test
fun makeSpotLitDiffuse() = imageFilterTest {
ImageFilter.makeSpotLitDiffuse(
x0 = 0f, y0 = 0f, z0 = 0f, x1 = 10f, y1 = 10f, z1 = 10f,
falloffExponent = 2f, cutoffAngle = 0f, lightColor = Color.RED,
surfaceScale = 2f, kd = 1f, input = null, crop = IRect(0, 0, 15, 15)
)
}
@Test
fun makeDistantLitSpecular() = imageFilterTest {
ImageFilter.makeDistantLitSpecular(
x = 1f, y = 1f, z = 10f, lightColor = Color.RED,
surfaceScale = 2f, ks = 1f, shininess = 1f, input = null,
crop = IRect(0, 0, 15, 15)
)
}
@Test
fun makePointLitSpecular() = imageFilterTest {
ImageFilter.makePointLitSpecular(
x = 1f, y = 1f, z = 10f, lightColor = Color.RED,
surfaceScale = 2f, ks = 1f, shininess = 1f, input = null,
crop = IRect(0, 0, 15, 15)
)
}
@Test
fun makeSpotLitSpecular() = imageFilterTest {
ImageFilter.makeSpotLitSpecular(
x0 = 0f, y0 = 0f, z0 = 0f, x1 = 10f, y1 = 10f, z1 = 10f,
falloffExponent = 2f, cutoffAngle = 0f, lightColor = Color.RED,
surfaceScale = 2f, ks = 1f, input = null, crop = IRect(0, 0, 15, 15),
shininess = 1f
)
}
}
package org.jetbrains.skia.util
import kotlin.test.assertTrue
internal fun assertContentDifferent(array1: ByteArray, array2: ByteArray, message: String? = null) {
assertTrue(
actual = array1.size != array2.size ||
array1.asSequence().zip(array2.asSequence()).any { it.first != it.second },
message = message
)
}
......@@ -9,47 +9,47 @@
#include "interop.hh"
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeAlphaThreshold
(JNIEnv* env, jclass jclass, jlong regionPtr, jfloat innerMin, jfloat outerMax, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jlong regionPtr, jfloat innerMin, jfloat outerMax, jlong inputPtr, jintArray cropInts) {
SkRegion* region = reinterpret_cast<SkRegion*>(static_cast<uintptr_t>(regionPtr));
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::AlphaThreshold(*region, innerMin, outerMax, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeArithmetic
(JNIEnv* env, jclass jclass, jfloat k1, jfloat k2, jfloat k3, jfloat k4, jboolean enforcePMColor, jlong bgPtr, jlong fgPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat k1, jfloat k2, jfloat k3, jfloat k4, jboolean enforcePMColor, jlong bgPtr, jlong fgPtr, jintArray cropInts) {
SkImageFilter* bg = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(bgPtr));
SkImageFilter* fg = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(fgPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Arithmetic(k1, k2, k3, k4, enforcePMColor, sk_ref_sp(bg), sk_ref_sp(fg), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeBlend
(JNIEnv* env, jclass jclass, jint blendModeInt, jlong bgPtr, jlong fgPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jint blendModeInt, jlong bgPtr, jlong fgPtr, jintArray cropInts) {
SkBlendMode blendMode = static_cast<SkBlendMode>(blendModeInt);
SkImageFilter* bg = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(bgPtr));
SkImageFilter* fg = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(fgPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Blend(blendMode, sk_ref_sp(bg), sk_ref_sp(fg), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeBlur
(JNIEnv* env, jclass jclass, jfloat sigmaX, jfloat sigmaY, jint tileModeInt, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat sigmaX, jfloat sigmaY, jint tileModeInt, jlong inputPtr, jintArray cropInts) {
SkTileMode tileMode = static_cast<SkTileMode>(tileModeInt);
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Blur(sigmaX, sigmaY, tileMode, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeColorFilter
(JNIEnv* env, jclass jclass, jlong colorFilterPtr, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jlong colorFilterPtr, jlong inputPtr, jintArray cropInts) {
SkColorFilter* colorFilter = reinterpret_cast<SkColorFilter*>(static_cast<uintptr_t>(colorFilterPtr));
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::ColorFilter(sk_ref_sp(colorFilter), sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
......@@ -63,28 +63,28 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMake
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeDisplacementMap
(JNIEnv* env, jclass jclass, jint xChanInt, jint yChanInt, jfloat scale, jlong displacementPtr, jlong colorPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jint xChanInt, jint yChanInt, jfloat scale, jlong displacementPtr, jlong colorPtr, jintArray cropInts) {
SkColorChannel xChan = static_cast<SkColorChannel>(xChanInt);
SkColorChannel yChan = static_cast<SkColorChannel>(yChanInt);
SkImageFilter* displacement = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(displacementPtr));
SkImageFilter* color = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(colorPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::DisplacementMap(xChan, yChan, scale, sk_ref_sp(displacement), sk_ref_sp(color), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeDropShadow
(JNIEnv* env, jclass jclass, jfloat dx, jfloat dy, jfloat sigmaX, jfloat sigmaY, jint color, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat dx, jfloat dy, jfloat sigmaX, jfloat sigmaY, jint color, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::DropShadow(dx, dy, sigmaX, sigmaY, color, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeDropShadowOnly
(JNIEnv* env, jclass jclass, jfloat dx, jfloat dy, jfloat sigmaX, jfloat sigmaY, jint color, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat dx, jfloat dy, jfloat sigmaX, jfloat sigmaY, jint color, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::DropShadowOnly(dx, dy, sigmaX, sigmaY, color, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
......@@ -97,19 +97,19 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMake
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeMagnifier
(JNIEnv* env, jclass jclass, jfloat l, jfloat t, jfloat r, jfloat b, jfloat inset, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat l, jfloat t, jfloat r, jfloat b, jfloat inset, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Magnifier(SkRect{l, t, r, b}, inset, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeMatrixConvolution
(JNIEnv* env, jclass jclass, jint kernelW, jint kernelH, jfloatArray kernelArray, jfloat gain, jfloat bias, jint offsetX, jint offsetY, jint tileModeInt, jboolean convolveAlpha, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jint kernelW, jint kernelH, jfloatArray kernelArray, jfloat gain, jfloat bias, jint offsetX, jint offsetY, jint tileModeInt, jboolean convolveAlpha, jlong inputPtr, jintArray cropInts) {
jfloat* kernel = env->GetFloatArrayElements(kernelArray, 0);
SkTileMode tileMode = static_cast<SkTileMode>(tileModeInt);
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::MatrixConvolution(SkISize{kernelW, kernelH}, kernel, gain, bias, SkIPoint{offsetX, offsetY}, tileMode, convolveAlpha, sk_ref_sp(input), crop.get()).release();
env->ReleaseFloatArrayElements(kernelArray, kernel, 0);
return reinterpret_cast<jlong>(ptr);
......@@ -124,32 +124,31 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMake
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeMerge
(JNIEnv* env, jclass jclass, jlongArray filtersArray, jobject cropObj) {
(JNIEnv* env, jclass jclass, jlongArray filtersArray, jint filtersArraySize, jintArray cropInts) {
jlong* f = env->GetLongArrayElements(filtersArray, 0);
jsize len = env->GetArrayLength(filtersArray);
std::vector<sk_sp<SkImageFilter>> filters(len);
for (int i = 0; i < len; ++i) {
std::vector<sk_sp<SkImageFilter>> filters(filtersArraySize);
for (int i = 0; i < filtersArraySize; ++i) {
SkImageFilter* fi = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(f[i]));
filters[i] = sk_ref_sp(fi);
}
env->ReleaseLongArrayElements(filtersArray, f, 0);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
SkImageFilter* ptr = SkImageFilters::Merge(filters.data(), len, crop.get()).release();
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Merge(filters.data(), filtersArraySize, crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeOffset
(JNIEnv* env, jclass jclass, jfloat dx, jfloat dy, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat dx, jfloat dy, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Offset(dx, dy, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakePaint
(JNIEnv* env, jclass jclass, jlong paintPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jlong paintPtr, jintArray cropInts) {
SkPaint* paint = reinterpret_cast<SkPaint*>(static_cast<uintptr_t>(paintPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Paint(*paint, crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
......@@ -169,65 +168,65 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMake
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeDilate
(JNIEnv* env, jclass jclass, float rx, jfloat ry, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, float rx, jfloat ry, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Dilate(rx, ry, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeErode
(JNIEnv* env, jclass jclass, float rx, jfloat ry, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, float rx, jfloat ry, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Erode(rx, ry, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeDistantLitDiffuse
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat kd, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat kd, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::DistantLitDiffuse(SkPoint3{x, y, z}, lightColor, surfaceScale, kd, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakePointLitDiffuse
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat kd, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat kd, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::PointLitDiffuse(SkPoint3{x, y, z}, lightColor, surfaceScale, kd, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeSpotLitDiffuse
(JNIEnv* env, jclass jclass, jfloat x0, jfloat y0, jfloat z0, jfloat x1, jfloat y1, jfloat z1, jfloat falloffExponent, jfloat cutoffAngle, jint lightColor, jfloat surfaceScale, jfloat kd, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat x0, jfloat y0, jfloat z0, jfloat x1, jfloat y1, jfloat z1, jfloat falloffExponent, jfloat cutoffAngle, jint lightColor, jfloat surfaceScale, jfloat kd, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::SpotLitDiffuse(SkPoint3{x0, y0, z0}, SkPoint3{x1, y1, z1}, falloffExponent, cutoffAngle, lightColor, surfaceScale, kd, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeDistantLitSpecular
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat ks, jfloat shininess, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat ks, jfloat shininess, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::DistantLitSpecular(SkPoint3{x, y, z}, lightColor, surfaceScale, ks, shininess, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakePointLitSpecular
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat ks, jfloat shininess, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat x, jfloat y, jfloat z, jint lightColor, jfloat surfaceScale, jfloat ks, jfloat shininess, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::PointLitSpecular(SkPoint3{x, y, z}, lightColor, surfaceScale, ks, shininess, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeSpotLitSpecular
(JNIEnv* env, jclass jclass, jfloat x0, jfloat y0, jfloat z0, jfloat x1, jfloat y1, jfloat z1, jfloat falloffExponent, jfloat cutoffAngle, jint lightColor, jfloat surfaceScale, jfloat ks, jfloat shininess, jlong inputPtr, jobject cropObj) {
(JNIEnv* env, jclass jclass, jfloat x0, jfloat y0, jfloat z0, jfloat x1, jfloat y1, jfloat z1, jfloat falloffExponent, jfloat cutoffAngle, jint lightColor, jfloat surfaceScale, jfloat ks, jfloat shininess, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::SpotLitSpecular(SkPoint3{x0, y0, z0}, SkPoint3{x1, y1, z1}, falloffExponent, cutoffAngle, lightColor, surfaceScale, ks, shininess, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
......@@ -452,6 +452,19 @@ namespace skija {
});
}
}
std::unique_ptr<SkIRect> toSkIRect(JNIEnv* env, jintArray rectInts) {
if (rectInts == nullptr)
return std::unique_ptr<SkIRect>(nullptr);
else {
jint *ints = env->GetIntArrayElements(rectInts, NULL);
auto result = std::unique_ptr<SkIRect>(new SkIRect{
ints[0], ints[1], ints[2], ints[3]
});
env->ReleaseIntArrayElements(rectInts, ints, NULL);
return result;
}
}
}
namespace Path {
......
......@@ -11,94 +11,50 @@
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeAlphaThreshold
(KNativePointer regionPtr, KFloat innerMin, KFloat outerMax, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeAlphaThreshold");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeAlphaThreshold
(KNativePointer regionPtr, KFloat innerMin, KFloat outerMax, KNativePointer inputPtr, KInteropPointer cropObj) {
(KNativePointer regionPtr, KFloat innerMin, KFloat outerMax, KNativePointer inputPtr, KInt* cropInts) {
SkRegion* region = reinterpret_cast<SkRegion*>((regionPtr));
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropInts);
SkImageFilter* ptr = SkImageFilters::AlphaThreshold(*region, innerMin, outerMax, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeArithmetic
(KFloat k1, KFloat k2, KFloat k3, KFloat k4, KBoolean enforcePMColor, KNativePointer bgPtr, KNativePointer fgPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeArithmetic");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeArithmetic
(KFloat k1, KFloat k2, KFloat k3, KFloat k4, KBoolean enforcePMColor, KNativePointer bgPtr, KNativePointer fgPtr, KInteropPointer cropObj) {
(KFloat k1, KFloat k2, KFloat k3, KFloat k4, KBoolean enforcePMColor, KNativePointer bgPtr, KNativePointer fgPtr, KInt* cropInts) {
SkImageFilter* bg = reinterpret_cast<SkImageFilter*>((bgPtr));
SkImageFilter* fg = reinterpret_cast<SkImageFilter*>((fgPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropInts);
SkImageFilter* ptr = SkImageFilters::Arithmetic(k1, k2, k3, k4, enforcePMColor, sk_ref_sp(bg), sk_ref_sp(fg), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeBlend
(KInt blendModeInt, KNativePointer bgPtr, KNativePointer fgPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeBlend");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeBlend
(KInt blendModeInt, KNativePointer bgPtr, KNativePointer fgPtr, KInteropPointer cropObj) {
(KInt blendModeInt, KNativePointer bgPtr, KNativePointer fgPtr, KInt* cropInts) {
SkBlendMode blendMode = static_cast<SkBlendMode>(blendModeInt);
SkImageFilter* bg = reinterpret_cast<SkImageFilter*>((bgPtr));
SkImageFilter* fg = reinterpret_cast<SkImageFilter*>((fgPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropInts);
SkImageFilter* ptr = SkImageFilters::Blend(blendMode, sk_ref_sp(bg), sk_ref_sp(fg), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeBlur
(KFloat sigmaX, KFloat sigmaY, KInt tileModeInt, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeBlur");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeBlur
(KFloat sigmaX, KFloat sigmaY, KInt tileModeInt, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat sigmaX, KFloat sigmaY, KInt tileModeInt, KNativePointer inputPtr, KInt* cropRectInts) {
SkTileMode tileMode = static_cast<SkTileMode>(tileModeInt);
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Blur(sigmaX, sigmaY, tileMode, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeColorFilter
(KNativePointer colorFilterPtr, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeColorFilter");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeColorFilter
(KNativePointer colorFilterPtr, KNativePointer inputPtr, KInteropPointer cropObj) {
(KNativePointer colorFilterPtr, KNativePointer inputPtr, KInt* cropRectInts) {
SkColorFilter* colorFilter = reinterpret_cast<SkColorFilter*>((colorFilterPtr));
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::ColorFilter(sk_ref_sp(colorFilter), sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeCompose
(KNativePointer outerPtr, KNativePointer innerPtr) {
......@@ -108,58 +64,32 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeCompose
return reinterpret_cast<KNativePointer>(ptr);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDisplacementMap
(KInt xChanInt, KInt yChanInt, KFloat scale, KNativePointer displacementPtr, KNativePointer colorPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeDisplacementMap");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDisplacementMap
(KInt xChanInt, KInt yChanInt, KFloat scale, KNativePointer displacementPtr, KNativePointer colorPtr, KInteropPointer cropObj) {
(KInt xChanInt, KInt yChanInt, KFloat scale, KNativePointer displacementPtr, KNativePointer colorPtr, KInt* cropRectInts) {
SkColorChannel xChan = static_cast<SkColorChannel>(xChanInt);
SkColorChannel yChan = static_cast<SkColorChannel>(yChanInt);
SkImageFilter* displacement = reinterpret_cast<SkImageFilter*>((displacementPtr));
SkImageFilter* color = reinterpret_cast<SkImageFilter*>((colorPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::DisplacementMap(xChan, yChan, scale, sk_ref_sp(displacement), sk_ref_sp(color), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDropShadow
(KFloat dx, KFloat dy, KFloat sigmaX, KFloat sigmaY, KInt color, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeDropShadow");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDropShadow
(KFloat dx, KFloat dy, KFloat sigmaX, KFloat sigmaY, KInt color, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat dx, KFloat dy, KFloat sigmaX, KFloat sigmaY, KInt color, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::DropShadow(dx, dy, sigmaX, sigmaY, color, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDropShadowOnly
(KFloat dx, KFloat dy, KFloat sigmaX, KFloat sigmaY, KInt color, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeDropShadowOnly");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDropShadowOnly
(KFloat dx, KFloat dy, KFloat sigmaX, KFloat sigmaY, KInt color, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat dx, KFloat dy, KFloat sigmaX, KFloat sigmaY, KInt color, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::DropShadowOnly(dx, dy, sigmaX, sigmaY, color, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeImage
......@@ -169,116 +99,58 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeImage
return reinterpret_cast<KNativePointer>(ptr);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMagnifier
(KFloat l, KFloat t, KFloat r, KFloat b, KFloat inset, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeMagnifier");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMagnifier
(KFloat l, KFloat t, KFloat r, KFloat b, KFloat inset, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat l, KFloat t, KFloat r, KFloat b, KFloat inset, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Magnifier(SkRect{l, t, r, b}, inset, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMatrixConvolution
(KInt kernelW, KInt kernelH, KFloat* kernelArray, KFloat gain, KFloat bias, KInt offsetX, KInt offsetY, KInt tileModeInt, KBoolean convolveAlpha, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeMatrixConvolution");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMatrixConvolution
(KInt kernelW, KInt kernelH, KFloat* kernelArray, KFloat gain, KFloat bias, KInt offsetX, KInt offsetY, KInt tileModeInt, KBoolean convolveAlpha, KNativePointer inputPtr, KInteropPointer cropObj) {
KFloat* kernel = env->GetFloatArrayElements(kernelArray, 0);
(KInt kernelW, KInt kernelH, KFloat* kernelArray, KFloat gain, KFloat bias, KInt offsetX, KInt offsetY, KInt tileModeInt, KBoolean convolveAlpha, KNativePointer inputPtr, KInt* cropRectInts) {
SkTileMode tileMode = static_cast<SkTileMode>(tileModeInt);
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
SkImageFilter* ptr = SkImageFilters::MatrixConvolution(SkISize{kernelW, kernelH}, kernel, gain, bias, SkIPoint{offsetX, offsetY}, tileMode, convolveAlpha, sk_ref_sp(input), crop.get()).release();
env->ReleaseFloatArrayElements(kernelArray, kernel, 0);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::MatrixConvolution(SkISize{kernelW, kernelH}, kernelArray, gain, bias, SkIPoint{offsetX, offsetY}, tileMode, convolveAlpha, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMatrixTransform
(KFloat* matrixArray, KInt samplingModeVal1, KInt samplingModeVal2, KNativePointer inputPtr) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeMatrixTransform");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMatrixTransform
(KFloat* matrixArray, KInt samplingModeVal1, KInt samplingModeVal2, KNativePointer inputPtr) {
std::unique_ptr<SkMatrix> matrix = skMatrix(env, matrixArray);
std::unique_ptr<SkMatrix> matrix = skMatrix(matrixArray);
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
SkImageFilter* ptr = SkImageFilters::MatrixTransform(*matrix, skija::SamplingMode::unpackFrom2Ints(samplingModeVal1, samplingModeVal2), sk_ref_sp(input)).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMerge
(KNativePointerArray filtersArray, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeMerge");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMerge
(KNativePointerArray filtersArray, KInteropPointer cropObj) {
KNativePointer* f = env->GetLongArrayElements(filtersArray, 0);
jsize len = env->GetArrayLength(filtersArray);
std::vector<sk_sp<SkImageFilter>> filters(len);
for (int i = 0; i < len; ++i) {
SkImageFilter* fi = reinterpret_cast<SkImageFilter*>((f[i]));
(KNativePointer* filtersArray, KInt filtersArraySize, KInt* cropRectInts) {
std::vector<sk_sp<SkImageFilter>> filters(filtersArraySize);
for (int i = 0; i < filtersArraySize; ++i) {
SkImageFilter* fi = reinterpret_cast<SkImageFilter*>(filtersArray[i]);
filters[i] = sk_ref_sp(fi);
}
env->ReleaseLongArrayElements(filtersArray, f, 0);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
SkImageFilter* ptr = SkImageFilters::Merge(filters.data(), len, crop.get()).release();
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Merge(filters.data(), filtersArraySize, crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeOffset
(KFloat dx, KFloat dy, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeOffset");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeOffset
(KFloat dx, KFloat dy, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat dx, KFloat dy, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Offset(dx, dy, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePaint
(KNativePointer paintPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakePaint");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePaint
(KNativePointer paintPtr, KInteropPointer cropObj) {
(KNativePointer paintPtr, KInt* cropRectInts) {
SkPaint* paint = reinterpret_cast<SkPaint*>((paintPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Paint(*paint, crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePicture
......@@ -295,138 +167,66 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeTile
return reinterpret_cast<KNativePointer>(ptr);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDilate
(float rx, KFloat ry, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeDilate");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDilate
(float rx, KFloat ry, KNativePointer inputPtr, KInteropPointer cropObj) {
(float rx, KFloat ry, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Dilate(rx, ry, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeErode
(float rx, KFloat ry, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeErode");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeErode
(float rx, KFloat ry, KNativePointer inputPtr, KInteropPointer cropObj) {
(float rx, KFloat ry, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Erode(rx, ry, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDistantLitDiffuse
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeDistantLitDiffuse");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDistantLitDiffuse
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::DistantLitDiffuse(SkPoint3{x, y, z}, lightColor, surfaceScale, kd, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePointLitDiffuse
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakePointLitDiffuse");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePointLitDiffuse
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::PointLitDiffuse(SkPoint3{x, y, z}, lightColor, surfaceScale, kd, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeSpotLitDiffuse
(KFloat x0, KFloat y0, KFloat z0, KFloat x1, KFloat y1, KFloat z1, KFloat falloffExponent, KFloat cutoffAngle, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeSpotLitDiffuse");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeSpotLitDiffuse
(KFloat x0, KFloat y0, KFloat z0, KFloat x1, KFloat y1, KFloat z1, KFloat falloffExponent, KFloat cutoffAngle, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat x0, KFloat y0, KFloat z0, KFloat x1, KFloat y1, KFloat z1, KFloat falloffExponent, KFloat cutoffAngle, KInt lightColor, KFloat surfaceScale, KFloat kd, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::SpotLitDiffuse(SkPoint3{x0, y0, z0}, SkPoint3{x1, y1, z1}, falloffExponent, cutoffAngle, lightColor, surfaceScale, kd, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDistantLitSpecular
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeDistantLitSpecular");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeDistantLitSpecular
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::DistantLitSpecular(SkPoint3{x, y, z}, lightColor, surfaceScale, ks, shininess, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePointLitSpecular
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakePointLitSpecular");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakePointLitSpecular
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat x, KFloat y, KFloat z, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::PointLitSpecular(SkPoint3{x, y, z}, lightColor, surfaceScale, ks, shininess, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeSpotLitSpecular
(KFloat x0, KFloat y0, KFloat z0, KFloat x1, KFloat y1, KFloat z1, KFloat falloffExponent, KFloat cutoffAngle, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInteropPointer cropObj) {
TODO("implement org_jetbrains_skia_ImageFilter__1nMakeSpotLitSpecular");
}
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeSpotLitSpecular
(KFloat x0, KFloat y0, KFloat z0, KFloat x1, KFloat y1, KFloat z1, KFloat falloffExponent, KFloat cutoffAngle, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInteropPointer cropObj) {
(KFloat x0, KFloat y0, KFloat z0, KFloat x1, KFloat y1, KFloat z1, KFloat falloffExponent, KFloat cutoffAngle, KInt lightColor, KFloat surfaceScale, KFloat ks, KFloat shininess, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropObj);
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::SpotLitSpecular(SkPoint3{x0, y0, z0}, SkPoint3{x1, y1, z1}, falloffExponent, cutoffAngle, lightColor, surfaceScale, ks, shininess, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#endif
......@@ -64,6 +64,10 @@ namespace skija {
namespace SurfaceProps {
std::unique_ptr<SkSurfaceProps> toSkSurfaceProps(KInt* surfacePropsInts);
}
namespace IRect {
std::unique_ptr<SkIRect> toSkIRect(KInt* rectInts);
}
}
std::unique_ptr<SkMatrix> skMatrix(KFloat* matrixArray);
......
......@@ -196,4 +196,16 @@ namespace skija {
return std::make_unique<SkSurfaceProps>(flags, geom);
}
}
namespace IRect {
std::unique_ptr<SkIRect> toSkIRect(KInt* rectInts) {
if (rectInts == nullptr)
return std::unique_ptr<SkIRect>(nullptr);
else {
return std::unique_ptr<SkIRect>(new SkIRect{
rectInts[0], rectInts[1], rectInts[2], rectInts[3]
});
}
}
}
}
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