|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Declares HuiUtil class, a collection of utility routines for HUITK. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUIUTIL_H__ |
|
21 #define __HUIUTIL_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <gdi.h> |
|
26 |
|
27 #include <uiacceltk/HuiRealSize.h> // for HUI_ROUND_FLOAT_TO_INT macro |
|
28 #include <uiacceltk/HuiImageVisual.h> |
|
29 |
|
30 const TUint KHuiAntialiasing = 0x00000001; // antialiasing enabled (bit mask) |
|
31 |
|
32 _LIT(KHuiUserInvariant, "User::Invariant"); // max 16 characters |
|
33 |
|
34 #define USER_INVARIANT() \ |
|
35 ( RDebug::Printf("User::Invariant in "__FILE__" on line %i", __LINE__), \ |
|
36 User::Panic(KHuiUserInvariant, 0) ) |
|
37 |
|
38 /* Forward declarations. */ |
|
39 class THuiRealPoint; |
|
40 class TAknFontSpecification; |
|
41 class THuiFont; |
|
42 class CHuiDisplay; |
|
43 |
|
44 |
|
45 /** |
|
46 * HuiUtil is a collection of utility routines for HUITK. |
|
47 * Many of the utility routines are mathematical operations such as |
|
48 * the calculation of a vector cross product or linear interpolation between two |
|
49 * values. |
|
50 * |
|
51 * HuiUtil contains only static member functions. It cannot be instantiated. |
|
52 */ |
|
53 NONSHARABLE_CLASS(HuiUtil) |
|
54 { |
|
55 public: |
|
56 |
|
57 /** @beginAPI */ |
|
58 |
|
59 /** |
|
60 * Calculates the smallest power-of-two that is equal to or greater than |
|
61 * a value (rounds value up to the nearest power-of-two). |
|
62 * |
|
63 * @param aValue Integer value. |
|
64 * |
|
65 * @return Smallest power-of-two that is equal to or greater than |
|
66 * <code>aValue</code>. |
|
67 * |
|
68 * @see Power2RoundDown() for down-rounding equivalent. |
|
69 */ |
|
70 IMPORT_C static TInt Power2(TInt aValue); |
|
71 |
|
72 /** |
|
73 * Calculates the largest power-of-two that is equal to or smaller than |
|
74 * a value (rounds the value down to nearest power-of-two). |
|
75 * |
|
76 * @param aValue Integer value. |
|
77 * |
|
78 * @return Smallest power-of-two that is equal to or greater than |
|
79 * <code>aValue</code>. |
|
80 */ |
|
81 IMPORT_C static TInt Power2RoundDown(TInt aValue); |
|
82 |
|
83 /** |
|
84 * Interpolates between two values. Calculates a linear interpolation |
|
85 * between a minimum and maximum value. |
|
86 * |
|
87 * @param aPos Position. 0.0 corresponds to the minimum value, 1.0 |
|
88 * corresponds to the maximum value. Positions outside this |
|
89 * range are allowed, which results in extrapolation. |
|
90 * @param aMin Minimum value. |
|
91 * @param aMax Maximum value. |
|
92 * |
|
93 * @return Interpolated value. |
|
94 */ |
|
95 IMPORT_C static TReal32 Interpolate(TReal32 aPos, TReal32 aMin, TReal32 aMax) __SOFTFP; |
|
96 |
|
97 /** |
|
98 * Wraps a value to a range. |
|
99 * |
|
100 * @param aValue Reference to the value to wrap. Will be modified. |
|
101 * @param aLow Range minimum. If aValue is equal to aLow, it will remain |
|
102 * at aLow. |
|
103 * @param aHigh Range maximum. If aValue is equal to aHigh, it will be |
|
104 * wrapped to aLow. |
|
105 */ |
|
106 IMPORT_C static void WrapValue(TReal32& aValue, TReal32 aLow, TReal32 aHigh) __SOFTFP; |
|
107 |
|
108 /** |
|
109 * Generates a random integer. |
|
110 * |
|
111 * @param aMin Minimum possible value. |
|
112 * @param aMax Maximum possible value. |
|
113 * |
|
114 * @return Random integer between the minimum and maximum values, |
|
115 * inclusive. |
|
116 */ |
|
117 IMPORT_C static TInt RandomInt(TInt aMin, TInt aMax); |
|
118 |
|
119 /** |
|
120 * Generates a random real number. |
|
121 * |
|
122 * @param aMin Minimum possible value. |
|
123 * @param aMax Maximum possible value. |
|
124 * |
|
125 * @return Random real number between the minimum and maximum values, |
|
126 * inclusive. |
|
127 */ |
|
128 IMPORT_C static TReal32 RandomReal(TReal32 aMin, TReal32 aMax) __SOFTFP; |
|
129 |
|
130 /** |
|
131 * Approximates the length of a 2D vector. This is done without |
|
132 * calculating a square root. |
|
133 * |
|
134 * @param aVector 2D vector as a point. The X and Y components are |
|
135 * interpreted as deltas. |
|
136 * |
|
137 * @return Approximate length of the vector. |
|
138 */ |
|
139 IMPORT_C static TReal32 QuickLength(THuiRealPoint& aVector) __SOFTFP; |
|
140 |
|
141 /** |
|
142 * Approximates the length of a 2D vector. This is done without |
|
143 * calculating a square root. |
|
144 * |
|
145 * @param aDx X delta of the vector. |
|
146 * @param aDy Y delta of the vector. |
|
147 * |
|
148 * @return Approximate length of the vector. |
|
149 */ |
|
150 IMPORT_C static TReal32 QuickLength(TReal32 aDx, TReal32 aDy) __SOFTFP; |
|
151 |
|
152 /** |
|
153 * Normalizes a vector so that its length will be approximately 1.0. |
|
154 * This is done without calculating a square root. |
|
155 * |
|
156 * @param aVector 2D vector to be normalized as a point. The X and Y |
|
157 * components are interpreted as deltas. Will be modified. |
|
158 */ |
|
159 IMPORT_C static void QuickNormalize(THuiRealPoint& aVector); |
|
160 |
|
161 /** |
|
162 * Normalizes a vector so that its length will be approximately 1.0. |
|
163 * This is done without calculating a square root. |
|
164 * |
|
165 * @param aVector 3D vector to be normalized as a point (X, Y, Z components |
|
166 * as an array of TReal32). Will be modified. |
|
167 */ |
|
168 IMPORT_C static void QuickNormalize(TReal32 aVector[3]); |
|
169 |
|
170 /** |
|
171 * Calculates a cross product of 3D vectors. aProduct = aA x aB. |
|
172 * |
|
173 * @param aA 3D vector. |
|
174 * @param aB 3D vector. |
|
175 * @param aProduct 3D vector where the cross product is returned. |
|
176 */ |
|
177 IMPORT_C static void CrossProduct(const TReal32 aA[3], const TReal32 aB[3], TReal32 aProduct[3]); |
|
178 |
|
179 /** |
|
180 * Calculates a normal vector for a plane defined by three points. |
|
181 * |
|
182 * @param aPoints Array of three 3D vectors. The first index is the number |
|
183 * of the vector, the second index is the vector component |
|
184 * (x, y, z). |
|
185 * @param aNormal Resulting normal vector. |
|
186 */ |
|
187 IMPORT_C static void NormalFromPoints(const TReal32 aPoints[3][3], TReal32 aNormal[3]); |
|
188 |
|
189 /** |
|
190 * Calculates a matrix that projects 3D points onto a plane. The name |
|
191 * ShadowMatrix comes from the intended usage: when used as a modelview |
|
192 * matrix, this matrix will flatten a 3D mesh onto a projected shadow. |
|
193 * |
|
194 * @param aPlanePoint Point on the plane onto which the shadow is casted. |
|
195 * @param aPlaneNormal Normal of the plane onto which the shadow is casted. |
|
196 * @param aLightPos Position of the light source. |
|
197 * @param aDestMat Resulting matrix. |
|
198 */ |
|
199 IMPORT_C static void ShadowMatrix(const TReal32 aPlanePoint[3], |
|
200 const TReal32 aPlaneNormal[3], |
|
201 const TReal32 aLightPos[4], |
|
202 TReal32 aDestMat[16]); |
|
203 |
|
204 /** |
|
205 * Determines the amount of free memory in the system. |
|
206 * |
|
207 * @param aTotalMemory If not NULL, the total amount of memory is |
|
208 * returned here. |
|
209 * |
|
210 * @return Bytes of free memory. |
|
211 */ |
|
212 IMPORT_C static TUint FreeMemory(TUint* aTotalMemory = 0); |
|
213 |
|
214 /** |
|
215 * Determines the native resolution of the device's screen. |
|
216 * |
|
217 * @return Screen size in pixels. |
|
218 */ |
|
219 IMPORT_C static TSize ScreenSize(); |
|
220 |
|
221 |
|
222 /** |
|
223 * Calculates a display size dependent length unit. This can be used for |
|
224 * layout calculations that should be independent of the display size. |
|
225 * For example, this could be the distance at which a shadow is drawn |
|
226 * behind text strings (assuming the font size also depends on display |
|
227 * size). |
|
228 * |
|
229 * @return Length unit. |
|
230 */ |
|
231 IMPORT_C static TReal32 LengthUnit() __SOFTFP; |
|
232 |
|
233 /** |
|
234 * Approximates the lightness of a color. The returned value is in range |
|
235 * 0...1, where 0.0 means the equivalent of black and 1.0 means the |
|
236 * equivalent of white. This is similar to the Value component in the HSV |
|
237 * color model (but not exactly the same). |
|
238 * |
|
239 * @param aColor Color whose lightness is to be evaluated. |
|
240 * |
|
241 * @return Lightness value. |
|
242 */ |
|
243 IMPORT_C static TReal32 ColorLightness(const TRgb& aColor) __SOFTFP; |
|
244 |
|
245 /** |
|
246 * Resamples given FBS bitmap to new size (converting |
|
247 * color modes along the way..) |
|
248 * @param aSrcBitmap Source bitmap to resample. |
|
249 * @param aScaledBitmap Output bitmap. The original size of |
|
250 * this CFbsBitmap defines the size of the downscaled bitmap. |
|
251 */ |
|
252 IMPORT_C static void ScaleFbsBitmapL(const CFbsBitmap & aSrcBitmap, |
|
253 CFbsBitmap & aScaledBitmap); |
|
254 |
|
255 /** |
|
256 * Converts separate mask and color bitmaps into single |
|
257 * EColor16MA (24bpp colour plus 8bpp alpha) bitmap. |
|
258 * @param aBitmap Source color channel bitmap. |
|
259 * @param aMaskBitmap The source alpha mask bitmap. Use either a black and |
|
260 * white (binary) mask bitmap, or if aMaskBitmap's display mode is EGray256, |
|
261 * alpha blending is used. Use of any other mode may result in unpredictable |
|
262 * results. |
|
263 * @param aCombinedBitmap Bitmap that will to contain the target |
|
264 * EColor16MA bitmap with color information from aBitmap and alpha information |
|
265 * from aMaskBitmap. NOTE: Must have color mode EColor16MA! |
|
266 */ |
|
267 IMPORT_C static void CombineMaskFbsBitmapL(const CFbsBitmap & aSrcBitmap, |
|
268 const CFbsBitmap & aSrcMaskBitmap, |
|
269 CFbsBitmap & aCombinedBitmap); |
|
270 |
|
271 /** |
|
272 * Crops an area of FBS bitmap to new image. The size of the |
|
273 * copped bitmap defines the size of the area to crop. |
|
274 */ |
|
275 IMPORT_C static void CropFbsBitmapL(const CFbsBitmap & aSrcBitmap, |
|
276 CFbsBitmap & aCroppedBitmap, |
|
277 TPoint aCropPosition); |
|
278 |
|
279 /** |
|
280 * Resamples given unsigned byte image data to new size. Uses box |
|
281 * filtering. Can be used to downscale too large textures, for example. |
|
282 * |
|
283 * @param aComponents Number of image components (color channels) in the |
|
284 * source image. Use 3 with RGB image and 4 with RGBA. The destination will |
|
285 * have the same amount of color channels after this operation. |
|
286 * @param aSrcSize Size (width and height) of the original image (aSrcBuffer), |
|
287 * in number of pixels (width) or rows (height). |
|
288 * @param aSrcBuffer Pointer to the source image data. |
|
289 * @param aDestSize Size (width and height) of the new scaled image, |
|
290 * (aDestBuffer) in number of pixels (width) or rows (height). |
|
291 * @param aDestBuffer Output parameter: Pointer where new scaled image |
|
292 * data will be stored. You must remember to allocate the space for the |
|
293 * buffer before calling this method. |
|
294 */ |
|
295 IMPORT_C static void ScaleImage(TInt aComponents, |
|
296 const TSize& aSrcSize, |
|
297 const TUint8* aSrcBuffer, |
|
298 const TSize& aDestSize, |
|
299 TUint8* aDestBuffer); |
|
300 |
|
301 /** |
|
302 * Crops given unsigned byte image data. Can be used to split |
|
303 * large images to smaller sections. |
|
304 * |
|
305 * @param aComponents Number of image components (color channels) in the |
|
306 * source image. Use 3 with RGB image and 4 with RGBA. The destination will |
|
307 * have the same amount of color channels after this operation. |
|
308 * @param aSrcBufferSize Size (width and height) of the original image (aSrcBuffer), |
|
309 * in number of pixels (width) or rows (height). |
|
310 * @param aSrcBuffer Pointer to the source image data. |
|
311 * @param aCropOffset Cropping offset in the source image. Location of the |
|
312 * top-left corner of the cropped area, in pixels. |
|
313 * @param aCroppedSize Size of the cropped area. Is also the size of the |
|
314 * image in aDestBuffer. Width and height in pixels. |
|
315 * @param aDestBuffer Output parameter: Pointer where the cropped image |
|
316 * data will be stored. You must remember to allocate the space for the |
|
317 * buffer before calling this method. |
|
318 */ |
|
319 IMPORT_C static void CropImage(TInt aComponents, |
|
320 const TSize& aSrcBufferSize, |
|
321 const TUint8* aSrcBuffer, |
|
322 const TPoint& aCropOffset, |
|
323 const TSize& aCroppedSize, |
|
324 TUint8* aDestBuffer); |
|
325 |
|
326 |
|
327 /** |
|
328 * Checks if aTag is included in aTagsColonSeparated. Tags are case-sensitive. |
|
329 * |
|
330 * @param aTagsColonSeparated One or more tags separated by colons (:). |
|
331 * For example: "hello:world:tag3". |
|
332 * @param aTag Tag to look for. For example: "world". |
|
333 * |
|
334 * @return <code>ETrue</code>, if the tag was found in the colon-separated |
|
335 * tags descriptor. <code>EFalse</code> otherwise. |
|
336 * |
|
337 * @see CHuiVisual::FindTag() |
|
338 */ |
|
339 IMPORT_C static TBool TagMatches(const TDesC8& aTagsColonSeparated, const TDesC8& aTag); |
|
340 |
|
341 /** |
|
342 * Converts a bitmap to specified display mode. |
|
343 * This method converts a bitmap in any display mode to specified display mode. |
|
344 * Method creates a new bitmap, leaves it in cleanup stack and returns it. |
|
345 * |
|
346 * @param aBitmap The bitmap to be converted. |
|
347 * @param aDisplaymode The target display mode to convert the bitmap into. |
|
348 * @return Newly created conversion of the source bitmap. |
|
349 */ |
|
350 IMPORT_C static CFbsBitmap* ConvertBitmapToDisplayModeLC( const CFbsBitmap& aBitmap, const TDisplayMode& aDisplaymode ); |
|
351 |
|
352 /** @endAPI */ |
|
353 |
|
354 /** |
|
355 * Calculates the scale factor for an image content which is |
|
356 * place on a specific container are. |
|
357 * |
|
358 * @param aContainerSize Container size where the image is been placed on. |
|
359 * @param aContentSize Size of the image original. |
|
360 * @param aScaleMode Scale mode. |
|
361 * @param aInitialScale Initial scale value. |
|
362 * @return Result scale factor. Returns aInitialScale if aScaleMode = EScaleFit. |
|
363 * |
|
364 * @see CHuiImageVisual::TScaleMode |
|
365 */ |
|
366 static TReal32 CalculateScaleFactorFromScaleMode( |
|
367 const THuiRealSize& aContainerSize, |
|
368 const THuiRealSize& aContentSize, |
|
369 CHuiImageVisual::TScaleMode aScaleMode, |
|
370 TReal32 aInitialScale = 1.f ); |
|
371 |
|
372 /** |
|
373 * Compares floating points. |
|
374 * |
|
375 * @param aCompare1 Another compare value |
|
376 * @param aCompare2 Another compare value |
|
377 * @param aEpsilon Delta value in which the compared values are treated |
|
378 * as equal float values. |
|
379 * @return ETrue if the floating points are concidered to be the same. |
|
380 */ |
|
381 IMPORT_C static TBool RealCompare( |
|
382 TReal32 aCompare1, |
|
383 TReal32 aCompare2, |
|
384 TReal32 aEpsilon = 0.0001f ); |
|
385 |
|
386 /** |
|
387 * Asserts if the given condition is false. |
|
388 */ |
|
389 IMPORT_C static void Assert(TBool aCondition); |
|
390 |
|
391 |
|
392 /** |
|
393 * Creates a copy of a bitmap, ownership is transferred to caller |
|
394 */ |
|
395 IMPORT_C static CFbsBitmap* CopyBitmapL(const CFbsBitmap& aSrc); |
|
396 |
|
397 /** |
|
398 * Gets an integer value from central repository |
|
399 * |
|
400 * @param aKey key whose value is queried |
|
401 * @param aValue the value of the key |
|
402 * @return error, if OK, KErrNone |
|
403 * if there is any error, aValue is not changed |
|
404 */ |
|
405 IMPORT_C static TInt GetValueFromCentralRepository( const TUint32 aKey, TInt& aValue ); |
|
406 |
|
407 }; |
|
408 |
|
409 /** Sign function template. */ |
|
410 template <class T> |
|
411 inline TInt Sgn(T aVal) |
|
412 {return(aVal>0 ? 1 : aVal<0 ? -1 : 0);} |
|
413 |
|
414 // Define our own HUI_ASSERT macro for trapping asserts. |
|
415 #ifdef _DEBUG |
|
416 // Define a wrapper for our assert method. |
|
417 #define HUI_ASSERT(cond) HuiUtil::Assert(TBool(cond)) |
|
418 #define HUI_ASSERT2(cond, panic) { if(!(cond)) HUI_PANIC(panic) } |
|
419 #else // not _DEBUG |
|
420 // In release builds asserts are ignored. |
|
421 #define HUI_ASSERT(cond) //HuiUtil::Assert(cond) |
|
422 #define HUI_ASSERT2(cond, panic) |
|
423 #endif //not _DEBUG |
|
424 |
|
425 /** |
|
426 * Debug macros for printing debug messages. The debug messages will be |
|
427 * redirected to console using RDebug::Print(), or to a log file if |
|
428 * HUI_DEBUG_WITH_PRINTF is defined and CHuiStatic::EnableLogging() has been |
|
429 * called. |
|
430 * |
|
431 * Note that the debug macros will not be compiled in to release builds, |
|
432 * unless HUI_DEBUG_WITH_PRINTF is defined. |
|
433 */ |
|
434 |
|
435 // Debug output is disabled in windows by default. |
|
436 // It slows down the emulator, and often it is not needed |
|
437 // If you want debug output in windows, comment the following definition out. |
|
438 // It does not affect logging in hardware. In hardware debug version always logs. |
|
439 #define HUI_NO_DEBUG_OUTPUT_IN_WINS |
|
440 |
|
441 #ifndef __WINS__ |
|
442 #ifdef _DEBUG |
|
443 #ifdef HUI_DEBUG_WITH_PRINTF |
|
444 // Debug build that prints log output via CHuiStatic::Printf() |
|
445 # define HUI_DEBUG(s) CHuiStatic::Printf(s) |
|
446 # define HUI_DEBUG1(s, t) CHuiStatic::Printf(s, t) |
|
447 # define HUI_DEBUG2(s, t, u) CHuiStatic::Printf(s, t, u) |
|
448 # define HUI_DEBUG3(s, t, u, v) CHuiStatic::Printf(s, t, u, v) |
|
449 # define HUI_DEBUG4(s, t, u, v, w) CHuiStatic::Printf(s, t, u, v, w) |
|
450 # define HUI_DEBUG5(s, t, u, v, w, x) CHuiStatic::Printf(s, t, u, v, w, x) |
|
451 # define HUI_DEBUG6(s, t, u, v, w, x, y) CHuiStatic::Printf(s, t, u, v, w, x, y) |
|
452 # define HUI_DEBUG7(s, t, u, v, w, x, y, z) CHuiStatic::Printf(s, t, u, v, w, x, y, z) |
|
453 #else // HUI_DEBUG_WITH_PRINTF |
|
454 // Debug build that prints log output via RDebug (preferably the WINSCW Emulator) |
|
455 # define HUI_DEBUG(s) RDebug::Print(s) |
|
456 # define HUI_DEBUG1(s, t) RDebug::Print(s, t) |
|
457 # define HUI_DEBUG2(s, t, u) RDebug::Print(s, t, u) |
|
458 # define HUI_DEBUG3(s, t, u, v) RDebug::Print(s, t, u, v) |
|
459 # define HUI_DEBUG4(s, t, u, v, w) RDebug::Print(s, t, u, v, w) |
|
460 # define HUI_DEBUG5(s, t, u, v, w, x) RDebug::Print(s, t, u, v, w, x) |
|
461 # define HUI_DEBUG6(s, t, u, v, w, x, y) RDebug::Print(s, t, u, v, w, x, y) |
|
462 # define HUI_DEBUG7(s, t, u, v, w, x, y, z) RDebug::Print(s, t, u, v, w, x, y, z) |
|
463 #endif // HUI_DEBUG_WITH_PRINTF |
|
464 #else // _DEBUG |
|
465 // No debug output for release builds |
|
466 # define HUI_DEBUG(s) |
|
467 # define HUI_DEBUG1(s, t) |
|
468 # define HUI_DEBUG2(s, t, u) |
|
469 # define HUI_DEBUG3(s, t, u, v) |
|
470 # define HUI_DEBUG4(s, t, u, v, w) |
|
471 # define HUI_DEBUG5(s, t, u, v, w, x) |
|
472 # define HUI_DEBUG6(s, t, u, v, w, x, y) |
|
473 # define HUI_DEBUG7(s, t, u, v, w, x, y, z) |
|
474 #endif // _DEBUG |
|
475 #else // __WINS__ |
|
476 #ifdef HUI_NO_DEBUG_OUTPUT_IN_WINS |
|
477 // No output in windows by default |
|
478 # define HUI_DEBUG(s) |
|
479 # define HUI_DEBUG1(s, t) |
|
480 # define HUI_DEBUG2(s, t, u) |
|
481 # define HUI_DEBUG3(s, t, u, v) |
|
482 # define HUI_DEBUG4(s, t, u, v, w) |
|
483 # define HUI_DEBUG5(s, t, u, v, w, x) |
|
484 # define HUI_DEBUG6(s, t, u, v, w, x, y) |
|
485 # define HUI_DEBUG7(s, t, u, v, w, x, y, z) |
|
486 #else // HUI_NO_DEBUG_OUTPUT_IN_WINS |
|
487 #ifdef HUI_DEBUG_WITH_PRINTF |
|
488 // Debug build that prints log output via CHuiStatic::Printf() |
|
489 # define HUI_DEBUG(s) CHuiStatic::Printf(s) |
|
490 # define HUI_DEBUG1(s, t) CHuiStatic::Printf(s, t) |
|
491 # define HUI_DEBUG2(s, t, u) CHuiStatic::Printf(s, t, u) |
|
492 # define HUI_DEBUG3(s, t, u, v) CHuiStatic::Printf(s, t, u, v) |
|
493 # define HUI_DEBUG4(s, t, u, v, w) CHuiStatic::Printf(s, t, u, v, w) |
|
494 # define HUI_DEBUG5(s, t, u, v, w, x) CHuiStatic::Printf(s, t, u, v, w, x) |
|
495 # define HUI_DEBUG6(s, t, u, v, w, x, y) CHuiStatic::Printf(s, t, u, v, w, x, y) |
|
496 # define HUI_DEBUG7(s, t, u, v, w, x, y, z) CHuiStatic::Printf(s, t, u, v, w, x, y, z) |
|
497 #else // HUI_DEBUG_WITH_PRINTF |
|
498 // Debug build that prints log output via RDebug (preferably the WINSCW Emulator) |
|
499 # define HUI_DEBUG(s) RDebug::Print(s) |
|
500 # define HUI_DEBUG1(s, t) RDebug::Print(s, t) |
|
501 # define HUI_DEBUG2(s, t, u) RDebug::Print(s, t, u) |
|
502 # define HUI_DEBUG3(s, t, u, v) RDebug::Print(s, t, u, v) |
|
503 # define HUI_DEBUG4(s, t, u, v, w) RDebug::Print(s, t, u, v, w) |
|
504 # define HUI_DEBUG5(s, t, u, v, w, x) RDebug::Print(s, t, u, v, w, x) |
|
505 # define HUI_DEBUG6(s, t, u, v, w, x, y) RDebug::Print(s, t, u, v, w, x, y) |
|
506 # define HUI_DEBUG7(s, t, u, v, w, x, y, z) RDebug::Print(s, t, u, v, w, x, y, z) |
|
507 #endif // HUI_DEBUG_WITH_PRINTF |
|
508 #endif // HUI_NO_DEBUG_OUTPUT_IN_WINS |
|
509 #endif // __WINS__ |
|
510 |
|
511 /** Framedraw debug macros for printing debug messages during frame drawing operation. */ |
|
512 #ifdef HUI_DEBUG_FRAMEDRAW_WITH_PRINTF |
|
513 # define HUI_DEBUGF(s) CHuiStatic::Printf(s) |
|
514 # define HUI_DEBUGF1(s, t) CHuiStatic::Printf(s, t) |
|
515 # define HUI_DEBUGF2(s, t, u) CHuiStatic::Printf(s, t, u) |
|
516 # define HUI_DEBUGF3(s, t, u, v) CHuiStatic::Printf(s, t, u, v) |
|
517 # define HUI_DEBUGF4(s, t, u, v, w) CHuiStatic::Printf(s, t, u, v, w) |
|
518 # define HUI_DEBUGF5(s, t, u, v, w, x) CHuiStatic::Printf(s, t, u, v, w, x) |
|
519 # define HUI_DEBUGF6(s, t, u, v, w, x, y) CHuiStatic::Printf(s, t, u, v, w, x, y) |
|
520 # define HUI_DEBUGF7(s, t, u, v, w, x, y, z) CHuiStatic::Printf(s, t, u, v, w, x, y, z) |
|
521 #else |
|
522 #ifdef HUI_DEBUG_FRAMEDRAW |
|
523 # define HUI_DEBUGF(s) RDebug::Print(s) |
|
524 # define HUI_DEBUGF1(s, t) RDebug::Print(s, t) |
|
525 # define HUI_DEBUGF2(s, t, u) RDebug::Print(s, t, u) |
|
526 # define HUI_DEBUGF3(s, t, u, v) RDebug::Print(s, t, u, v) |
|
527 # define HUI_DEBUGF4(s, t, u, v, w) RDebug::Print(s, t, u, v, w) |
|
528 # define HUI_DEBUGF5(s, t, u, v, w, x) RDebug::Print(s, t, u, v, w, x) |
|
529 # define HUI_DEBUGF6(s, t, u, v, w, x, y) RDebug::Print(s, t, u, v, w, x, y) |
|
530 # define HUI_DEBUGF7(s, t, u, v, w, x, y, z) RDebug::Print(s, t, u, v, w, x, y, z) |
|
531 #else |
|
532 # define HUI_DEBUGF(s) |
|
533 # define HUI_DEBUGF1(s, t) |
|
534 # define HUI_DEBUGF2(s, t, u) |
|
535 # define HUI_DEBUGF3(s, t, u, v) |
|
536 # define HUI_DEBUGF4(s, t, u, v, w) |
|
537 # define HUI_DEBUGF5(s, t, u, v, w, x) |
|
538 # define HUI_DEBUGF6(s, t, u, v, w, x, y) |
|
539 # define HUI_DEBUGF7(s, t, u, v, w, x, y, z) |
|
540 #endif |
|
541 #endif |
|
542 |
|
543 |
|
544 |
|
545 /** |
|
546 * Non-exporting implementation for MHuiSessionObject |
|
547 */ |
|
548 #define HUI_SESSION_OBJECT_IMPL(classname, type) \ |
|
549 MHuiSessionObject::TType classname::Type() const \ |
|
550 { \ |
|
551 return type; \ |
|
552 } \ |
|
553 \ |
|
554 TInt classname::SessionId() const \ |
|
555 { \ |
|
556 return iSessionId; \ |
|
557 } \ |
|
558 \ |
|
559 void classname::SetSessionId(TInt aSessionId) \ |
|
560 { \ |
|
561 iSessionId = aSessionId; \ |
|
562 } |
|
563 |
|
564 |
|
565 /** |
|
566 * Implementation for MHuiSessionObject with exports |
|
567 */ |
|
568 #define HUI_SESSION_OBJECT_IMPL_EXPORT(classname, type) \ |
|
569 EXPORT_C MHuiSessionObject::TType classname::Type() const \ |
|
570 { \ |
|
571 return type; \ |
|
572 } \ |
|
573 \ |
|
574 EXPORT_C TInt classname::SessionId() const \ |
|
575 { \ |
|
576 return iSessionId; \ |
|
577 } \ |
|
578 \ |
|
579 EXPORT_C void classname::SetSessionId(TInt aSessionId) \ |
|
580 { \ |
|
581 iSessionId = aSessionId; \ |
|
582 } |
|
583 |
|
584 |
|
585 /* Probing macros. Probing is enabled only if macro HUI_PROBE_ENABLED is defined. */ |
|
586 #ifdef HUI_PROBE_ENABLED |
|
587 |
|
588 /** |
|
589 * Associate this object with current session. |
|
590 */ |
|
591 #define HUI_PROBE_ASSOCIATE_WITH_CURRENT_SESSION \ |
|
592 CHuiStatic::Probe().AssociateWithCurrentSession(*this); |
|
593 |
|
594 /** |
|
595 * Report to Hui Probe object; report construction of this object. |
|
596 */ |
|
597 #define HUI_PROBE_REPORT_CONSTRUCTED \ |
|
598 CHuiStatic::Probe().ReportObjectLifeCycleEvent(*this, MHuiProbe::ELifecycleEventConstructed); |
|
599 |
|
600 /** |
|
601 * Report to Hui Probe object; report destruction of this object. |
|
602 */ |
|
603 #define HUI_PROBE_REPORT_DESTRUCTED \ |
|
604 CHuiStatic::Probe().ReportObjectLifeCycleEvent(*this, MHuiProbe::ELifecycleEventDestructed); |
|
605 |
|
606 /** |
|
607 * Report to Hui Probe object; report release of this object. |
|
608 */ |
|
609 #define HUI_PROBE_REPORT_RELEASED \ |
|
610 CHuiStatic::Probe().ReportObjectLifeCycleEvent(*this, MHuiProbe::ELifecycleEventReleased); |
|
611 |
|
612 /** |
|
613 * Report to Hui Probe object; report restoration of this object. |
|
614 */ |
|
615 #define HUI_PROBE_REPORT_RESTORED \ |
|
616 CHuiStatic::Probe().ReportObjectLifeCycleEvent(*this, MHuiProbe::ELifecycleEventRestored); |
|
617 |
|
618 /** |
|
619 * Report to Hui Probe object; report entering on program flow point |
|
620 */ |
|
621 #define HUI_PROBE_PROGRAMFLOW_ENTER(point) \ |
|
622 CHuiStatic::Probe().ReportProgramFlowEvent( \ |
|
623 point, \ |
|
624 MHuiProbe::EProgramFlowEventEnter); |
|
625 |
|
626 /** |
|
627 * Report to Hui Probe object; report exiting from program flow point |
|
628 */ |
|
629 #define HUI_PROBE_PROGRAMFLOW_EXIT(point) \ |
|
630 CHuiStatic::Probe().ReportProgramFlowEvent( \ |
|
631 point, \ |
|
632 MHuiProbe::EProgramFlowEventExit); |
|
633 |
|
634 /** |
|
635 * Report to Hui Probe object; report entering on program flow point, |
|
636 * where the program flow point is in session object. |
|
637 */ |
|
638 #define HUI_PROBE_PROGRAMFLOW_WITHSESSION_ENTER(point) \ |
|
639 CHuiStatic::Probe().ReportProgramFlowEvent( \ |
|
640 *this, \ |
|
641 point, \ |
|
642 MHuiProbe::EProgramFlowEventEnter); |
|
643 |
|
644 /** |
|
645 * Report to Hui Probe object; report exiting from program flow point, |
|
646 * where the program flow point is in session object. |
|
647 */ |
|
648 #define HUI_PROBE_PROGRAMFLOW_WITHSESSION_EXIT(point) \ |
|
649 CHuiStatic::Probe().ReportProgramFlowEvent( \ |
|
650 *this, \ |
|
651 point, \ |
|
652 MHuiProbe::EProgramFlowEventExit); |
|
653 |
|
654 #else // HUI_PROBE_ENABLED |
|
655 |
|
656 #define HUI_PROBE_ASSOCIATE_WITH_CURRENT_SESSION |
|
657 #define HUI_PROBE_REPORT_CONSTRUCTED |
|
658 #define HUI_PROBE_REPORT_DESTRUCTED |
|
659 #define HUI_PROBE_REPORT_RELEASED |
|
660 #define HUI_PROBE_REPORT_RESTORED |
|
661 #define HUI_PROBE_PROGRAMFLOW_ENTER(point) |
|
662 #define HUI_PROBE_PROGRAMFLOW_EXIT(point) |
|
663 #define HUI_PROBE_PROGRAMFLOW_WITHSESSION_ENTER(point) |
|
664 #define HUI_PROBE_PROGRAMFLOW_WITHSESSION_EXIT(point) |
|
665 |
|
666 #endif // HUI_PROBE_ENABLED |
|
667 |
|
668 #endif // __HUIUTIL_H__ |