|
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: Definition file for CHuiGc (graphics context) class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUIGC_H__ |
|
21 #define __HUIGC_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <gdi.h> |
|
26 |
|
27 #include <uiacceltk/HuiRealPoint.h> |
|
28 #include <uiacceltk/HuiRealSize.h> |
|
29 #include <uiacceltk/HuiRealRect.h> |
|
30 |
|
31 |
|
32 /* Forward declarations. */ |
|
33 class CHuiTexture; |
|
34 class THuiFont; |
|
35 class THuiImage; |
|
36 class CHuiMesh; |
|
37 class CHuiTextMesh; |
|
38 class CHuiCurvePath; |
|
39 class CHuiTransformation; |
|
40 class MHuiMappingFunction; |
|
41 |
|
42 const TInt KHuiGcClipRegionGranularity = 10; |
|
43 |
|
44 /** Point on a weighted path. */ |
|
45 struct THuiPathPoint |
|
46 { |
|
47 /** Position of the point. */ |
|
48 TPoint iPoint; |
|
49 |
|
50 /** Weight of the point. */ |
|
51 TReal32 iWeight; |
|
52 |
|
53 inline THuiPathPoint(const TPoint& aPoint, const TReal32& aWeight) |
|
54 : iPoint(aPoint), iWeight(aWeight) {} |
|
55 }; |
|
56 |
|
57 |
|
58 /** Weighted path. */ |
|
59 typedef RArray<THuiPathPoint> THuiWeightedPath; |
|
60 |
|
61 |
|
62 /** Horizontal alignment. */ |
|
63 enum THuiAlignHorizontal |
|
64 { |
|
65 EHuiAlignHLeft, |
|
66 EHuiAlignHCenter, |
|
67 EHuiAlignHRight, |
|
68 |
|
69 /** Alignment that follows the directionality of the UI language. This is converted to left or |
|
70 right alignment internally. e.g. into right-aligned for Arabic */ |
|
71 EHuiAlignHLocale, |
|
72 |
|
73 /** Alignment that is opposite to the directionality of the UI language. This is |
|
74 converted to left or right alignment internally. e.g. into left-aligned for Arabic */ |
|
75 EHuiAlignHLocaleMirrored, |
|
76 |
|
77 /** Alignment is text content dependent according to Unicode paragraph alignment rules. |
|
78 This is converted to left or right alignment according to text content. |
|
79 Where used in an editable context, the cursor alignment when empty comes from current input language. |
|
80 This should not be used in a non-textual context, but if used, behaves like EHuiAlignHLocale. */ |
|
81 EHuiAlignHBidirectionalText, |
|
82 |
|
83 /** Alignment is text content dependent according to Unicode paragraph alignment rules, but then reversed. |
|
84 This is converted to left or right alignment according to text content. |
|
85 Where used in an editable context, the cursor alignment when empty is opposite to current input language. |
|
86 This should not be used in a non-textual context, but if used, behaves like EHuiAlignHLocaleMirrored. */ |
|
87 EHuiAlignHBidirectionalTextMirrored |
|
88 }; |
|
89 |
|
90 |
|
91 /** Vertical alignment. */ |
|
92 enum THuiAlignVertical |
|
93 { |
|
94 EHuiAlignVTop, |
|
95 EHuiAlignVCenter, |
|
96 EHuiAlignVBottom |
|
97 }; |
|
98 |
|
99 |
|
100 /** Texture matrices. */ |
|
101 enum THuiGcMatrix |
|
102 { |
|
103 /** Modelview matrix. */ |
|
104 EHuiGcMatrixModel, |
|
105 |
|
106 /** Projection matrix. */ |
|
107 EHuiGcMatrixProjection, |
|
108 |
|
109 /** Texture matrix. */ |
|
110 EHuiGcMatrixTexture |
|
111 }; |
|
112 |
|
113 |
|
114 /** Rendering quality. */ |
|
115 enum THuiQuality |
|
116 { |
|
117 /** Accurate quality ensures the best visual quality. */ |
|
118 EHuiQualityAccurate, |
|
119 |
|
120 /** Fastest rendering speed in exchange for lower quality. */ |
|
121 EHuiQualityFast |
|
122 }; |
|
123 |
|
124 /** Polygon draw mode */ |
|
125 enum THuiFillMode |
|
126 { |
|
127 EHuiNoFill, |
|
128 EHuiFillNonZero, |
|
129 EHuiFillEvenOdd |
|
130 }; |
|
131 |
|
132 /** |
|
133 * CHuiGc is a graphics context that is used for storing the state of the |
|
134 * drawing tools. The graphics context provides a number of relatively |
|
135 * low-level drawing routines. |
|
136 * |
|
137 * @todo Check which exports are truly useful to applications. |
|
138 * |
|
139 */ |
|
140 class CHuiGc : public CBase |
|
141 { |
|
142 public: |
|
143 |
|
144 /** Display orientation. */ |
|
145 enum TOrientation |
|
146 { |
|
147 /** Normal orientation. */ |
|
148 EOrientationNormal, |
|
149 |
|
150 /** 90 degrees counterclockwise. */ |
|
151 EOrientationCCW90, |
|
152 |
|
153 /** 90 degrees clockwise. */ |
|
154 EOrientationCW90, |
|
155 |
|
156 /** 180 degrees */ |
|
157 EOrientation180 |
|
158 }; |
|
159 |
|
160 /** Rendering features. */ |
|
161 enum TFeature |
|
162 { |
|
163 EFeatureTexturing, |
|
164 EFeatureBlending, |
|
165 EFeatureClipping, |
|
166 EFeatureDepthTest, |
|
167 EFeatureDepthWrite, |
|
168 EFeatureAntialias, |
|
169 EFeatureFog, |
|
170 }; |
|
171 |
|
172 /** Blending modes. */ |
|
173 enum TBlendMode |
|
174 { |
|
175 EBlendNormal, |
|
176 EBlendAdd, |
|
177 EBlendReplace |
|
178 }; |
|
179 |
|
180 /** Texture modes. */ |
|
181 enum TTextureMode |
|
182 { |
|
183 ETextureModeNormal, |
|
184 |
|
185 /** Interpolation between two texture units. Parameter controls how |
|
186 much interpolation is done. */ |
|
187 ETextureModeInterpolate |
|
188 }; |
|
189 |
|
190 /** Projections. */ |
|
191 enum TProjection |
|
192 { |
|
193 EProjectionOrthographic, |
|
194 EProjectionPerspective |
|
195 }; |
|
196 |
|
197 /** |
|
198 * Stretch modes. |
|
199 * @see DrawStretchImage() |
|
200 */ |
|
201 enum TStretchMode |
|
202 { |
|
203 EStretchNone = 0, ///< Does not stretch |
|
204 EStretchHorizontal, ///< Fits to horizontal width (left-right) |
|
205 EStretchVertical, ///< Fits to vertical height |
|
206 EStretchFull ///< Stretches the image to the full area of the visual, disregarding the original aspect ratio. |
|
207 |
|
208 }; |
|
209 |
|
210 /** |
|
211 * Modes for drawing borders with images. |
|
212 * @see DrawBorders() |
|
213 */ |
|
214 enum TBorderMode |
|
215 { |
|
216 /** |
|
217 * The whole image is stretched to the |
|
218 * borders so that the pixels at the center of the image are placed at the |
|
219 * edges of the visual and the pixels at the edge of the image are placed |
|
220 * at the outer edge. |
|
221 * |
|
222 * For example, a round-shaped ball having red centrum |
|
223 * and white outer rim cretes a red square inner border having white |
|
224 * rounded outer border. |
|
225 */ |
|
226 EBorderImage = 0, |
|
227 |
|
228 /** |
|
229 * Only the edge pixels of the image are used to draw the borders. The edge is |
|
230 * defined with the (left,right,top,bottom-) border widths. The corners of the |
|
231 * image are not stretched. The center image inside the borders won't be |
|
232 * included in the border drawing. |
|
233 * |
|
234 * This mode is used in CHuiImageBrush to draw background images to visuals |
|
235 * (eg. Soft key backgrounds) and texture-mapped borders to them (for example |
|
236 * to achieve rounded corners). |
|
237 */ |
|
238 EBorderFixedCorners |
|
239 |
|
240 }; |
|
241 |
|
242 /** Gradient types. */ |
|
243 enum TGradientType |
|
244 { |
|
245 EGradientLinearUp, |
|
246 EGradientLinearRight, |
|
247 EGradientLinearDown, |
|
248 EGradientLinearLeft |
|
249 }; |
|
250 |
|
251 |
|
252 /** |
|
253 * Destructor. |
|
254 */ |
|
255 IMPORT_C virtual ~CHuiGc(); |
|
256 |
|
257 |
|
258 /* Methods. */ |
|
259 |
|
260 /** |
|
261 * Sets the quality preference of the graphics context. |
|
262 * |
|
263 * @param aQuality Quality setting. |
|
264 */ |
|
265 IMPORT_C virtual void SetQuality(THuiQuality aQuality); |
|
266 |
|
267 /** |
|
268 * Determines the quality preference of the graphics context. |
|
269 * |
|
270 * @return Quality preference. |
|
271 */ |
|
272 IMPORT_C THuiQuality Quality() const; |
|
273 |
|
274 /** |
|
275 * Pushes the current global transformation matrix on the stack. |
|
276 */ |
|
277 IMPORT_C virtual void Push(THuiGcMatrix aStack) = 0; |
|
278 |
|
279 /** |
|
280 * Pops a matrix from the stack. |
|
281 */ |
|
282 IMPORT_C virtual void Pop(THuiGcMatrix aStack) = 0; |
|
283 |
|
284 /** |
|
285 * Loads an identity matrix as the current matrix. |
|
286 */ |
|
287 IMPORT_C virtual void LoadIdentity(THuiGcMatrix aStack) = 0; |
|
288 |
|
289 /** |
|
290 * Multiplies the current matrix with another matrix. |
|
291 */ |
|
292 IMPORT_C virtual void Multiply(THuiGcMatrix aStack, TReal32 aMatrix[16]) = 0; |
|
293 |
|
294 /** |
|
295 * Apply a translation to given matrix stack. |
|
296 */ |
|
297 IMPORT_C virtual void Translate(THuiGcMatrix aStack, |
|
298 TReal32 aX, TReal32 aY, TReal32 aZ) __SOFTFP = 0; |
|
299 |
|
300 /** |
|
301 * Apply a scale to given matrix stack. |
|
302 */ |
|
303 IMPORT_C virtual void Scale(THuiGcMatrix aStack, |
|
304 TReal32 aX, TReal32 aY, TReal32 aZ) __SOFTFP = 0; |
|
305 |
|
306 /** |
|
307 * Apply a rotation to given matrix stack. |
|
308 */ |
|
309 IMPORT_C virtual void Rotate(THuiGcMatrix aStack, TReal32 aAngle, |
|
310 TReal32 aX, TReal32 aY, TReal32 aZ) __SOFTFP = 0; |
|
311 |
|
312 /** |
|
313 * Apply a shear to given matrix stack. |
|
314 */ |
|
315 virtual void Shear(THuiGcMatrix /*aStack*/, |
|
316 TReal32 /*aX*/, TReal32 /*aY*/, TReal32 /*aZ*/) __SOFTFP {} // cheers ;) |
|
317 |
|
318 /** |
|
319 * Sets the orientation of the display. This affects clipping and |
|
320 * projection. |
|
321 * |
|
322 * @param aOrientation Orientation of the display. |
|
323 */ |
|
324 IMPORT_C void SetOrientation(TOrientation aOrientation); |
|
325 |
|
326 /** |
|
327 * Determines the orientation of the graphics context. |
|
328 * |
|
329 * @return Orientation. |
|
330 */ |
|
331 IMPORT_C TOrientation Orientation() const; |
|
332 |
|
333 /** |
|
334 * Initialize the state of the context. |
|
335 */ |
|
336 IMPORT_C virtual void InitState() = 0; |
|
337 |
|
338 /** |
|
339 * Selects the default data arrays. |
|
340 */ |
|
341 IMPORT_C virtual void RestoreState() const = 0; |
|
342 |
|
343 IMPORT_C void SetProjection(TProjection aProjection = EProjectionOrthographic); |
|
344 |
|
345 IMPORT_C TProjection Projection() const; |
|
346 |
|
347 /** |
|
348 * Sets projection within a custom viewport. |
|
349 */ |
|
350 IMPORT_C void SetProjection(TProjection aProjection, const TRect& aCustomViewport); |
|
351 |
|
352 /** |
|
353 * Defines an offset for the 3D frustum and updates the projection. |
|
354 */ |
|
355 IMPORT_C void SetFrustumOffset(const THuiRealPoint& aFrustumOffset); |
|
356 |
|
357 /** |
|
358 * Determines the current frustum offset. |
|
359 */ |
|
360 IMPORT_C THuiRealPoint FrustumOffset() const; |
|
361 |
|
362 /** |
|
363 * Updates the projection matrix without changing any settings. |
|
364 */ |
|
365 IMPORT_C virtual void UpdateProjection() = 0; |
|
366 |
|
367 /** |
|
368 * Sets the display area of the normal orientation. |
|
369 */ |
|
370 IMPORT_C void SetDisplayArea(const TRect& aDisplayArea); |
|
371 |
|
372 /** |
|
373 * Returns the display area. Affected by the display orientation. |
|
374 */ |
|
375 IMPORT_C TRect DisplayArea() const; |
|
376 |
|
377 /** |
|
378 * Returns the number of available texture units. |
|
379 * |
|
380 * @return Number of units (at least 1). |
|
381 */ |
|
382 IMPORT_C virtual TInt TextureUnits() const = 0; |
|
383 |
|
384 /** |
|
385 * Sets the number of active texture units. |
|
386 * |
|
387 * @param aTextureUnitCount Number of units to activate (e.g., 2 => 0,1) |
|
388 */ |
|
389 IMPORT_C virtual void SetTextureUnits(TInt aTextureUnitCount) = 0; |
|
390 |
|
391 /** |
|
392 * Enable a feature. |
|
393 */ |
|
394 IMPORT_C virtual void Enable(TFeature aFeature, TBool aDoEnable = ETrue) = 0; |
|
395 |
|
396 /** |
|
397 * Disable a feature. |
|
398 */ |
|
399 IMPORT_C virtual void Disable(TFeature aFeature); |
|
400 |
|
401 /** |
|
402 * Changes the blending mode. |
|
403 */ |
|
404 IMPORT_C virtual void SetBlendMode(TBlendMode aBlendMode) = 0; |
|
405 |
|
406 /** |
|
407 * Changes the texture mode. |
|
408 * |
|
409 * @param aTextureMode Texturing mode. |
|
410 * @param aParam Parameter for the texturing. |
|
411 */ |
|
412 IMPORT_C virtual void SetTextureMode(TTextureMode aTextureMode, TReal32 aParam = 0) __SOFTFP = 0; |
|
413 |
|
414 /** |
|
415 * Sets the strength of dimming fog. In order to have effect, enable the |
|
416 * Fog feature. |
|
417 * |
|
418 * @param aColor Color of dimming. |
|
419 * @param aAmount Amout of dimming (0...1). |
|
420 */ |
|
421 IMPORT_C virtual void SetDimmingFog(const TRgb& aColor, TReal32 aAmount) __SOFTFP = 0; |
|
422 |
|
423 /** |
|
424 * Clear using the current pen color. |
|
425 */ |
|
426 IMPORT_C virtual void Clear() = 0; |
|
427 |
|
428 /** |
|
429 * Clear the depth buffer. |
|
430 */ |
|
431 IMPORT_C virtual void ClearDepth() = 0; |
|
432 |
|
433 /** |
|
434 * Clear both color and depth buffer |
|
435 */ |
|
436 IMPORT_C virtual void ClearColorAndDepth() = 0; |
|
437 |
|
438 /** |
|
439 * Do initialization of new frame. |
|
440 * Called by CHuiDisplay when starting to render new frame. |
|
441 * Graphics context can do renderer specific state initializations here. |
|
442 */ |
|
443 IMPORT_C virtual void InitNewFrame() = 0; |
|
444 |
|
445 /** |
|
446 * Push the current clipping rectangle onto the clip stack. |
|
447 */ |
|
448 IMPORT_C virtual void PushClip(); |
|
449 |
|
450 /** |
|
451 * Pop a clipping rectangle off of the clip stack and activate it. |
|
452 */ |
|
453 IMPORT_C virtual void PopClip(); |
|
454 |
|
455 /** |
|
456 * Apply a clipping rectangle. |
|
457 * |
|
458 * @param aClipRect Clipping rectangle. |
|
459 */ |
|
460 IMPORT_C virtual void Clip(const TRect& aClipRect); |
|
461 |
|
462 /** |
|
463 * Apply a clipping region. |
|
464 * |
|
465 * @param aClipRegion Clipping region. |
|
466 */ |
|
467 IMPORT_C virtual void Clip(const TRegion& aClipRegion); |
|
468 |
|
469 /** |
|
470 * Apply a clipping region. |
|
471 * |
|
472 * @param aClipRegion Region containing clipping rectangles. |
|
473 */ |
|
474 |
|
475 IMPORT_C virtual void SetClipRegion(const TRegion& aClipRegion); |
|
476 |
|
477 /** |
|
478 * Cancel an applied clipping rectangle or region. |
|
479 */ |
|
480 |
|
481 IMPORT_C virtual void CancelClipping(); |
|
482 |
|
483 /** |
|
484 * Replace the current clipping rectangle. |
|
485 * |
|
486 * @param aClipRect Clipping rectangle in display coordinates. |
|
487 */ |
|
488 IMPORT_C virtual void SetClip(const TRect& aClipRect); |
|
489 |
|
490 /** |
|
491 * Returns the currently active clipping rectangle. |
|
492 */ |
|
493 IMPORT_C TRect ClipRect() const; |
|
494 |
|
495 /** |
|
496 * Returns the currently active clipping region. |
|
497 */ |
|
498 const TRegion& ClipRegion() const; |
|
499 |
|
500 |
|
501 /** |
|
502 * Determines the number of pushed clipping rectangles on the clip stack. |
|
503 * |
|
504 * @return Size of the clip stack. |
|
505 */ |
|
506 IMPORT_C TInt ClipStackCount() const; |
|
507 |
|
508 /** |
|
509 * Sets the pen color and alpha. |
|
510 */ |
|
511 IMPORT_C void SetPenColorAlpha(const TRgb& aColor); |
|
512 |
|
513 /** |
|
514 * Sets the pen color. |
|
515 */ |
|
516 IMPORT_C void SetPenColor(const TRgb& aColor); |
|
517 |
|
518 /** |
|
519 * Sets the pen alpha level. |
|
520 * |
|
521 * @param aAlpha Alpha level (0..255). |
|
522 */ |
|
523 IMPORT_C void SetPenAlpha(TInt aAlpha); |
|
524 |
|
525 /** |
|
526 * Determines the pen color and alpha. |
|
527 * |
|
528 * @return Pen color and alpha. |
|
529 */ |
|
530 IMPORT_C TRgb PenColorAlpha() const; |
|
531 |
|
532 /** |
|
533 * Determines the pen color. |
|
534 * |
|
535 * @return Pen color. |
|
536 */ |
|
537 IMPORT_C TRgb PenColor() const; |
|
538 |
|
539 /** |
|
540 * Determines the pen alpha level. |
|
541 * |
|
542 * @return Alpha level (0..255). |
|
543 */ |
|
544 IMPORT_C TInt PenAlpha() const; |
|
545 |
|
546 /** |
|
547 * Sets the current font. |
|
548 * |
|
549 * @param aFont Font texture. |
|
550 */ |
|
551 IMPORT_C void SetFont(THuiFont& aFont); |
|
552 |
|
553 /** |
|
554 * Sets the object alignment mode for both horizontal and vertical |
|
555 * directions. Used in DrawImage() and DrawImages(). |
|
556 * |
|
557 * @todo Should SetAlign() work also in other GC drawing operations? |
|
558 * |
|
559 * @param aHorizontalAlign Horizontal alignment mode. The horizontal |
|
560 * alignment mode determines if the used |
|
561 * coordinates are relative to left edge, center |
|
562 * or right edge of the screen. |
|
563 * @param aVerticalAlign Vertical alignment mode. The vertical |
|
564 * alignment mode determines if the used |
|
565 * coordinates are relative to top-edge, vertical |
|
566 * center or bottom of the screen. |
|
567 */ |
|
568 IMPORT_C void SetAlign(THuiAlignHorizontal aHorizontalAlign, |
|
569 THuiAlignVertical aVerticalAlign); |
|
570 |
|
571 /** |
|
572 * Determines the horizontal align mode. |
|
573 */ |
|
574 IMPORT_C THuiAlignHorizontal AlignHorizontal() const; |
|
575 |
|
576 /** |
|
577 * Determines the vertical align mode. |
|
578 */ |
|
579 IMPORT_C THuiAlignVertical AlignVertical() const; |
|
580 |
|
581 /** |
|
582 * Draws a line of text. Creates a temporary text mesh, so this is not as |
|
583 * efficient as calling DrawText on an existing mesh. |
|
584 */ |
|
585 IMPORT_C virtual void DrawTextL(const TDesC& aText, |
|
586 const THuiRealRect& aBounds, |
|
587 TReal32 aShadow = 0) __SOFTFP; |
|
588 |
|
589 /** |
|
590 * Draws a single line of text using the current pen color, font, and |
|
591 * alignment mode. |
|
592 * |
|
593 * @param aTextMesh Text string. |
|
594 * @param aBounds Bounding box for the text. |
|
595 * @param aShadow Darkness of text shadow. |
|
596 */ |
|
597 IMPORT_C virtual void DrawText(const CHuiTextMesh& aTextMesh, |
|
598 const THuiRealRect& aBounds, |
|
599 TReal32 aShadow = 0) __SOFTFP; |
|
600 |
|
601 /** |
|
602 * Draws an image using the current pen color and alignment mode. |
|
603 * |
|
604 * @param aImage Image specification. |
|
605 * @param aPos Origin point. Relative to the selected alignment point, |
|
606 * @see SetAlign() |
|
607 * @param aSize Size of the image. |
|
608 */ |
|
609 IMPORT_C virtual void DrawImage(const THuiImage& aImage, |
|
610 const THuiRealPoint& aPos, |
|
611 const THuiRealSize& aSize); |
|
612 |
|
613 /** |
|
614 * Draws two images using the current pen color and alignment mode. |
|
615 * The images are combined using the current texture mode. |
|
616 * |
|
617 * @param aImage Image specification. |
|
618 * @param aImage2 Image specification. |
|
619 * @param aPos Origin point. Relative to the selected alignment point, |
|
620 * @see SetAlign() |
|
621 * @param aSize Size of the image. |
|
622 */ |
|
623 IMPORT_C virtual void DrawImages(const THuiImage& aImage, |
|
624 const THuiImage& aImage2, |
|
625 const THuiRealPoint& aPos, |
|
626 const THuiRealSize& aSize); |
|
627 |
|
628 /** |
|
629 * Draws an image scaled to a specific size inside the bounds. |
|
630 * |
|
631 * @param aImage Image specification. |
|
632 * @param aSize Size of the image. |
|
633 * @param aBounds Rectangle in which to place the image, |
|
634 * based on alignment. @see SetAlign() |
|
635 */ |
|
636 IMPORT_C virtual void DrawImage(const THuiImage& aImage, |
|
637 const THuiRealSize& aSize, |
|
638 const THuiRealRect& aBounds); |
|
639 |
|
640 /** |
|
641 * Draws two images scaled to a specific size inside the bounds. |
|
642 * The images are combined using the current texture mode. |
|
643 * |
|
644 * @param aImage First image specification. |
|
645 * @param aImage2 Second image specification. |
|
646 * @param aSize Size of the image. |
|
647 * @param aBounds Rectangle in which to place the image, |
|
648 * based on alignment. @see SetAlign() |
|
649 * |
|
650 * @todo If multitexturing is not supported, use two calls to |
|
651 * DrawImage with suitable blending to achieve the same effect in |
|
652 * two passes.. |
|
653 * |
|
654 * Currently, if multitexturing is not supported, only the first |
|
655 * image will be drawn. |
|
656 */ |
|
657 IMPORT_C virtual void DrawImages(const THuiImage& aImage, |
|
658 const THuiImage& aImage2, |
|
659 const THuiRealSize& aSize, |
|
660 const THuiRealRect& aBounds); |
|
661 |
|
662 /** |
|
663 * Draws an image, placing it inside the given bounds using the alignment |
|
664 * settings. |
|
665 */ |
|
666 IMPORT_C virtual void DrawImage(const THuiImage& aImage, |
|
667 const THuiRealRect& aBounds); |
|
668 |
|
669 |
|
670 /** |
|
671 * Draws a rectangle with the current graphics context parameters. |
|
672 * |
|
673 * @param aRect Rectangle to draw. |
|
674 */ |
|
675 IMPORT_C virtual void DrawRect(const TRect& aRect) = 0; |
|
676 |
|
677 /** |
|
678 * Draws a solid line of uniform thickness with the current graphics context parameters. |
|
679 * |
|
680 * @param aStart Start of line. |
|
681 * @param aEnd End of line. |
|
682 * @param aThickness Thickness of line in pixels. |
|
683 */ |
|
684 IMPORT_C virtual void DrawLine(const TPoint& aStart, const TPoint& aEnd, const TInt aThickness) = 0; |
|
685 |
|
686 /** |
|
687 * Draws a stretched image. |
|
688 * |
|
689 * You may define a starting and ending sections for the image that will |
|
690 * not be stretched. This is useful for example in drawing scrollbars with |
|
691 * arrows on a single run where the center of the image is stretched, |
|
692 * but the arrows at the ends are drawn unstretched. |
|
693 * |
|
694 * @param aMode Stretch mode. |
|
695 * @param aImage Image to draw stretched. |
|
696 * @param aRect Rectangle to fill. |
|
697 * @param aStretchStartWidth |
|
698 * Define width of unstretchable start section (left or |
|
699 * upper section). The pixels in this section will not be |
|
700 * stretched. Only the center section of the image |
|
701 * (between aStartWidth and aEndWidth) gets stretched. |
|
702 * Defaults to zero. |
|
703 * @param aStretchEndWidth |
|
704 * Define width of unstretchable end section (right or |
|
705 * lower section). The pixels in this section will not be |
|
706 * stretched. Only the center section of the image |
|
707 * (between aStartWidth and aEndWidth) gets stretched. |
|
708 * Defaults to zero. |
|
709 */ |
|
710 IMPORT_C virtual void DrawStretchImage(TStretchMode aMode, |
|
711 const THuiImage& aImage, |
|
712 const THuiRealRect& aRect, |
|
713 TInt aStretchStartWidth = 0, |
|
714 TInt aStretchEndWidth = 0) = 0; |
|
715 |
|
716 /** |
|
717 * Draws edges with a color or using a texture. |
|
718 * |
|
719 * @param aOuterRect The outer edge of the borders. |
|
720 * @param aLeftBorderWidth The visible width of the left border, |
|
721 * the width is assumed to be pixel units |
|
722 * inside from the respective edge |
|
723 * border. Use 0.0 for no left border. |
|
724 * @param aRightBorderWidth The visible width of the right border, |
|
725 * the width is assumed to be pixel units |
|
726 * inside from the respective edge |
|
727 * border. Use 0.0 for no right border. |
|
728 * @param aTopBorderWidth The visible height of the top border, |
|
729 * the height is assumed to be pixel units |
|
730 * inside from the respective edge |
|
731 * border. Use 0.0 for no border. |
|
732 * @param aBottomBorderWidth The visible height of the bottom border, |
|
733 * the height is assumed to be pixel units |
|
734 * inside from the respective edge |
|
735 * border. Use 0.0 for no border. |
|
736 * @param aBorderMode Border drawing mode, defines how the |
|
737 * image is streched to the borders. |
|
738 * aImage needs to be defined in order |
|
739 * to this modes to be effective. |
|
740 * @param aImage The image to be used to draw borders, |
|
741 * according to the border drawing mode. |
|
742 * If left NULL will use the current pen |
|
743 * color to draw single-color borders. |
|
744 */ |
|
745 IMPORT_C virtual void DrawBorders(const TRect& aOuterRect, |
|
746 TReal32 aLeftBorderWidth, |
|
747 TReal32 aRightBorderWidth, |
|
748 TReal32 aTopBorderHeight, |
|
749 TReal32 aBottomBorderHeight, |
|
750 TBorderMode aBorderMode = EBorderImage, |
|
751 const THuiImage* aImage = 0) __SOFTFP = 0; |
|
752 |
|
753 |
|
754 /** |
|
755 * Draws a path from the beginning to aPos. |
|
756 * |
|
757 * @param aPath Weighted path. |
|
758 * @param aOrigin Offset. |
|
759 * @param aStartPos Start position on the path. |
|
760 * @param aEndPos End position on the path. |
|
761 * @param aAlphaFunction Function for determining alpha values. |
|
762 * @param aWidthFunction Function for determining line thickness. |
|
763 */ |
|
764 IMPORT_C virtual void DrawPath(const CHuiCurvePath& aPath, |
|
765 const TPoint& aOrigin, |
|
766 TReal32 aStartPos, |
|
767 TReal32 aEndPos, |
|
768 MHuiMappingFunction* aAlphaFunction = 0, |
|
769 MHuiMappingFunction* aWidthFunction = 0) __SOFTFP = 0; |
|
770 |
|
771 /** |
|
772 * Sets up the appropriate rendering mode and draws the mesh. The caller |
|
773 * is responsible for setting up the transformation and projection. |
|
774 * |
|
775 * @param aMesh Mesh to draw. |
|
776 * @param aImage Primary surface image. |
|
777 * @param aSecondaryImage Secondary surface image. |
|
778 * @param aSecondaryAlpha Alpha level of the secondary image. |
|
779 */ |
|
780 IMPORT_C virtual void DrawMesh(const CHuiMesh& aMesh, |
|
781 const THuiImage* aImage = 0, |
|
782 const THuiImage* aSecondaryImage = 0, |
|
783 TReal32 aSecondaryAlpha = 0.0) __SOFTFP = 0; |
|
784 |
|
785 /** |
|
786 * Draws a thick arc. |
|
787 * |
|
788 * @param aOrigin Center of the arc. |
|
789 * @param aRadius Radius of the arc. |
|
790 * @param aStart Start angle of the arc (degrees). |
|
791 * @param aEnd End angle of the arc (degrees). |
|
792 * @param aAnglePerSegment Degrees per segment. |
|
793 * @param aWidth Width of the segment line. |
|
794 * @param aImage Texture to use on the segment line. |
|
795 * @param aAlphaFunc Angle (degrees) to alpha (0..1) mapping function. |
|
796 * @param aAbsoluteAngleParm If true, absolute angles given to alpha func. |
|
797 */ |
|
798 IMPORT_C virtual void DrawArc(const TPoint& aOrigin, const TSize& aRadius, |
|
799 TReal32 aStart, TReal32 aEnd, TInt aAnglePerSegment, |
|
800 TReal32 aWidth, const THuiImage& aImage, |
|
801 TReal32 (*aAlphaFunc)(TReal32)=0, |
|
802 TBool aAbsoluteAngleParm = EFalse) __SOFTFP = 0; |
|
803 |
|
804 /** |
|
805 * Draws a gradient. |
|
806 * |
|
807 * @param aType Direction of the gradient. |
|
808 * @param aRect Coordinates of the rectangle in which the gradient is drawn. |
|
809 * @param aStartColor Color of the gradient on the start edge. |
|
810 * @param aEndColor Color of the gradient on the end edge. |
|
811 * @param aStartOpacity Optional opacity for the start edge. Opacity is gradually |
|
812 * interpolated as well. |
|
813 * @param aEndOpacity Optional opacity for the end edge. |
|
814 * @param aTexCoords Optional texture coordinates for the gradient rectangle. |
|
815 * If this is NULL, texturing is disabled when the gradient is |
|
816 * drawn. Otherwise, the currently bound texture is used as |
|
817 * the texture in the gradient rectangle. |
|
818 */ |
|
819 IMPORT_C virtual void DrawGradient(TGradientType aType, const TRect& aRect, |
|
820 const TRgb& aStartColor, const TRgb& aEndColor, |
|
821 TReal32 aStartOpacity = 1.0, |
|
822 TReal32 aEndOpacity = 1.0, |
|
823 const THuiRealRect* aTexCoords = 0) __SOFTFP = 0; |
|
824 |
|
825 /** |
|
826 * Returns the currently active font. |
|
827 */ |
|
828 IMPORT_C THuiFont* Font(); |
|
829 |
|
830 /** |
|
831 * Determines the near clip distance of the context. |
|
832 */ |
|
833 IMPORT_C TReal32 NearClipDistance() const __SOFTFP; |
|
834 |
|
835 /** |
|
836 * Determines the far clip distance of the context. |
|
837 */ |
|
838 IMPORT_C TReal32 FarClipDistance() const __SOFTFP; |
|
839 |
|
840 /** |
|
841 * Returns the FOV factor. |
|
842 */ |
|
843 IMPORT_C TReal32 FovFactor() const __SOFTFP; |
|
844 |
|
845 /** |
|
846 * Determines the Z offset for 2D graphics so that they are projected |
|
847 * correctly when using a 3D projection. |
|
848 */ |
|
849 IMPORT_C TReal32 Offset2D() const __SOFTFP; |
|
850 |
|
851 /** |
|
852 * Sets a depth offset. The depth offset is used when drawing overlaid |
|
853 * surfaces with the same Z coordinates. Normally the depth offset is |
|
854 * always zero. |
|
855 * |
|
856 * @param aOffset Offset units. |
|
857 */ |
|
858 IMPORT_C virtual void SetDepthOffset(TInt aOffset) = 0; |
|
859 |
|
860 /** |
|
861 * Makes a screen capture of the graphics context's current content. |
|
862 * |
|
863 * @param aSize Returns the size of the buffer. |
|
864 * @return Rgb888 version of the content. Caller must pop and destroy |
|
865 * the returned buffer. |
|
866 */ |
|
867 IMPORT_C virtual TUint8* CaptureLC(TSize& aSize) const = 0; |
|
868 |
|
869 /** |
|
870 * Sets a transformation that is applied as the final step of projection. |
|
871 * To remove the transformation, set to <code>NULL</code>. |
|
872 * |
|
873 * @param aWindowTransformation Window transformation steps. |
|
874 */ |
|
875 IMPORT_C void SetWindowTransformation(CHuiTransformation* aWindowTransformation); |
|
876 |
|
877 |
|
878 // @TODO: Renderer pluginization change: Should these be pure virtual or not? |
|
879 /** |
|
880 * Enables transformations for clipping rects. Implementing this method in |
|
881 * inherited classes is optional (if e.g. transformed clipping rectangles |
|
882 * aren't supported) |
|
883 * |
|
884 * @param aEnable To transform clipping rects or not. |
|
885 */ |
|
886 IMPORT_C virtual void EnableTransformedClippingRects(TBool aEnable=ETrue); |
|
887 |
|
888 /** |
|
889 * Replace the current clipping rectangle. Implementing this method in |
|
890 * inherited classes is optional (if e.g. transformed clipping rectangles |
|
891 * aren't supported) |
|
892 * |
|
893 * @param aClipRect Clipping rectangle in display coordinates. |
|
894 * @param aTransformClipRect If ETrue. new clipping rect is transformed before it is taken as current rect. |
|
895 */ |
|
896 IMPORT_C virtual void SetClip(const TRect& aClipRect, TBool aTransformClipRect); |
|
897 |
|
898 /** |
|
899 * Transforms a dirty rectangle. Implementing this method in |
|
900 * inherited classes is optional (if e.g. dirty rects aren't supported) |
|
901 * |
|
902 * @param aRect Rectangle to transform. |
|
903 */ |
|
904 IMPORT_C virtual void TransformDirtyRect(THuiRealRect& aRect); |
|
905 |
|
906 |
|
907 /* Static methods. */ |
|
908 |
|
909 /** |
|
910 * Determines the horizontal alignment used for text in the current locale. |
|
911 * Applications can use this for any text whose placement should change |
|
912 * depending on the locale. |
|
913 * |
|
914 * @return Left or right alignment. |
|
915 */ |
|
916 IMPORT_C static THuiAlignHorizontal LocaleTextAlignment(); |
|
917 |
|
918 public: |
|
919 |
|
920 /** |
|
921 * Notifies image (and its texture object if it exists) that it is currently being |
|
922 * drawn into the display as the given size. Image may use this information to |
|
923 * resize itself to a more optimal size. |
|
924 * |
|
925 * @aImage Image that is drawn. |
|
926 * @aRect Rect where image is drawn. |
|
927 * |
|
928 */ |
|
929 IMPORT_C void NotifyImagePreferredSize(const THuiImage& aImage, THuiRealRect aRect); |
|
930 |
|
931 protected: |
|
932 |
|
933 /* Constructors. */ |
|
934 |
|
935 /** |
|
936 * Constructor. |
|
937 */ |
|
938 IMPORT_C CHuiGc(); |
|
939 |
|
940 /* Methods. */ |
|
941 |
|
942 /** |
|
943 * Determines the projection viewport. |
|
944 */ |
|
945 IMPORT_C TRect ProjectionViewport() const; |
|
946 |
|
947 /** |
|
948 * Determines the display area not affected by orientation. |
|
949 */ |
|
950 IMPORT_C TRect RawDisplayArea() const; |
|
951 |
|
952 /** |
|
953 * Determines the current window transformation. |
|
954 * |
|
955 * @return CHuiTransformation, or <code>NULL</code> if none defined. |
|
956 */ |
|
957 IMPORT_C const CHuiTransformation* WindowTransformation() const; |
|
958 |
|
959 /** |
|
960 * Orients the rectangle back to the normal orientation. |
|
961 */ |
|
962 IMPORT_C TRect UnOrientRect(const TRect& aOrientedRect) const; |
|
963 |
|
964 /** |
|
965 * Orients the region back to the normal orientation. |
|
966 */ |
|
967 IMPORT_C void UnOrientRegion(TRegion& aOrientedRegion) const; |
|
968 |
|
969 /** |
|
970 * Calculate offset using the current alignment mode. |
|
971 * |
|
972 * @param bounds Size of the object being aligned. |
|
973 * |
|
974 * @return Offset from top-left corner. |
|
975 */ |
|
976 IMPORT_C TPoint AlignOffset(const TSize& aBounds) const; |
|
977 |
|
978 /** |
|
979 * Sets the current OpenGL color based on the current selected Pen |
|
980 * color value. |
|
981 */ |
|
982 IMPORT_C virtual void UpdateColor(TReal32 aAlphaFactor = 1.f) __SOFTFP = 0; |
|
983 |
|
984 /** |
|
985 * Draw the image. |
|
986 * |
|
987 * @param aImage Image to draw. |
|
988 * @param aTopLeft Coordinates of the top left corner. |
|
989 * @param aSize Size of the image. |
|
990 */ |
|
991 IMPORT_C virtual void DoDrawImage(const THuiImage& aImage, const THuiRealPoint& aTopLeft, |
|
992 const THuiRealSize& aSize) = 0; |
|
993 |
|
994 /** |
|
995 * Draws two images simultaneously. Requires at least two texture units. |
|
996 * |
|
997 * Segment count must match and sizes must match if using multiple segments. |
|
998 * Otherwise nothing is drawn. |
|
999 * |
|
1000 * @param aImage Image to draw. |
|
1001 * @param aImage2 Secondary image to draw. |
|
1002 * @param aTopLeft Coordinates for the top left corner. |
|
1003 * @param aSize Size of the image. |
|
1004 */ |
|
1005 IMPORT_C virtual void DoDrawImages(const THuiImage& aImage, |
|
1006 const THuiImage& aImage2, |
|
1007 const THuiRealPoint& aTopLeft, |
|
1008 const THuiRealSize& aSize) = 0; |
|
1009 |
|
1010 |
|
1011 protected: // New methods |
|
1012 |
|
1013 /** |
|
1014 * Provides expandability, helps keeping the binary compatibility. Since virtual |
|
1015 * table is now exported and this class is dll derivable and the implementation |
|
1016 * is more difficult to change, hence this method, which can provide additional |
|
1017 * extension APIs. |
|
1018 * |
|
1019 * @param aExtensionUid UID, which is being used for recognizing the extension |
|
1020 * @param aExtensionParams Return pointer to the extension API, once recognized from the extension uid |
|
1021 */ |
|
1022 IMPORT_C virtual void GcExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
1023 |
|
1024 private: |
|
1025 |
|
1026 RRegion* CreateRecycledRegion(); |
|
1027 |
|
1028 void DeleteRecycledRegion(RRegion* aRegion); |
|
1029 |
|
1030 protected: |
|
1031 |
|
1032 /** Stack of clipping regions. In user coordinate space (oriented). */ |
|
1033 RPointerArray<RRegion> iClipRegionStack; |
|
1034 |
|
1035 /** Current clipping region. In user coordinate space (oriented). */ |
|
1036 RRegionBuf<KHuiGcClipRegionGranularity> iClipRegion; |
|
1037 |
|
1038 private: |
|
1039 |
|
1040 /** Private temp region for general purpose, used to avoid excessive allocations of RRegion heap objects */ |
|
1041 mutable RRegionBuf<KHuiGcClipRegionGranularity> iTempRegion; |
|
1042 |
|
1043 /** Recycled clipping region objects for performance reasons */ |
|
1044 mutable RPointerArray<RRegion> iRecycledRegions; |
|
1045 |
|
1046 /** Size and position of the display in normal orientation. */ |
|
1047 TRect iDisplayArea; |
|
1048 |
|
1049 /** Orientation of the display. */ |
|
1050 TOrientation iOrientation; |
|
1051 |
|
1052 /** Projection mode. */ |
|
1053 TProjection iProjection; |
|
1054 |
|
1055 /** Projection viewport. */ |
|
1056 TRect iProjectionViewport; |
|
1057 |
|
1058 TReal32 iNearClipDistance; |
|
1059 |
|
1060 TReal32 iFarClipDistance; |
|
1061 |
|
1062 TReal32 iFovFactor; |
|
1063 |
|
1064 /** Not owned. */ |
|
1065 CHuiTransformation* iWindowTransform; |
|
1066 |
|
1067 /** Offset for the 3D projection frustum center. */ |
|
1068 THuiRealPoint iFrustumOffset; |
|
1069 |
|
1070 /** Pen color for drawing lines. */ |
|
1071 TRgb iPenColor; |
|
1072 |
|
1073 /** Pen alpha level for drawing lines. */ |
|
1074 TUint8 iPenAlpha; |
|
1075 |
|
1076 /** Horizontal alignment mode. */ |
|
1077 THuiAlignHorizontal iAlignHorizontal; |
|
1078 |
|
1079 /** Vertical alignment mode. */ |
|
1080 THuiAlignVertical iAlignVertical; |
|
1081 |
|
1082 /** Current font. Not owned. |
|
1083 Fonts are owned by the texture manager. */ |
|
1084 THuiFont* iCurrentFont; |
|
1085 |
|
1086 /** Completeness (0..1) of the frustum offset. This is used when adjusting |
|
1087 the perspective effect in 3D projection. A complete frustum offset |
|
1088 means that the perspective is fully local to the object being drawn |
|
1089 (i.e., the visual's center point). A completeness of zero means that |
|
1090 the perspective is always in the center of the display. */ |
|
1091 TReal32 iFrustumOffsetCompleteness; |
|
1092 |
|
1093 /** Rendering quality. */ |
|
1094 THuiQuality iQuality; |
|
1095 |
|
1096 /** Clip region count held separately in case OOM happens */ |
|
1097 TInt iClipRegionStackCount; |
|
1098 }; |
|
1099 |
|
1100 #endif // __HUIGC_H__ |