james
07/06/2024, 5:57 AMdrawWithCache
which helps with heavy calculations, but I’m doing some pretty resource intensive draw calls in my drawIntoCanvas
block, and once they’re done they don’t need to be redrawn unless I explicitly tell them to. Code example in 🧵james
07/06/2024, 5:57 AMdrawWithCache {
println("drawWithCache") // only called with new state
// cache certain heavy calculations here
onDrawBehind {
drawIntoCanvas { canvas ->
println("drawIntoCanvas") // this is called constantly
// many canvas.drawXX calls here
}
}
}
One way I thought of is to draw into a bitmap for the first time, then draw that bitmap for subsequent calls using a single drawImage
call, but I want to know if there’s a way I can rely on the underlying graphics framework to cache it instead because I assume it has more advanced / optimised caching mechanisms?Albert Chang
07/06/2024, 6:31 AMgraphicsLayer()
before drawWithCache()
is the best you can do.Stylianos Gakis
07/06/2024, 9:47 AMZach Klippenstein (he/him) [MOD]
07/06/2024, 1:52 PMZach Klippenstein (he/him) [MOD]
07/06/2024, 1:53 PMromainguy
07/06/2024, 2:56 PMromainguy
07/06/2024, 2:57 PMromainguy
07/06/2024, 2:58 PMjames
07/24/2024, 1:33 AM