1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Graphical Effects module.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\qmlclass FastDropShadow
\inqmlmodule QtGraphicalEffects
\brief Generates a fast shadow image of the source.
FastDropShadow is intended to be fast to render. It means that the quality
of the shadow may not be highest possible, especially if the shadow edges
are softened. For situations where a high visual quality is required, consider
\l {QtGraphicalEffects::DropShadow}{DropShadow} effect.
\table
\header
\o Source
\o Effect applied
\row
\o \image Original_butterfly.png
\o \image FastDropShadow_butterfly.png
\endtable
\section1 Example
The following example shows the usage of some of the items common properties.
\snippet snippets/FastDropShadow-example.qml example
\section1 Memory consumption
The internal memory consumption is approximately twice the memory
consumption of the the source item area in pixels.
If source item is not Image or ShaderEffectSource, then effect internally creates one ShaderEffectSource item per source.
Enabling the effect cache increases the memory consumption because an extra
buffer is allocated for the effect output.
\table
\header
\o Estimated memory usage for an effect with a size of 640x480 pixels with 32 bits per pixel (bpp)
\o
\row
\o Effect internal
\o 2.4 MB
\row
\o ShaderEffectSource (if used)
\o 1.2 MB
\row
\o Effect internal cache (if enabled)
\o 1.2 MB
\row
\o TOTAL (max)
\o 4.8 MB
\endtable
*/
/*!
\qmlproperty variant QtGraphicalEffects::FastDropShadow::source
This property defines the source item that is going to be used as source for
the generated shadow.
*/
/*!
\qmlproperty real QtGraphicalEffects::FastDropShadow::blur
BlurLevel defines the softness of the shadow edge. The value of 0.0
represents the shadow as sharp. The value of 1.0 softens the shdow edges
maximally.
The value ranges from 0.0 (no blur) to 1.0 (maximum blur). By default the
property is set to \c 0.0 (no blur).
\table
\header
\o Output examples with different blur values
\o
\o
\row
\o \image FastDropShadow_blur1.png
\o \image FastDropShadow_blur2.png
\o \image FastDropShadow_blur3.png
\row
\o \bold { blur: 0.0 }
\o \bold { blur: 0.5 }
\o \bold { blur: 0.8 }
\row
\o \l color: #000000
\o \l color: #000000
\o \l color: #000000
\row
\o \l horizontalOffset: 0
\o \l horizontalOffset: 0
\o \l horizontalOffset: 0
\row
\o \l verticalOffset: 20
\o \l verticalOffset: 20
\o \l verticalOffset: 20
\row
\o \l spread: 0
\o \l spread: 0
\o \l spread: 0
\endtable
*/
/*!
\qmlproperty real QtGraphicalEffects::FastDropShadow::spread
This property defines how large part of the glow color is strenghtened near
the source edges.
The value ranges from 0.0 to 1.0. By default, the property is set to \c 0.5.
\table
\header
\o Output examples with different spread values
\o
\o
\row
\o \image FastDropShadow_spread1.png
\o \image FastDropShadow_spread2.png
\o \image FastDropShadow_spread3.png
\row
\o \bold { spread: 0.0 }
\o \bold { spread: 0.5 }
\o \bold { spread: 0.8 }
\row
\o \l blur: 0.5
\o \l blur: 0.5
\o \l blur: 0.5
\row
\o \l color: #000000
\o \l color: #000000
\o \l color: #000000
\row
\o \l horizontalOffset: 0
\o \l horizontalOffset: 0
\o \l horizontalOffset: 0
\row
\o \l verticalOffset: 20
\o \l verticalOffset: 20
\o \l verticalOffset: 20
\endtable
*/
/*!
\qmlproperty color QtGraphicalEffects::FastDropShadow::color
This property defines the RGBA color value which is used for the shadow.
By default, the property is set to \c "black".
\table
\header
\o Output examples with different color values
\o
\o
\row
\o \image FastDropShadow_color1.png
\o \image FastDropShadow_color2.png
\o \image FastDropShadow_color3.png
\row
\o \bold { color: #000000 }
\o \bold { color: #0000ff }
\o \bold { color: #aa000000 }
\row
\o \l blur: 0.5
\o \l blur: 0.5
\o \l blur: 0.5
\row
\o \l horizontalOffset: 0
\o \l horizontalOffset: 0
\o \l horizontalOffset: 0
\row
\o \l verticalOffset: 20
\o \l verticalOffset: 20
\o \l verticalOffset: 20
\row
\o \l spread: 0
\o \l spread: 0
\o \l spread: 0
\endtable
*/
/*!
\qmlproperty real QtGraphicalEffects::FastDropShadow::horizontalOffset
\qmlproperty real QtGraphicalEffects::FastDropShadow::verticalOffset
HorizontalOffset and verticalOffset properties define the offset for the
rendered shadow compared to the DropShadow item position. Often, the
DropShadow item is anchored so that it fills the source element. In this
case, if the HorizontalOffset and verticalOffset properties are set to 0 the
shadow is rendered exactly under the source item. By changing the offset
properties, the shadow can be positioned relatively to the source item.
The values range from -inf to inf. By default, these properties are set to \c 0.
\table
\header
\o Output examples with different horizontalOffset values
\o
\o
\row
\o \image FastDropShadow_horizontalOffset1.png
\o \image FastDropShadow_horizontalOffset2.png
\o \image FastDropShadow_horizontalOffset3.png
\row
\o \bold { horizontalOffset: -20 }
\o \bold { horizontalOffset: 0 }
\o \bold { horizontalOffset: 20 }
\row
\o \l blur: 0.5
\o \l blur: 0.5
\o \l blur: 0.5
\row
\o \l color: #000000
\o \l color: #000000
\o \l color: #000000
\row
\o \l verticalOffset: 0
\o \l verticalOffset: 0
\o \l verticalOffset: 0
\row
\o \l spread: 0
\o \l spread: 0
\o \l spread: 0
\endtable
*/
/*!
\qmlproperty bool QtGraphicalEffects::FastDropShadow::cached
This property allows the effect output pixels to be cached in order to
improve rendering performance. After the effect has been rendered into a
cache, drawing the effect into display can be done using the cached pixels,
which is very fast.
However every time when the source or effect properties are changed, the
pixels in the cache need to be updated. Another drawback of the caching is
the increased memory consumption, extra buffer of memory is required for
storing the effect output.
A rule of thumb for using the cache would be that it should be disabled when
the source or the effect properties are animated, otherwise it should be
enabled.
By default the property is set to \c false.
*/
|