|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 @released |
|
23 */ |
|
24 |
|
25 #ifndef LCDGDRV_H |
|
26 #define LCDGDRV_H |
|
27 |
|
28 #include <e32std.h> |
|
29 #include <gdi.h> |
|
30 #include <graphicsaccelerator.h> // for TAcceleratedBitmapInfo. TO BE REVIEWED |
|
31 |
|
32 // |
|
33 // NEED NAMESPACE! |
|
34 // |
|
35 |
|
36 /** |
|
37 * Supported reflections. |
|
38 */ |
|
39 enum TReflection |
|
40 { |
|
41 /** |
|
42 * Identity transformation. |
|
43 */ |
|
44 EReflectNone=0, |
|
45 /** |
|
46 * Vertical reflection (in horizontal line through region center). |
|
47 */ |
|
48 EReflectVert=1, |
|
49 /** |
|
50 * Horizontal reflection (in vertical line through region center). |
|
51 */ |
|
52 EReflectHorz=2, |
|
53 /** |
|
54 * Reflection in diagonal line from top left corner to bottom right corner |
|
55 */ |
|
56 EReflectDiag=4 |
|
57 }; |
|
58 |
|
59 /** |
|
60 * Supported transformation are all combinations of the supported reflections. |
|
61 * Note that two reflections make a rotation, so that this list includes pure |
|
62 * rotations by multiples of 90 degrees. |
|
63 */ |
|
64 enum TTransformType |
|
65 { |
|
66 ETransNone =EReflectNone, |
|
67 ETransMirrorRot180 =EReflectVert, |
|
68 ETransMirror =EReflectHorz, |
|
69 ETransRot180 =EReflectVert|EReflectHorz, |
|
70 ETransMirrorRot270 =EReflectDiag, |
|
71 ETransRot90 =EReflectVert|EReflectDiag, |
|
72 ETransRot270 =EReflectHorz|EReflectDiag, |
|
73 ETransMirrorRot90 =EReflectVert|EReflectHorz|EReflectDiag |
|
74 }; |
|
75 |
|
76 /** |
|
77 * lcdui anchor description. |
|
78 */ |
|
79 enum TAnchor |
|
80 { |
|
81 EAnchorHCenter = 1, |
|
82 EAnchorVCenter = 2, |
|
83 EAnchorLeft = 4, |
|
84 EAnchorRight = 8, |
|
85 EAnchorTop = 16, |
|
86 EAnchorBottom = 32, |
|
87 EAnchorBaseline = 64 |
|
88 }; |
|
89 |
|
90 /** |
|
91 * Transparency description. |
|
92 * |
|
93 * Note drivers need not support all these formats, but must support |
|
94 * at least one format that includes transparency information. |
|
95 */ |
|
96 enum TTransparency |
|
97 { |
|
98 /** |
|
99 * No transparency, alpha bitmap may not be present or is to be ignored. |
|
100 */ |
|
101 ETransparencyNone, |
|
102 |
|
103 /** |
|
104 * Image has a mask bitmap. Supported mask bitmap formats may include 1bpp |
|
105 * and a format that matches the color bitmap. |
|
106 */ |
|
107 ETransparencyMaskBitmap, |
|
108 |
|
109 /** |
|
110 * Image has an alpha bitmap containing alpha values. |
|
111 * Typically 8bpp 256 level alpha bitmaps will be supported. |
|
112 */ |
|
113 ETransparencyAlphaBitmap, |
|
114 |
|
115 /** |
|
116 * Image has alpha contained as channel in the color bitmap. |
|
117 * |
|
118 *@see EColor16MA display mode. |
|
119 */ |
|
120 ETransparencyAlphaChannel, |
|
121 |
|
122 /** |
|
123 * Image has mask contained as a channel in the color bitmap. |
|
124 * Equivalent to ETransparencyAlphaChannel with only two alpha |
|
125 * levels. |
|
126 */ |
|
127 ETransparencyMaskChannel, |
|
128 |
|
129 #ifdef RD_JAVA_NGA_ENABLED |
|
130 /** |
|
131 * Target surface has alpha contained as channel in the color bitmap |
|
132 * Color components are premultiplied. |
|
133 * @see ETransparencyAlphaChannel. |
|
134 * @since S60 9.2 |
|
135 */ |
|
136 ETransparencyAlphaChannelPre, |
|
137 |
|
138 /** |
|
139 * Target surface has alpha contained as channel in the color bitmap |
|
140 * Color components are premultiplied. |
|
141 * @see ETransparencyMaskChannel. |
|
142 * @since S60 9.2 |
|
143 */ |
|
144 ETransparencyMaskChannelPre, |
|
145 #endif // RD_JAVA_NGA_ENABLED |
|
146 |
|
147 |
|
148 /** |
|
149 * Image color bitmap may be able to hold transparency channel |
|
150 * but this should be ignored and the pixels treated as though |
|
151 * they were fully opaque. |
|
152 */ |
|
153 ETransparencyIgnoreChannel, |
|
154 |
|
155 /** |
|
156 * Count of enumerated transparency types - must always be the |
|
157 * last entry in this enumeration: add new values above this one. |
|
158 */ |
|
159 ETransparencyCount |
|
160 }; |
|
161 |
|
162 /** |
|
163 * Image type descriptor. |
|
164 */ |
|
165 struct TImageType |
|
166 { |
|
167 TDisplayMode iColorMode; // color bitmap displaymode |
|
168 TDisplayMode iAlphaMode; // alpha bitmap (if any) displaymode. |
|
169 TTransparency iTransparency; // transparency type |
|
170 }; |
|
171 |
|
172 enum TStrokeStyle |
|
173 { |
|
174 EStrokeSolid, |
|
175 EStrokeDotted |
|
176 }; |
|
177 |
|
178 /** |
|
179 * For CanavsGraphicsItem support |
|
180 */ |
|
181 enum TCanvasGraphicsItemOperations |
|
182 { |
|
183 ECanvasGraphicsItemImageRendering, |
|
184 ECanvasGraphicsItemRGBRendering |
|
185 }; |
|
186 typedef TCanvasGraphicsItemOperations TCanvasGraphicsItemOperationsType; |
|
187 |
|
188 |
|
189 /** |
|
190 * Private implementation class. |
|
191 */ |
|
192 class CLcdGraphicsDevice; |
|
193 |
|
194 |
|
195 /** |
|
196 * Interface to graphics driver dll's. |
|
197 * |
|
198 * Encapsulates support for bitblts and renderers for various image formats. |
|
199 * |
|
200 */ |
|
201 class CLcdGraphicsDriver : public CBase |
|
202 { |
|
203 public: |
|
204 /** |
|
205 * Transparency capabilities. |
|
206 */ |
|
207 enum TTranspanrencyCaps |
|
208 { |
|
209 ECapTransparencyMask1Bpp=0x1, |
|
210 ECapTransparencyMaskMatched=0x2, |
|
211 ECapTransparencyAlpha8Bpp=0x4, |
|
212 ECapTransparencyAlphaChannel8=0x8, |
|
213 ECapTransparencyMaskChannel8=0x10 |
|
214 }; |
|
215 |
|
216 /** |
|
217 * Driver info. |
|
218 */ |
|
219 struct TDriverInfo |
|
220 { |
|
221 TVersion iVersion; // |
|
222 TBuf<64> iProvider; // driver provider |
|
223 TInt iTransparencyCaps; // |
|
224 TDisplayMode iDisplayMode; // primary display mode |
|
225 TDisplayMode iARGB8888Mode; // how driver recognises ARGB8888 pixels |
|
226 }; |
|
227 |
|
228 public: |
|
229 /** |
|
230 * Factory method creates a new CLcdGraphicsDriver instance for |
|
231 * images of type <CODE>aPrimaryMode</CODE>). |
|
232 */ |
|
233 IMPORT_C static CLcdGraphicsDriver* NewL(TDisplayMode aPrimaryMode); |
|
234 |
|
235 /** |
|
236 * |
|
237 */ |
|
238 virtual void GetDriverInfo(TDriverInfo& aInfo) const = 0; |
|
239 |
|
240 /** |
|
241 * Transforming bitblt from aColorBitmap/aAlphaBitmap to aDestBitmap |
|
242 * Composites source image over destination image (either alpha blending |
|
243 * or masking as appropriate to <CODE>aSrcTransparency</CODE>). |
|
244 * Destination bitmap is treated as being opaque. |
|
245 * |
|
246 * Note: This method does not support target bitmaps with alpha channel. |
|
247 */ |
|
248 virtual TInt DrawRegion |
|
249 ( |
|
250 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
251 const TRect& aDstRect, |
|
252 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
253 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
254 TTransparency aSrcTransparency, |
|
255 const TRect& aSrcRect, |
|
256 TTransformType aSrcTransform, |
|
257 const TRect& aClipRect |
|
258 ) = 0; |
|
259 |
|
260 /** |
|
261 * Transforming bitblt from <CODE>aSrcColorBitmap,aSrcAlphaBitmap<CODE> |
|
262 * to <CODE>aDstColorBitmap,aDstAlphaBitmap</CODE>. |
|
263 * Copies source image pixels to destination image converting color |
|
264 * and transparency pixels to the destination format. Supports translation |
|
265 * and symmetry transformation of source image region, specified by |
|
266 * <CODE>aSrcTransform</CODE>. |
|
267 */ |
|
268 virtual TInt CopyRegion |
|
269 ( |
|
270 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
271 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
272 TTransparency aDstTransparency, |
|
273 const TRect& aDstRect, |
|
274 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
275 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
276 TTransparency aSrcTransparency, |
|
277 const TRect& aSrcRect, |
|
278 TTransformType aSrcTransform, |
|
279 const TRect& aClipRect |
|
280 ) = 0; |
|
281 |
|
282 /** |
|
283 * |
|
284 */ |
|
285 virtual TBool DetectCollision |
|
286 ( |
|
287 const TAcceleratedBitmapInfo* aMask1, |
|
288 TTransparency aTransparency1, |
|
289 const TSize& aSize1, |
|
290 const TRect& aRect1, |
|
291 TInt aTransform1, |
|
292 const TPoint& aPoint1, |
|
293 |
|
294 const TAcceleratedBitmapInfo* aMask2, |
|
295 TTransparency aTransparency2, |
|
296 const TSize& aSize2, |
|
297 const TRect& aRect2, |
|
298 TInt aTransform2, |
|
299 const TPoint& aPoint2 |
|
300 ) = 0; |
|
301 |
|
302 /** |
|
303 * |
|
304 */ |
|
305 virtual CLcdGraphicsDevice* CreateDeviceL(const TImageType& aImageType) = 0; |
|
306 }; |
|
307 |
|
308 class CLcdGraphicsDevice : public CBase |
|
309 { |
|
310 public: |
|
311 /** |
|
312 * Drawing capabilities |
|
313 */ |
|
314 enum TDrawingCaps |
|
315 { |
|
316 ECapDrawLine =0x1, |
|
317 ECapDrawRect =0x2, |
|
318 ECapFillRect =0x4, |
|
319 ECapDrawArc =0x8, |
|
320 ECapFillArc =0x10, |
|
321 ECapDrawRegion =0x20, |
|
322 ECapCopyRegion =0x40, |
|
323 ECapFillTriangle=0x80, |
|
324 ECapDrawText =0x100, |
|
325 ECapStrokeDotted=0x200, |
|
326 }; |
|
327 |
|
328 virtual TUint32 DrawingCaps() const = 0; |
|
329 |
|
330 /** |
|
331 *@return closest RGB color on 888 lattice to aRGB that can |
|
332 * be mapped without loss of information between 888 RGB color |
|
333 * space and the RGB color space of the target drawing surface. |
|
334 */ |
|
335 virtual TUint32 Quantize(TUint32 aRGB) const = 0; |
|
336 |
|
337 /** |
|
338 * Transforming bitblt from aColorBitmap/aAlphaBitmap to target surface |
|
339 * Composites source image over destination image (either alpha blending |
|
340 * or masking as appropriate to <CODE>aSrcTransparency</CODE>). |
|
341 */ |
|
342 virtual TInt DrawRegion |
|
343 ( |
|
344 const TAcceleratedBitmapInfo* aDstBitmap, |
|
345 const TRect& aDstRect, |
|
346 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
347 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
348 TTransparency aSrcTransparency, |
|
349 const TRect& aSrcRect, |
|
350 TTransformType aSrcTransform, |
|
351 const TRect& aClipRect |
|
352 ) = 0; |
|
353 |
|
354 /** |
|
355 * Transforming bitblt from <CODE>aSrcColorBitmap,aSrcAlphaBitmap<CODE> |
|
356 * to <CODE>aDstColorBitmap,aDstAlphaBitmap</CODE>. |
|
357 * Copies source image pixels to destination image converting color |
|
358 * and transparency pixels to the destination format. Supports translation |
|
359 * and symmetry transformation of source image region, specified by |
|
360 * <CODE>aSrcTransform</CODE>. |
|
361 */ |
|
362 virtual TInt CopyRegion |
|
363 ( |
|
364 const TAcceleratedBitmapInfo* aDstBitmap, |
|
365 const TRect& aDstRect, |
|
366 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
367 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
368 TTransparency aSrcTransparency, |
|
369 const TRect& aSrcRect, |
|
370 TTransformType aSrcTransform, |
|
371 const TRect& aClipRect |
|
372 ) = 0; |
|
373 |
|
374 /* |
|
375 * Draw line from aStart to aEnd including both end points and |
|
376 * using line style TStrokeStyle. |
|
377 */ |
|
378 virtual TInt DrawLine |
|
379 ( |
|
380 const TAcceleratedBitmapInfo* aDstBitmap, |
|
381 const TPoint& aStart, |
|
382 const TPoint& aEnd, |
|
383 TUint32 aRGB, |
|
384 TStrokeStyle aStyle, |
|
385 const TRect& aClipRect |
|
386 ) = 0; |
|
387 |
|
388 /** |
|
389 * Draw outline of <CODE>aRect</CODE> |
|
390 */ |
|
391 virtual TInt DrawRect |
|
392 ( |
|
393 const TAcceleratedBitmapInfo* aDstBitmap, |
|
394 const TRect& aRect, |
|
395 TUint32 aRGB, |
|
396 TStrokeStyle aStyle, |
|
397 const TRect& aClipRect |
|
398 ) = 0; |
|
399 |
|
400 /** |
|
401 * Fill interior of <CODE>aRect</CODE> with color <CODE>aRGB</CODE> |
|
402 */ |
|
403 virtual TInt FillRect |
|
404 ( |
|
405 const TAcceleratedBitmapInfo* aDstBitmap, |
|
406 const TRect& aRect, |
|
407 TUint32 aRGB, |
|
408 const TRect& aClipRect |
|
409 ) = 0; |
|
410 |
|
411 /** |
|
412 * Draw the arc of an ellipse bounded by aBoundingRect in device coordinates, |
|
413 * starting the arc at aStartAngle from the ellipse horizontal axis and |
|
414 * extending for aArcAngle degrees anticlockwise. Draw with color aRGB and |
|
415 * clip to aClipRect in device coords. |
|
416 */ |
|
417 virtual TInt DrawArc |
|
418 ( |
|
419 const TAcceleratedBitmapInfo* aDstBitmap, |
|
420 const TRect& aBoundingRect, |
|
421 const TInt aStartAngle, |
|
422 const TInt aArcAngle, |
|
423 TUint32 aRGB, |
|
424 TStrokeStyle aStyle, |
|
425 const TRect& aClipRect |
|
426 ) = 0; |
|
427 |
|
428 /** |
|
429 * Fill the region bounded by an arc and the radii of its end points of an ellipse bounded |
|
430 * by aBoundingRect in device coordinates. The first radius lies at aStartAngle from the |
|
431 * ellipse horizontal axis and the second radies lies aArcAngle degrees anticlockwise |
|
432 * from the first. Fill with color aRGB and clip to aClipRect in device coords. |
|
433 */ |
|
434 virtual TInt FillArc |
|
435 ( |
|
436 const TAcceleratedBitmapInfo* aDstBitmap, |
|
437 const TRect& aBoundingRect, |
|
438 const TInt aStartAngle, |
|
439 const TInt aArcAngle, |
|
440 TUint32 aRGB, |
|
441 const TRect& aClipRect |
|
442 ) = 0; |
|
443 |
|
444 /** |
|
445 * Fill a triangle in device coordinates with color aRGB, |
|
446 * clipping to aClipRect in device coordinates. |
|
447 */ |
|
448 virtual TInt FillTriangle |
|
449 ( |
|
450 const TAcceleratedBitmapInfo* aDstBitmap, |
|
451 const TPoint aPoints[3], |
|
452 TUint32 aRGB, |
|
453 const TRect& aClipRect |
|
454 ) = 0; |
|
455 |
|
456 /** |
|
457 * |
|
458 */ |
|
459 virtual TInt DrawText |
|
460 ( |
|
461 const TAcceleratedBitmapInfo* aDstBitmap, |
|
462 const TDesC& aText, |
|
463 const TPoint& aPoint, |
|
464 const CFont* aFont, |
|
465 TUint32 aRGB, |
|
466 const TRect& aClipRect |
|
467 ) = 0; |
|
468 |
|
469 /** |
|
470 * This function is used, when image is drawn and rendering |
|
471 * target is framebuffer of CanavsGraphicsItem. |
|
472 */ |
|
473 virtual TInt DrawRegionForCanvasGraphicsItem |
|
474 ( |
|
475 const TAcceleratedBitmapInfo* /*aDstBitmap*/, |
|
476 const TRect& /*aDstRect*/, |
|
477 const TAcceleratedBitmapInfo* /*aSrcColorBitmap*/, |
|
478 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
479 TTransparency /*aSrcTransparency*/, |
|
480 const TRect& /*aSrcRect*/, |
|
481 TTransformType /*aSrcTransform*/, |
|
482 const TRect& /*aClipRect*/, |
|
483 const TCanvasGraphicsItemOperationsType& /*aOperation*/ |
|
484 ) |
|
485 { |
|
486 return KErrNone; |
|
487 } |
|
488 |
|
489 }; |
|
490 |
|
491 #endif // LCDGDRV_H |