Loading tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapImage.kt +40 −25 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package com.android.test.silkfx.hdr import android.animation.AnimatorSet import android.animation.ObjectAnimator import android.animation.ValueAnimator import android.animation.ValueAnimator.AnimatorUpdateListener import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas Loading Loading @@ -65,17 +69,11 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context findViewById<RadioGroup>(R.id.output_mode)!!.also { it.check(outputMode) it.setOnCheckedChangeListener { _, checkedId -> val previousMode = outputMode outputMode = checkedId if (previousMode == R.id.output_sdr && checkedId == R.id.output_hdr) { animateToHdr() } else if (previousMode == R.id.output_hdr && checkedId == R.id.output_sdr) { animateToSdr() } else { // Intentionally don't do anything fancy so that mode A/B comparisons are easy updateDisplay() } } } val spinner = findViewById<Spinner>(R.id.image_selection)!! val adapter = ArrayAdapter(context, android.R.layout.simple_spinner_item, gainmapImages) Loading Loading @@ -103,10 +101,41 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context imageView.apply { isClickable = true // Example of animating between SDR and HDR using gainmap params; animates HDR->SDR->HDR // with a brief pause on SDR. The key thing here is that the gainmap's // minDisplayRatioForHdrTransition is animated between its original value (for full HDR) // and displayRatioForFullHdr (for full SDR). The view must also be invalidated during // the animation for the updates to take effect. setOnClickListener { animate().alpha(.5f).withEndAction { animate().alpha(1f).start() }.start() if (gainmap != null && (outputMode == R.id.output_hdr || outputMode == R.id.output_hdr_test)) { val animationLengthMs: Long = 500 val updateListener = object : AnimatorUpdateListener { override fun onAnimationUpdate(animation: ValueAnimator) { imageView.invalidate() } } val hdrToSdr = ObjectAnimator.ofFloat( gainmap, "minDisplayRatioForHdrTransition", gainmap!!.minDisplayRatioForHdrTransition, gainmap!!.displayRatioForFullHdr).apply { duration = animationLengthMs addUpdateListener(updateListener) } val sdrToHdr = ObjectAnimator.ofFloat( gainmap, "minDisplayRatioForHdrTransition", gainmap!!.displayRatioForFullHdr, gainmap!!.minDisplayRatioForHdrTransition).apply { duration = animationLengthMs addUpdateListener(updateListener) } AnimatorSet().apply { play(hdrToSdr) play(sdrToHdr).after(animationLengthMs) start() } } } } } Loading Loading @@ -164,20 +193,6 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context updateDisplay() } private fun animateToHdr() { if (bitmap == null || gainmap == null) return // TODO: Trigger an animation updateDisplay() } private fun animateToSdr() { if (bitmap == null) return // TODO: Trigger an animation updateDisplay() } private fun updateDisplay() { if (bitmap == null) return Loading Loading
tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapImage.kt +40 −25 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package com.android.test.silkfx.hdr import android.animation.AnimatorSet import android.animation.ObjectAnimator import android.animation.ValueAnimator import android.animation.ValueAnimator.AnimatorUpdateListener import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas Loading Loading @@ -65,17 +69,11 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context findViewById<RadioGroup>(R.id.output_mode)!!.also { it.check(outputMode) it.setOnCheckedChangeListener { _, checkedId -> val previousMode = outputMode outputMode = checkedId if (previousMode == R.id.output_sdr && checkedId == R.id.output_hdr) { animateToHdr() } else if (previousMode == R.id.output_hdr && checkedId == R.id.output_sdr) { animateToSdr() } else { // Intentionally don't do anything fancy so that mode A/B comparisons are easy updateDisplay() } } } val spinner = findViewById<Spinner>(R.id.image_selection)!! val adapter = ArrayAdapter(context, android.R.layout.simple_spinner_item, gainmapImages) Loading Loading @@ -103,10 +101,41 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context imageView.apply { isClickable = true // Example of animating between SDR and HDR using gainmap params; animates HDR->SDR->HDR // with a brief pause on SDR. The key thing here is that the gainmap's // minDisplayRatioForHdrTransition is animated between its original value (for full HDR) // and displayRatioForFullHdr (for full SDR). The view must also be invalidated during // the animation for the updates to take effect. setOnClickListener { animate().alpha(.5f).withEndAction { animate().alpha(1f).start() }.start() if (gainmap != null && (outputMode == R.id.output_hdr || outputMode == R.id.output_hdr_test)) { val animationLengthMs: Long = 500 val updateListener = object : AnimatorUpdateListener { override fun onAnimationUpdate(animation: ValueAnimator) { imageView.invalidate() } } val hdrToSdr = ObjectAnimator.ofFloat( gainmap, "minDisplayRatioForHdrTransition", gainmap!!.minDisplayRatioForHdrTransition, gainmap!!.displayRatioForFullHdr).apply { duration = animationLengthMs addUpdateListener(updateListener) } val sdrToHdr = ObjectAnimator.ofFloat( gainmap, "minDisplayRatioForHdrTransition", gainmap!!.displayRatioForFullHdr, gainmap!!.minDisplayRatioForHdrTransition).apply { duration = animationLengthMs addUpdateListener(updateListener) } AnimatorSet().apply { play(hdrToSdr) play(sdrToHdr).after(animationLengthMs) start() } } } } } Loading Loading @@ -164,20 +193,6 @@ class GainmapImage(context: Context, attrs: AttributeSet?) : FrameLayout(context updateDisplay() } private fun animateToHdr() { if (bitmap == null || gainmap == null) return // TODO: Trigger an animation updateDisplay() } private fun animateToSdr() { if (bitmap == null) return // TODO: Trigger an animation updateDisplay() } private fun updateDisplay() { if (bitmap == null) return Loading