DropShadowBase.qml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2017 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
  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. import Qt5Compat.GraphicalEffects
  7. Item {
  8. id: root
  9. property variant source
  10. property real radius: Math.floor(samples / 2)
  11. property int samples: 9
  12. property color color: "black"
  13. property real horizontalOffset: 0
  14. property real verticalOffset: 0
  15. property real spread: 0.0
  16. property bool cached: false
  17. property bool transparentBorder: true
  18. GaussianBlur {
  19. id: blur
  20. width: parent.width
  21. height: parent.height
  22. x: Math.round(horizontalOffset)
  23. y: Math.round(verticalOffset)
  24. source: root.source
  25. radius: root.radius * Screen.devicePixelRatio
  26. samples: root.samples * Screen.devicePixelRatio
  27. _thickness: root.spread
  28. transparentBorder: root.transparentBorder
  29. _color: root.color;
  30. _alphaOnly: true
  31. // ignoreDevicePixelRatio: root.ignoreDevicePixelRatio
  32. ShaderEffect {
  33. x: blur._outputRect.x - parent.x
  34. y: blur._outputRect.y - parent.y
  35. width: transparentBorder ? blur._outputRect.width : blur.width
  36. height: transparentBorder ? blur._outputRect.height : blur.height
  37. property variant source: blur._output;
  38. }
  39. }
  40. ShaderEffectSource {
  41. id: cacheItem
  42. x: -blur._kernelRadius + horizontalOffset
  43. y: -blur._kernelRadius + verticalOffset
  44. width: blur.width + 2 * blur._kernelRadius
  45. height: blur.height + 2 * blur._kernelRadius
  46. visible: root.cached
  47. smooth: true
  48. sourceRect: Qt.rect(-blur._kernelRadius, -blur._kernelRadius, width, height);
  49. sourceItem: blur
  50. hideSource: visible
  51. }
  52. }