qt: reuse textures in various places
This enables texture reusing in these places:
- Drag item.
- Grid view expansion.
- Artist page header.
This should significantly reduce the time it takes to start dragging (current waiting bailout time is 50ms, and image loading from disk should take less than that, but it is still considerable), as the drag item would not bother loading images whenever the texture is provided. I'm not considering the image cache here, because we can not expect the source size to match (and as far as I see, that is the case).
I do not intend to overuse this approach everywhere, such as, having a single Image per source image and using it as texture provider among view delegate instances.
Draft because:
-
fillModeprobably would not be applicable in this case, unless we do whatImageis doing for things like having a texture with properties such as wrap mode set (we can do this withTextureProviderItemindirection) or calculatingpaintedWidth/Heightourselves as the source would have calculated it for the source's ownfillMode. So far inImageExt, we have been using theImageto help withfillModeto most extent (unlessPreserveAspectCropwhere we do the big work for defining a viewport). - Image in artist page header sometimes looks black, that's probably because of Qt's mipmapped texture sampling bug. I already have a workaround for that in https://code.videolan.org/videolan/vlc/-/blob/master/modules/gui/qt/util/qsgtextureview.cpp#L47, which can be used with
TextureProviderItemwithout any graphics overhead here, but for now we demand anImagefor external texture providers due to not being able to usetextureSize()in GLSL and wanting to use probe the availability of the texture (I think both can be provided by a texture provider introspection helper class.TextureProviderObserverin !7461 (merged) can already provide the texture size, it can also provide the availability). I will investigate more if this can be mitigated like in !7461 (diffs) withTextureProviderItem. - If the texture and display sizes differ big, the image may noticeably appear sharp (downsampling) or blurry (upsampling). And we can not use mipmapping in most cases, as it would spoil atlas textures (which we need in view delegate, for example) and even if it was not it would still be debatable whether it is worth to use for this case.