1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Interface for Scene Elements |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @publishedPartner |
|
20 @prototype |
|
21 */ |
|
22 |
|
23 #ifndef WSELEMENT_H |
|
24 #define WSELEMENT_H |
|
25 |
|
26 #include <w32std.h> |
|
27 #include <graphics/wsgraphicdrawerinterface.h> |
|
28 #include <graphics/surface.h> |
|
29 |
|
30 /** |
|
31 * @brief Window Server Scene Element Interface Definition |
|
32 * |
|
33 * This interface allows Image Sources to be associated with meta-data |
|
34 * to define how the Image Source must be presented within a Scene. |
|
35 * |
|
36 * For a conceptual overview of Scenes, refer to the @c MWsScene Interface. |
|
37 * |
|
38 * The following aspects of Image Source presentation may be controlled: |
|
39 * @li Source rectangular region |
|
40 * @li Destination rectangular region |
|
41 * @li Rotation and flipping |
|
42 * @li Opacity |
|
43 * @li Relative z-order (ordinal position) |
|
44 * @li Tags to descriminate the UI from other Elements |
|
45 * |
|
46 * All co-ordinates are pixels offsets from (0,0) representing the |
|
47 * top level of the Image Source or Destination Target (the screen |
|
48 * or an off-screen buffer representing the screen), moving rightwards |
|
49 * and downwards in x and y co-ordinates respectively. |
|
50 * |
|
51 * Elements can be marked with flags. There are two different consumers |
|
52 * of flags: Target Renderers and Render Stage Plug-ins. |
|
53 * |
|
54 * Target Renderers are sub-systems which actually do composition and |
|
55 * rendering on a particular display device or off-screen buffer. |
|
56 * The EElementTransparencySource flag tells the Target Renderer that |
|
57 * alpha blending must use the alpha channel in the Surface connected to |
|
58 * the Element. |
|
59 * |
|
60 * On the other hand, Render Stage Plug-ins need flags to implement |
|
61 * specific policies such as "UI always on top". To facilitate this, |
|
62 * Elements have a EElementIsIndirectlyRenderedUserInterface or a |
|
63 * EElementIsDirectlyRenderedUserInterface optionally set. This |
|
64 * flag allows Render Stage Plug-ins to keep the relative z-order |
|
65 * of Elements aligned to this policy. |
|
66 * |
|
67 * To allow compatible updates to be made to flags, all Render Stage |
|
68 * Plug-ins must preserve the flags in Elements which they do not operate |
|
69 * upon. Target Renderers may ignore the flags in Elements which they |
|
70 * do not operate on. |
|
71 * |
|
72 * <h2>Intial State</h2> |
|
73 * |
|
74 * The initial state for an Element is: |
|
75 * @li Fully opaque |
|
76 * @li No rotation, nor flipped |
|
77 * @li Not part of the Committed Scene |
|
78 * @li No connected Surface |
|
79 * @li All flags reset |
|
80 * @li Local error value set as KErrNone |
|
81 * @li Source Rectangle and Destination Rectangle is (0,0,0,0) |
|
82 * @il Destination Clipping Rectangle is (0,0,0,0) |
|
83 * |
|
84 * When an Image Source is connected, the initial state becomes: |
|
85 * @li Source Rectangle is the extent of the Image Source |
|
86 * @li Destination Rectangle is set at origin (0,0), whose sized equals the |
|
87 * Image Source size truncated the the target screen size. |
|
88 * @li Destination Clipping Rectangle is (0,0,0,0) to represent the entire |
|
89 * area of the target screen. |
|
90 * |
|
91 * <h2>Special Rectangle Values</h2> |
|
92 * |
|
93 * Sometimes it is desirable to reset a Source, Destination, or Clipping |
|
94 * Rectangle so that the actual value used matches the corresponding Source |
|
95 * Image or Target Screen size. In such cases rectangle (0,0,0,0) is used to |
|
96 * represent this. |
|
97 * |
|
98 * <h2>Extending this interface</h2> |
|
99 * |
|
100 * This interface can be extended in two different ways |
|
101 * @li Creating optional extension interfaces with |
|
102 * MWsElement::MWsObjectProvider::ResolveObjectInterface() |
|
103 * @li Defining new TElementFlags flag settings; Render Stage Plug-ins |
|
104 * preserve the value of these across the Render Stage Pipeline. |
|
105 * |
|
106 * <h2>Committed Elements versus Pending Elements</h2> |
|
107 * |
|
108 * This interface allows Elements to be modified in terms of their |
|
109 * own flag settings, and rotation, as well as their relative position |
|
110 * with other Elements. Queries return the pending values for such |
|
111 * Elements. Any modifications are marked Pending, and affect the Scene |
|
112 * according to the rules described by "Rendering" in @c MWsScene. |
|
113 * |
|
114 * <h2>Order in which transformations are applied</h2> |
|
115 * |
|
116 * A number of different transformations may be specified for an Element. |
|
117 * The order in which these are applied to arrive at the view seen in |
|
118 * the target is: |
|
119 * -# SetSourceRectangle (Cropping) |
|
120 * -# SetSourceFlipping (Flipping) |
|
121 * -# SetSourceRotation (Rotation) |
|
122 * -# SetDestinationRectangle (Scaling and Positioning) |
|
123 * -# SetDestinationClippingRectangle (Scaling and Positioning) |
|
124 * -# SetGlobalAlpha (Blending) |
|
125 */ |
|
126 class MWsElement : public MWsObjectProvider |
|
127 { |
|
128 public: |
|
129 |
|
130 /** |
|
131 * @brief Flags used by Target Renderers. |
|
132 */ |
|
133 enum TElementTargetRendererFlags |
|
134 { |
|
135 /** |
|
136 * Target renderer must treat the Element as Opaque. |
|
137 */ |
|
138 EElementTransparencyNone = 0, |
|
139 /** |
|
140 * Target renderer must use the Global Alpha Transparency value |
|
141 * from the Element |
|
142 */ |
|
143 EElementTransparencyGlobalAlpha = (1 << 0), |
|
144 /** |
|
145 * Target renderer must use the Alpha Transparency Channel from |
|
146 * the Element |
|
147 */ |
|
148 EElementTransparencySource = (1 << 1), |
|
149 /** |
|
150 * Reserved flag value; this must not be set. |
|
151 */ |
|
152 EElementTargetRendererReserved = (1 << 2) |
|
153 }; |
|
154 |
|
155 /** |
|
156 * @brief Flags used by Render Stages. |
|
157 */ |
|
158 enum TElementRenderStageFlags |
|
159 { |
|
160 /** |
|
161 * No flag value set for Render Stage Plug-in |
|
162 */ |
|
163 EElementRenderStageNone = 0, |
|
164 /** |
|
165 * Indirectly Rendered User Interface, i.e. rendering via |
|
166 * MWsGraphicsContext calls originating from client CWindowGc |
|
167 * commands |
|
168 */ |
|
169 EElementIsIndirectlyRenderedUserInterface = (1 << 0), |
|
170 /** |
|
171 * Directly Render User Interface, i.e. rendering where Window |
|
172 * Server does not see the graphics commands, as is the case for |
|
173 * Direct Screen Access clients. |
|
174 */ |
|
175 EElementIsDirectlyRenderedUserInterface = (1 << 1), |
|
176 /** |
|
177 * Reserved values for future Render Stage Plug-in usage |
|
178 */ |
|
179 EElementRenderStageReserved = (1 << 2) |
|
180 }; |
|
181 |
|
182 /** |
|
183 * Amount of rotation of pixel data to apply to the Image Source |
|
184 * to obtain the Target Image |
|
185 */ |
|
186 enum TElementRotation |
|
187 { |
|
188 EElementAntiClockwise0 = 0, /** No rotation */ |
|
189 EElementAntiClockwise90 = 1, /** 90 Degrees Anti-clockwise in target */ |
|
190 EElementAntiClockwise180 = 2, /** 180 Degrees Anti-clockwise in target */ |
|
191 EElementAntiClockwise270 = 3 /** 270 Degrees Anti-clockwise in target */ |
|
192 }; |
|
193 |
|
194 public: |
|
195 /** |
|
196 * @brief Set which portion of the image source is used. |
|
197 * |
|
198 * Set which rectangular portion of the connected image source |
|
199 * will be used when displaying this Element. |
|
200 * |
|
201 * @param aSrc The source rectangle of pixels from the connected Image Source. |
|
202 * This rectangle must not include any pixels outside the Image |
|
203 * Source. (0,0,0,0) means the entire size of the Image Source. |
|
204 * @pre An Image Source must have been connected; @see ConnectSurface() |
|
205 * @return One of the system-wide error codes. |
|
206 * KErrGeneral, if there is no image source connected. |
|
207 * KErrArgument, if the source rectangle includes pixels not in the |
|
208 * connected image source, or has negative width or height. |
|
209 * KErrNone, if successful. |
|
210 */ |
|
211 virtual TInt SetSourceRectangle(const TRect& aSrc) = 0; |
|
212 |
|
213 /** |
|
214 * @brief Get the portion of the Image Source being used. |
|
215 * |
|
216 * Get the portion of the connected Image Source being used. The default |
|
217 * value is the entire extent of the connected Image Source. |
|
218 * |
|
219 * @param aSrc The source rectangle is updated with the current rectangular |
|
220 * region being used within the Image Source. |
|
221 * @pre An Image Source must have been connected; @see ConnectSurface() |
|
222 * @return One of the system-wide error codes. |
|
223 * KErrGeneral, if no Image Source has been connected. |
|
224 * KErrNone, if successful. |
|
225 */ |
|
226 virtual TInt GetSourceRectangle(TRect& aSrc) = 0; |
|
227 |
|
228 /** |
|
229 * @brief Set the target area where the Image Source should appear. |
|
230 * |
|
231 * Set the target area in the target screen (or off-screen buffer) |
|
232 * where the Image Source should appear. Scaling may result if |
|
233 * the source and destination rectangles differ. A platform specific |
|
234 * algorithm will be used to interpolate the scaled image. |
|
235 * |
|
236 * @param aDest The destination rectangle in the target. |
|
237 * @pre An Image Source must have been connected; @see ConnectSurface() |
|
238 * @return One of the system-wide error codes. |
|
239 * KErrGeneral, if there is no image source connected. |
|
240 * KErrArgument, if the destination rectangle has negative width or |
|
241 * height. |
|
242 * KErrNone, if successful. |
|
243 */ |
|
244 virtual TInt SetDestinationRectangle(const TRect& aDest) = 0; |
|
245 |
|
246 /** |
|
247 * @brief Get the target area where the Image Source would appear. |
|
248 * |
|
249 * Get the target area where the Image Source would appear. The default |
|
250 * value is at (0,0) sized to the Image Source clipped to the size |
|
251 * of the target. |
|
252 * |
|
253 * @param aDest The destination rectangle is updated with the current |
|
254 * region used in the target screen. |
|
255 * @pre An Image Source must have been connected; @see ConnectSurface() |
|
256 * @return One of the system-wide error codes. |
|
257 * KErrGeneral, if no Image Source has been connected. |
|
258 * KErrNone, if successful. |
|
259 */ |
|
260 virtual TInt GetDestinationRectangle(TRect& aDest) const = 0; |
|
261 |
|
262 /** |
|
263 * @brief Clip the target area where the Image Source would appear. |
|
264 * |
|
265 * Set clipping area where the Image Source would appear. The default |
|
266 * value is the area of the target screen. |
|
267 * |
|
268 * @param aDestClipRect The clipping rectangle in the target. (0,0,0,0) |
|
269 * means the entire size of the Target Screen. |
|
270 * @return One of the system-wide error codes. |
|
271 * KErrGeneral, if no Image Source has been connected. |
|
272 * KErrArgument, if the rectangle has negative width or height |
|
273 * KErrNone, if successful. |
|
274 */ |
|
275 virtual TInt SetDestinationClippingRect(const TRect& aDestClipRect) = 0; |
|
276 |
|
277 /** |
|
278 * @brief Get the clipping area in the target. |
|
279 * |
|
280 * Get the clipping area which limits where in the target screen the |
|
281 * element may appear. |
|
282 * |
|
283 * @param aDestClipRect The clipping rectangle is updated with the current |
|
284 * clipping area used in the target screen. |
|
285 * @return One of the system-wide error codes. KErrGeneral means no Image |
|
286 * Source has been connected. KErrNone is returned upon success. |
|
287 */ |
|
288 virtual TInt GetDestinationClippingRect(TRect& aDestClipRect) const = 0; |
|
289 |
|
290 /** |
|
291 * @brief Set the rotation that should appear in the target for the |
|
292 * Image Source. |
|
293 * |
|
294 * Set the rotation which describes how the connected Image Source |
|
295 * should be rotated to appear in the target. |
|
296 * |
|
297 * @param aElementRotation The amount of rotation in the target. |
|
298 * @pre An Image Source must have been connected; @see ConnectSurface() |
|
299 * @return One of the system-wide error codes. |
|
300 * KErrGeneral, if no Image Source has been connected. |
|
301 * KErrArgument, if an out of bounds rotation value has been |
|
302 * supplied. |
|
303 * KErrNone, if successful. |
|
304 */ |
|
305 virtual TInt SetSourceRotation(const TElementRotation aElementRotation) = 0; |
|
306 |
|
307 /** |
|
308 * @brief Get the pending rotation setting as it would appear in the target. |
|
309 * |
|
310 * Get the pending rotation setting for the connected Image Source. |
|
311 * By default, the rotation is EElementAntiClockwise0 and this is returned |
|
312 * if there is no connected Image Source. |
|
313 * |
|
314 * @return The pending rotation setting. |
|
315 */ |
|
316 virtual TElementRotation SourceRotation() const = 0 ; |
|
317 |
|
318 /** |
|
319 * @brief Set flipping about the image horizontal centerline. |
|
320 * |
|
321 * Set the pending flipping setting for the connected Image Source. |
|
322 * When flipped, the Image Source appears in the target as inverted |
|
323 * about its horizontal centerline. This effect can be combined |
|
324 * with rotation effects. |
|
325 * By default, the Image Source is not flipped. |
|
326 * |
|
327 * @param aFlip If ETrue, the connected Image is flipped, else |
|
328 * it is not flipped. |
|
329 * @pre An Image Source must have been connected; @see ConnectSurface() |
|
330 * @return One of the system-wide error codes. |
|
331 * KErrGeneral, if no Image Source has been connceted. |
|
332 * KErrNotSupported, if the platform does not support the feature. |
|
333 * KErrNone, if successful. |
|
334 */ |
|
335 virtual TInt SetSourceFlipping(const TBool aFlip) = 0; |
|
336 |
|
337 /** |
|
338 * @brief Get the pending flipping setting. |
|
339 * |
|
340 * Get the pending flipping setting for the connected Image Source. |
|
341 * By default, the image is not flipped. |
|
342 * |
|
343 * @return The pending flipping setting. If no Image is connected, return |
|
344 * EFalse. |
|
345 */ |
|
346 virtual TBool SourceFlipping() const = 0 ; |
|
347 |
|
348 /** |
|
349 * @brief Set Target Renderer Flags associated with this Element |
|
350 * |
|
351 * Set the Target Renderer flags to be associated with this Element. |
|
352 * |
|
353 * @note Flags which are not recognised by an implementation must |
|
354 * be kept to allow the interface to be extended in a |
|
355 * compatible manner. |
|
356 * @param aTargetRendererFlags Flags to set for Target Renderer; |
|
357 * @see TElementTargetRendererFlags |
|
358 * @return One of the system-wide error codes. |
|
359 * KErrNotSupported, if the platform does not support the given |
|
360 * flags. |
|
361 * KErrArgument, if incompatible flag settings have been made. |
|
362 * KErrNone, if successful. |
|
363 */ |
|
364 virtual TInt SetTargetRendererFlags(const TUint32& aTargetRendererFlags) = 0; |
|
365 |
|
366 /** |
|
367 * @brief Set Render Stage Flags associated with this Element |
|
368 * |
|
369 * Set the Render Stage flags to be associated with this Element. |
|
370 * |
|
371 * @note Flags which are not recognised by an implementation must |
|
372 * be kept to allow the interface to be extended in a |
|
373 * compatible manner. |
|
374 * @param aRenderStageFlags Flags to set for Render Stage Plug-ins; |
|
375 * @see TElementRenderStageFlags |
|
376 * @return One of the system-wide error codes. |
|
377 * KErrNotSupported, if the platform does not support the given |
|
378 * flags. |
|
379 * KErrArgument, if incompatible flag settings have been requested. |
|
380 * KErrNone, if successful. |
|
381 */ |
|
382 virtual TInt SetRenderStageFlags(const TUint32& aRenderStageFlags) = 0; |
|
383 |
|
384 /** |
|
385 * @brief Get Target Renderer Flags associated with this Element |
|
386 * |
|
387 * Get the Target Renderer flags associated with this Element. |
|
388 * |
|
389 * @note Flags which are not recognised by an implementation must |
|
390 * be kept to allow the interface to be extended in a |
|
391 * compatible manner. |
|
392 * @param aTargetRendererFlags Variable to receive TElementTargetRendererFlags |
|
393 */ |
|
394 virtual void GetTargetRendererFlags(TUint32& aTargetRendererFlags) const = 0; |
|
395 |
|
396 /** |
|
397 * @brief Get Render Stage Flags associated with this Element |
|
398 * |
|
399 * Get the Render Stage flags associated with this Element. |
|
400 * |
|
401 * @note Flags which are not recognised by an implementation must |
|
402 * be kept to allow the interface to be extended in a |
|
403 * compatible manner. |
|
404 * @param aRenderStageFlags Variable to receive TElementRenderStageFlags |
|
405 */ |
|
406 virtual void GetRenderStageFlags(TUint32& aRenderStageFlags) const = 0; |
|
407 |
|
408 /** |
|
409 * @brief Get the Element above this Element. |
|
410 * |
|
411 * Get the Element which is above this Element in the Pending Scene. |
|
412 * If the Element is the top-most element, NULL is returned. If the |
|
413 * Element is not in the Scene, NULL is returned. |
|
414 * |
|
415 * @return Element above, or NULL. |
|
416 */ |
|
417 virtual MWsElement *ElementAbove() = 0; |
|
418 |
|
419 /** |
|
420 * @brief Get the Element below this Element. |
|
421 * |
|
422 * Get the Element which is below this Element in the Pending Scene. |
|
423 * If the Element is the bottom-most element, NULL is returned. If the |
|
424 * Element is not in the Scene, NULL is returned. |
|
425 * |
|
426 * @return Element below, or NULL. |
|
427 */ |
|
428 virtual MWsElement *ElementBelow() = 0; |
|
429 |
|
430 /** |
|
431 * @brief Connect or re-Connect a Surface to this Element. |
|
432 * |
|
433 * Connect the given Surface to this Element, or re-Connect a new |
|
434 * Surface to this Element which already has a connected Surface. |
|
435 * The Element does not need to be in the Scene when this call is made. |
|
436 * |
|
437 * @note The Source Rectangle of the Element is updated to correspond |
|
438 * to match the Source Rectangle of the Surface. Thus any |
|
439 * prior Source Rectangle setting will be overwritten. |
|
440 * |
|
441 * @param aSurface Surface to connect to. If this is the Null |
|
442 * Surface, then the Source Rectangle of the |
|
443 * Element is set to (0,0,0,0). |
|
444 * @return One of the system-wide error codes. |
|
445 * KErrArgument, if supplied Surface cannot be connected. For |
|
446 * example the Element has a flag indicating it has an Alpha |
|
447 * Channel but the Surface does not. |
|
448 * KErrNone, if successful. |
|
449 */ |
|
450 virtual TInt ConnectSurface(const TSurfaceId& aSurface) = 0; |
|
451 |
|
452 /** |
|
453 * @brief Get the Surface connected to this Element |
|
454 * |
|
455 * @return The Surface Identifier of the Connected Surface. This |
|
456 * identifier may represent the Null Surface Id if there |
|
457 * was no Surface connected in the Pending Scene for this |
|
458 * Element. |
|
459 */ |
|
460 virtual const TSurfaceId& ConnectedSurface() const = 0; |
|
461 |
|
462 /** |
|
463 * @brief Set the Global Alpha Transparency value |
|
464 * |
|
465 * Sets the Global Alpha Transparency value for this Element. Elements |
|
466 * are by default fully opaque, represented by opacity 255. On platforms |
|
467 * that support it, the Alpha Transparency value can be reduced down |
|
468 * to 0 representing fully transparent. The purpose of this is to |
|
469 * allow the fading in and fading out of Elements into the Scene. |
|
470 * |
|
471 * @param aAlpha The Alpha Transparency value desired. Values |
|
472 * are clamped to be within the range [0, 255] where 0 |
|
473 * represents fully transparent, and 255 represents |
|
474 * fully opaque. |
|
475 * @note This setting has no effect unless the flag |
|
476 * Target Renderer flag EElementTransparencyGlobalAlpha |
|
477 * is set; @see SetTargetRendererFlags() |
|
478 * @note Out of range values are clamped silently, and do not cause |
|
479 * error conditions. |
|
480 * @return One of the system-wide error codes. |
|
481 * KErrNotSupported, if the supplied value, once clamped, is not |
|
482 * supported on the platform. |
|
483 * KErrNone, if successful. |
|
484 */ |
|
485 virtual TInt SetGlobalAlpha(const TInt aAlpha) = 0; |
|
486 |
|
487 /** |
|
488 * @brief Get the Global Alpha Transparency value |
|
489 * |
|
490 * Gets the Global Alpha Transparency value for this Element. Elements |
|
491 * are by default fully opaque, represented by opacity 255. |
|
492 * |
|
493 * @param aAlpha Variable which receives the Global Alpha Transparency |
|
494 * value. |
|
495 */ |
|
496 virtual void GlobalAlpha(TInt& aAlpha) const = 0; |
|
497 }; |
|
498 #endif // WSELEMENT_H |
|