scoop:scoop.desktop:0.1.0
src/images.scoop
Selected production source · src/images.scoop
1
package scoop.desktop3
import scoop.window.DesktopImage5
internal fun <R> withDesktopImage(image: DesktopImage?, action: (Ptr<Unit>?) -> R): R {6
when (image) {7
case None -> return action(None)8
case Some(val value) -> @Unsafe9
{10
val native =11
desktopCreated(12
nativeImageCreate(13
value.size.width,14
value.size.height,15
if (value.template)16
117
else18
019
),20
"desktop image"21
)22
try {23
for (representation in value.representations)24
representation.pixels.withDataPointer {25
pixels,26
_ -> @Unsafe27
{28
desktopStatus(29
nativeImageAdd(30
native,31
representation.size.width,32
representation.size.height,33
pixels34
),35
"desktop image pixels"36
)37
}38
}39
return action(Some(native))40
} finally {41
nativeImageDestroy(native)42
}43
}44
}45
}47
internal fun sameDesktopImage(left: DesktopImage?, right: DesktopImage?): Boolean =48
when ((left, right)) {49
case(Some(val a), Some(val b)) -> a === b50
case(None, None) -> true51
else -> false52
}