Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
If `ShaderEffectSource`'s target is already a texture provider (such as layered item, or `Image`), and the parameters match (such as same texture format), it may not be necessary to create a new layer and texture.
This is a use case when `ShaderEffectSource` has a `sourceRect` that is a sub-rect of the source texture.
In order to achieve that, applications can currently use `QSGTexture` to come up with such `QSGTextureView` and use it with an arbitrary texture provider item as indirection. However, this would be simpler if `ShaderEffectSource` did that itself without all the additional effort.
The concept for texture view is already in the scene graph due to the atlas texture (`QSGTexture::normalizedTextureSubRect()`), as textures in the atlas are simply texture views for the atlas texture. However, it would be also convenient to have `QSGTextureView` that does the normalization calculations for non-atlas texture views. This new class would contain the target texture, and `setRect()` method that does the normalization calculation since `normalizedTextureSubRect()` needs to return the normalized rect.
It is first necessary to make it clear (document it) that a texture does not need to be an atlas texture if it makes use of `QSGTexture::normalizedTextureSubRect()`. According to my experiments, Qt is already fine with that (at least with `ShaderEffect` as the texture consumer case), the texture may not return true for `QSGTexture::isAtlasTexture()` but still the sub rect is respected.