aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarko Niemelä <marko.a.niemela@nokia.com>2012-01-16 13:48:23 +0200
committerMarko Niemelä <marko.a.niemela@nokia.com>2012-01-16 13:48:23 +0200
commit8e68fea33a7881bd3da511d353a2d83942a43b44 (patch)
tree8f87bb76590d08377ed3564052ef7016be8536fc
parent3657d0ab5ff2914b3d62afdec28663019eec6274 (diff)
DropShadow and Glow effect changed to draw also original pixels
-rw-r--r--doc/src/qtgraphicaleffects-dropshadow.qdoc3
-rw-r--r--doc/src/qtgraphicaleffects-glow.qdoc8
-rw-r--r--doc/src/snippets/DropShadow-example.qml15
-rw-r--r--doc/src/snippets/Glow-example.qml15
-rw-r--r--src/effects/DropShadow.qml43
-rw-r--r--src/effects/Glow.qml5
-rw-r--r--tests/manual/testbed/TestDropShadow.qml13
-rw-r--r--tests/manual/testbed/TestGlow.qml13
8 files changed, 73 insertions, 42 deletions
diff --git a/doc/src/qtgraphicaleffects-dropshadow.qdoc b/doc/src/qtgraphicaleffects-dropshadow.qdoc
index 8b57a0a..9921f60 100644
--- a/doc/src/qtgraphicaleffects-dropshadow.qdoc
+++ b/doc/src/qtgraphicaleffects-dropshadow.qdoc
@@ -29,7 +29,8 @@
\qmlclass DropShadow
\inqmlmodule QtGraphicalEffects
\brief Generates a colorized and blurred shadow image of the
- source.
+ source and places it behind the original, giving the impression that
+ source item is raised from the background.
By default the effect produces a high quality shadow image, thus the
rendering speed of the shadow might not be the highest possible. The
diff --git a/doc/src/qtgraphicaleffects-glow.qdoc b/doc/src/qtgraphicaleffects-glow.qdoc
index 8e41447..7674e90 100644
--- a/doc/src/qtgraphicaleffects-glow.qdoc
+++ b/doc/src/qtgraphicaleffects-glow.qdoc
@@ -28,12 +28,12 @@
/*!
\qmlclass Glow
\inqmlmodule QtGraphicalEffects
- \brief Generates a blurred and colorized image of the source, which gives
- the impression that the source is glowing.
+ \brief Generates a blurred and colorized image of the source and places it
+ behind the original, giving impression that the source is glowing.
By default effect produces a high quality glow image, thus the rendering
- speed of the shadow may not be the highest possible. The rendering speed is
- reduced especially if the shadow edges are heavily softened.
+ speed of the effect may not be the highest possible. The rendering speed is
+ reduced especially if the glow edges are heavily softened.
For use cases that require faster rendering speed and the highest possible
visual quality is not necessary, property \l fast can be set to true.
diff --git a/doc/src/snippets/DropShadow-example.qml b/doc/src/snippets/DropShadow-example.qml
index f9d47e5..813ab5f 100644
--- a/doc/src/snippets/DropShadow-example.qml
+++ b/doc/src/snippets/DropShadow-example.qml
@@ -50,6 +50,14 @@ Item {
anchors.fill: parent
}
+ Image {
+ id: butterfly
+ source: "images/butterfly.png"
+ sourceSize: Qt.size(parent.width, parent.height)
+ smooth: true
+ visible: false
+ }
+
DropShadow {
anchors.fill: butterfly
horizontalOffset: 3
@@ -59,12 +67,5 @@ Item {
color: "#80000000"
source: butterfly
}
-
- Image {
- id: butterfly
- source: "images/butterfly.png"
- sourceSize: Qt.size(parent.width, parent.height)
- smooth: true
- }
}
//! [example]
diff --git a/doc/src/snippets/Glow-example.qml b/doc/src/snippets/Glow-example.qml
index ede64ce..ebd84ab 100644
--- a/doc/src/snippets/Glow-example.qml
+++ b/doc/src/snippets/Glow-example.qml
@@ -51,6 +51,14 @@ Item {
color: "black"
}
+ Image {
+ id: butterfly
+ source: "images/butterfly.png"
+ sourceSize: Qt.size(parent.width, parent.height)
+ smooth: true
+ visible: false
+ }
+
Glow {
anchors.fill: butterfly
radius: 8
@@ -58,12 +66,5 @@ Item {
color: "white"
source: butterfly
}
-
- Image {
- id: butterfly
- source: "images/butterfly.png"
- sourceSize: Qt.size(parent.width, parent.height)
- smooth: true
- }
}
//! [example]
diff --git a/src/effects/DropShadow.qml b/src/effects/DropShadow.qml
index a88b3c2..5f2a43e 100644
--- a/src/effects/DropShadow.qml
+++ b/src/effects/DropShadow.qml
@@ -54,18 +54,43 @@ Item {
property bool cached: false
property bool transparentBorder: false
- Glow {
+ Loader {
x: rootItem.horizontalOffset
y: rootItem.verticalOffset
width: parent.width
height: parent.height
- source: rootItem.source
- radius: rootItem.radius
- samples: rootItem.samples
- color: rootItem.color
- cached: rootItem.cached
- spread: rootItem.spread
- transparentBorder: rootItem.transparentBorder
- fast: rootItem.fast
+ sourceComponent: rootItem.fast ? fastGlow : gaussianGlow
+ }
+
+ Component {
+ id: gaussianGlow
+ GaussianGlow {
+ anchors.fill: parent
+ source: rootItem.source
+ radius: rootItem.radius
+ maximumRadius: rootItem.samples * 0.5
+ color: rootItem.color
+ cached: rootItem.cached
+ spread: rootItem.spread
+ transparentBorder: rootItem.transparentBorder
+ }
+ }
+
+ Component {
+ id: fastGlow
+ FastGlow {
+ anchors.fill: parent
+ source: rootItem.source
+ blur: Math.pow(rootItem.radius / 64.0, 0.4)
+ color: rootItem.color
+ cached: rootItem.cached
+ spread: rootItem.spread
+ transparentBorder: rootItem.transparentBorder
+ }
+ }
+
+ ShaderEffectSource {
+ anchors.fill: parent
+ sourceItem: rootItem.source
}
}
diff --git a/src/effects/Glow.qml b/src/effects/Glow.qml
index d5a9df1..8c65142 100644
--- a/src/effects/Glow.qml
+++ b/src/effects/Glow.qml
@@ -83,4 +83,9 @@ Item {
transparentBorder: rootItem.transparentBorder
}
}
+
+ ShaderEffectSource {
+ anchors.fill: parent
+ sourceItem: rootItem.source
+ }
}
diff --git a/tests/manual/testbed/TestDropShadow.qml b/tests/manual/testbed/TestDropShadow.qml
index dc5dff4..cd4c6b3 100644
--- a/tests/manual/testbed/TestDropShadow.qml
+++ b/tests/manual/testbed/TestDropShadow.qml
@@ -43,6 +43,12 @@ import "../../../src/effects"
TestCaseTemplate {
+ ImageSource {
+ id: imageSource
+ source: "images/butterfly.png"
+ anchors.centerIn: parent
+ }
+
DropShadow {
id: effect
horizontalOffset: (offsetPicker.xValue - 0.5) * width
@@ -58,13 +64,6 @@ TestCaseTemplate {
fast: fastCheckBox.selected
}
- ImageSource {
- id: imageSource
- source: "images/butterfly.png"
- anchors.centerIn: parent
- opacity: 1.0
- }
-
PositionPicker {
id: offsetPicker
xValue: 0.51
diff --git a/tests/manual/testbed/TestGlow.qml b/tests/manual/testbed/TestGlow.qml
index 3eeedfc..d43f60d 100644
--- a/tests/manual/testbed/TestGlow.qml
+++ b/tests/manual/testbed/TestGlow.qml
@@ -43,6 +43,12 @@ import "../../../src/effects"
TestCaseTemplate {
+ ImageSource {
+ id: imageSource
+ source: "images/butterfly.png"
+ anchors.centerIn: parent
+ }
+
Glow {
id: effect
anchors.fill: imageSource
@@ -56,13 +62,6 @@ TestCaseTemplate {
source: imageSource
}
- ImageSource {
- id: imageSource
- source: "images/butterfly.png"
- anchors.centerIn: parent
- opacity: 1.0
- }
-
bgColor: bgColorPicker.color
controls: [
Control {