Commit Graph

11 Commits

Author SHA1 Message Date
Kaj Grönholm 47be703df5 Improve MultiEffect API documentation
Add some code examples and images.

Task-number: QTBUG-110757
Pick-to: 6.5
Change-Id: I599bef3374c597e4ab2afa4478748100d3963d84
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-02 08:53:24 +02:00
Kaj Grönholm 396a7454e6 Adjust the MultiEffect API
Based on the API review, adjust the MultiEffect API.
- Change mask threshold Low/Up to Min/Max and for spread AtMin/AtMax.
- Change colorize to colorization so it is more symmetric with
  brightness, saturation etc.

Task-number: QTBUG-109557
Pick-to: 6.5
Change-Id: I96ff2a13e20405998c5ed0cb38ad3b5911daf94c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-01-26 12:42:33 +02:00
Eskil Abrahamsen Blomfeldt 3352746b27 doc: Make sure QtQuick.Effects module shows in docs
This was missing some infrastructure to be generated.

Change-Id: I669193af2550bb6274b9f69fc3c852cf59e54f6d
Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>
2023-01-10 21:12:58 +01:00
Kaj Grönholm e09b72fe10 Improve blur items sizing
MultiEffect uses max 5 blur items. So to be able to divide first one 4
times without rounding, first one needs to be rounded up to next
2^4 = 16 (16,8,4,2,1). Make the first blurred item size half of the
source size (plus the rounding). This increases the blur amount and
performance and decreases texture memory usage and quality. Based on
testing it seemes like a good compromize.

Also resize bluritems only when needed.

Pick-to: 6.5
Task-number: QTBUG-109490
Change-Id: I907b48904d3f9b0414704026cc1f07c02c49a8c7
Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>
2022-12-20 12:09:59 +02:00
Kaj Grönholm 7c174fcf96 Cleanup and fix initial shadowOpacity
Cleanup unused properties from the effect. Also update initial shadow
opacity correctly with the color.

Task-number: QTBUG-109432
Pick-to: 6.5
Change-Id: I3615f17333ce63403d00b3df75794565b72768ed
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-20 12:09:53 +02:00
Kaj Grönholm 672bb1d450 Improve and optimize MultiEffect mask
Move mask calculations from fragment shader into C++ side, so that only
need to be done once vs. each pixel. Adjust slightly so that smoothstep
doesn't reach potentially undefined rangle (edge0 ≥ edge1).

Task-number: QTBUG-109431
Pick-to: 6.5
Change-Id: If0ca10385c9bf41fb32b666f2b1c4dd38b7cc192
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-20 12:09:47 +02:00
Kaj Grönholm 4d1c27942b Adjust the default values of shadow offsets
Default to 0 with shadow horizontal and vertical offsets. This way they
match to GE DropShadow defaults and also the shadow fits inside the
effect item area without any extra paddingRect.

Pick-to: 6.5
Change-Id: Ib02763a15c088a390dfe65e0e9216ca0a10fc58c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-20 12:09:41 +02:00
Kaj Grönholm cf6a4d0bf9 Fix MultiEffect sizing with layer.effect
When using Item layer.effect, the effect source item doesn't get a size
but instead the size is updated directly for the effect (see
QQuickItemLayer::updateGeometry()).

Task-number: QTBUG-109406
Pick-to: 6.5
Change-Id: I3ef7469b6286848791b9c844281c68c5988cfd01
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-20 12:09:36 +02:00
Kaj Grönholm 06085040fc Fix MultiEffect memory leak
Make sure bluritems get cleaned together with the MultiEffect item.

Task-number: QTBUG-109276
Change-Id: I0a84d10b0436f9fcdb051914839626c6cf226a5f
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
2022-12-10 09:27:03 +02:00
Kaj Grönholm 9f61a35254 Improve MultiEffect source handling
Improve the way MultiEffect handles input source item.
- Use modified QGfxSourceProxy from Graphical Effects, to be compatible
with the source handling. Basically internal ShaderEffectSource is only
created when the target source item can't be used directly.
- Remove "hideSource" property as that isn't relevant anymore.
- Add "hasProxySource" readonly property to see when the internal
  source is used.
- Adjust documentation related to this change.

Task-number: QTBUG-109137
Change-Id: I11fb317548c1a13442d6f241eca3917a4293f47d
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
2022-12-10 09:27:00 +02:00
Kaj Grönholm fc0d469718 Add QtQuick.Effects & MultiEffect
Add new QtQuick.Effects plugin for post-processing effects.
The plan is to add essential effects directly into QtQuick,
not to duplicate Qt Graphical Effects.

Initially the plugin will contain MultiEffect which supports
7 different effects in a single ShaderEffect (brightness,
contrast, saturation, colorize, blur, shadow, mask). Combining
multiple effects into a single shader is more performant than
chaining multiple effect items. Depending on used features,
the most optimal shader gets selected.

Includes two examples demonstrating the usage of MultiEffect.

Task-number: QTBUG-106651
Change-Id: I35865030fd4b7a1f657146cee03b195451545bc6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-07 08:31:43 +02:00