Skip to content

Commit

Permalink
Added option to selectively disable image release callbacks for Vito
Browse files Browse the repository at this point in the history
Differential Revision: D58819847

fbshipit-source-id: 5dc9bf707def637909edac9c4b90e608263cfe01
  • Loading branch information
oprisnik authored and facebook-github-bot committed Jun 20, 2024
1 parent 6947f27 commit dc64f21
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ object ImageReleaseScheduler {
var releaseDelayMs: Long = 16 * 5 // Roughly 5 frames.

var improveDelayedReleasing = false
var enableReleaseDelayed = true
var enableReleaseNextFrame = true
var enableReleaseImmediately = true

class ImageReleaseState(val drawable: KFrescoVitoDrawable) :
Runnable, DeferredReleaser.Releasable {
Expand All @@ -36,12 +39,15 @@ object ImageReleaseScheduler {
private val deferredReleaser = DeferredReleaser.getInstance()

fun releaseImmediately(drawable: KFrescoVitoDrawable) {
if (!enableReleaseImmediately) {
return
}
drawable.imagePerfListener.onReleaseImmediately(drawable)
drawable.reset()
}

fun releaseDelayed(drawable: KFrescoVitoDrawable) {
if (drawable.releaseState.delayedReleasePending) {
if (!enableReleaseDelayed || drawable.releaseState.delayedReleasePending) {
return
}
drawable.imagePerfListener.onScheduleReleaseDelayed(drawable)
Expand All @@ -52,6 +58,9 @@ object ImageReleaseScheduler {
}

fun releaseNextFrame(drawable: KFrescoVitoDrawable) {
if (!enableReleaseNextFrame) {
return
}
cancelReleaseDelayed(drawable)
drawable.imagePerfListener.onScheduleReleaseNextFrame(drawable)
deferredReleaser.scheduleDeferredRelease(drawable.releaseState)
Expand Down

0 comments on commit dc64f21

Please sign in to comment.