GaussianGlow.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2017 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. // Qt-Security score:significant reason:default
  4. import QtQuick
  5. import Qt5Compat.GraphicalEffects.private
  6. Item {
  7. id: rootItem
  8. property variant source
  9. property real radius: 0.0
  10. property int maximumRadius: 0
  11. property real spread: 0.0
  12. property color color: "white"
  13. property bool cached: false
  14. property bool transparentBorder: false
  15. SourceProxy {
  16. id: sourceProxy
  17. input: rootItem.source
  18. sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0)
  19. }
  20. ShaderEffectSource {
  21. id: cacheItem
  22. anchors.fill: shaderItem
  23. visible: rootItem.cached
  24. smooth: true
  25. sourceItem: shaderItem
  26. live: true
  27. hideSource: visible
  28. }
  29. GaussianDirectionalBlur {
  30. id: shaderItem
  31. x: transparentBorder ? -maximumRadius - 1 : 0
  32. y: transparentBorder ? -maximumRadius - 1 : 0
  33. width: horizontalBlur.width
  34. height: horizontalBlur.height
  35. horizontalStep: 0.0
  36. verticalStep: 1.0 / parent.height
  37. source: horizontalBlur
  38. radius: rootItem.radius
  39. maximumRadius: rootItem.maximumRadius
  40. transparentBorder: rootItem.transparentBorder
  41. enableColor: true
  42. color: rootItem.color
  43. spread: rootItem.spread
  44. }
  45. GaussianDirectionalBlur {
  46. id: horizontalBlur
  47. width: transparentBorder ? parent.width + 2 * maximumRadius + 2 : parent.width
  48. height: transparentBorder ? parent.height + 2 * maximumRadius + 2 : parent.height
  49. horizontalStep: 1.0 / parent.width
  50. verticalStep: 0.0
  51. source: sourceProxy.output
  52. radius: rootItem.radius
  53. maximumRadius: rootItem.maximumRadius
  54. transparentBorder: rootItem.transparentBorder
  55. visible: false
  56. }
  57. }