coil icon indicating copy to clipboard operation
coil copied to clipboard

Update SvgDecoder.android.kt to support scaling

Open seanpont opened this issue 1 year ago • 5 comments

Scales SVGs correctly

Issue: https://github.com/coil-kt/coil/issues/2048

Please run ./test.sh before submitting to ensure your pull request passes the automated checks.

seanpont avatar Jan 30 '24 18:01 seanpont

Thanks! I think we can ship this with a few changes:

  • Let's put these changes behind a flag in SvgDecoder.Factory's constructor. We need to preserve the existing behaviour for existing users.
  • Do we need to make the same changes to SvgDecoder.nonAndroid? Ideally we want the Android and non-Android implementations to behave as similarly as possible.
  • Please add a test in AbstractSvgDecoderTest. This'll make sure that we don't break the behaviour in the future.

colinrtwhite avatar Jan 30 '24 18:01 colinrtwhite

Hey Colin,

The changes that you suggest sound reasonable, but I'm not able to make those modifications right now. We (Google) are using the prior version, and upgrading to 3.x so that I can make the change to head is going to take a little longer.

On Tue, Jan 30, 2024 at 10:59 AM Colin White @.***> wrote:

Thanks! I think we can ship this with a few changes:

  • Let's put these changes behind a flag in SvgDecoder.Factory's constructor. We need to preserve the existing behaviour for existing users.
  • Do we need to make the same changes to SvgDecoder.nonAndroid? Ideally we want the Android and non-Android implementations to behave as similarly as possible.
  • Please add a test in AbstractSvgDecoderTest. This'll make sure that we don't break the behaviour in the future.

— Reply to this email directly, view it on GitHub https://github.com/coil-kt/coil/pull/2090#issuecomment-1917697109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFUHJ72FROI5XYRQPNR74DYRE7K5AVCNFSM6AAAAABCRWKZOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJXGY4TOMJQHE . You are receiving this because you authored the thread.Message ID: @.***>

seanpont avatar Jan 30 '24 20:01 seanpont

@seanpont Ah gotcha! If you'd like to make the change to the 2.x releases you'll need to target your PR to the 2.x branch. main currently has all the 3.0 alpha code which supports multiplatform.

I think we should still add a flag to SvgDecoder's constructor to avoid changing the behaviour for existing users. Maybe densityScalingEnabled: Boolean = false?

I can work on releasing 2.6.0 with those changes once they're merged.

colinrtwhite avatar Jan 30 '24 22:01 colinrtwhite

Looking at the commits does svg.scale even exist? I attempted to copy this code and it did not work. Is there something I am missing to get svg.scale be available?

Is there any obvious downsides of doing an implementation like this by default eventually?

davidcorradowell avatar Feb 07 '24 20:02 davidcorradowell

Gonna +1 getting this merged in some form. For us, SVGs render at a miniscule size on Android when using coil

androidacy-user avatar Apr 05 '24 16:04 androidacy-user