-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Share AssetFileDescriptor with ImageDecoder #1990
Conversation
@@ -30,30 +30,28 @@ internal class ContentUriFetcher( | |||
override suspend fun fetch(): FetchResult { | |||
val androidUri = data.toAndroidUri() | |||
val contentResolver = options.context.contentResolver | |||
val inputStream = if (isContactPhotoUri(data)) { | |||
val afd = if (isContactPhotoUri(data)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate to this PR, but will ImageDecoder.createSource(options.context.contentResolver, metadata.uri.toAndroidUri())
correctly handle this special case for a contacts image URI?
One of the issues with passing this data to StaticImageDecoderDecoder
is we're coupling the source with the decoder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate to this PR, but will
ImageDecoder.createSource(options.context.contentResolver, metadata.uri.toAndroidUri())
correctly handle this special case for a contacts image URI?One of the issues with passing this data to
StaticImageDecoderDecoder
is we're coupling the source with the decoder.
Haven't test it, but now ImageDecoder use a afd that InputStream use for this case so it doesn't matter
And ImageDecoder should work as it use openAssetFileDescriptor internally as well
And about coupling, I think we have to couple it as both BitmapFactory and ImageDecoder doesn't have a appropriate API to pass a "native" stream(SkStream like), and okio is ByteArray based.
Ideally we could abstract all source to a "ByteBufferStream" which could use DirectByteBuffer as internal storage(on other platform just a native allocated buffer), but things is neither okio nor decoder support it
But kotlinx-io is doing such thing
The best we can do is, if the source is file backed and can be used directly(i.e. uri, File), just let decoder use it directly
Close #1970