|
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 #ifndef LCDGDEV_H |
|
20 #define LCDGDEV_H |
|
21 |
|
22 #include <lcdgdrv.h> |
|
23 #include "lcdgdrvif.h" |
|
24 |
|
25 class TCompactImageType |
|
26 { |
|
27 public: |
|
28 inline TCompactImageType() |
|
29 { |
|
30 } |
|
31 |
|
32 inline TCompactImageType(const TImageType& aType) |
|
33 { |
|
34 iValue = aType.iColorMode | (aType.iAlphaMode << 8) | (aType.iTransparency << 16); |
|
35 } |
|
36 |
|
37 inline TCompactImageType(const TCompactImageType& aType) |
|
38 { |
|
39 iValue=aType.iValue; |
|
40 } |
|
41 |
|
42 inline TImageType Type() const |
|
43 { |
|
44 TImageType type; |
|
45 type.iColorMode = (TDisplayMode)(iValue & 0xff); |
|
46 type.iAlphaMode = (TDisplayMode)((iValue>>8) & 0xff); |
|
47 type.iTransparency = (TTransparency)((iValue>>16)&0xff); |
|
48 return type; |
|
49 } |
|
50 |
|
51 inline TUint32 Value() const |
|
52 { |
|
53 return iValue; |
|
54 } |
|
55 |
|
56 inline TBool operator == (const TCompactImageType& aType) const |
|
57 { |
|
58 return iValue == aType.iValue; |
|
59 } |
|
60 |
|
61 private: |
|
62 TUint32 iValue; |
|
63 }; |
|
64 |
|
65 inline TUint32 Hash(const TCompactImageType& aType) |
|
66 { |
|
67 ASSERT(EColorLast <= 0x10); |
|
68 |
|
69 // |
|
70 // remove sparsity - convert to 12 bits packed, in practise we could be |
|
71 // much more aggressive since many of the displaymodes will never be |
|
72 // used. |
|
73 // |
|
74 TUint32 value = aType.Value(); |
|
75 |
|
76 return (value & 0xf) | ((value >> 4)&0xf0) | ((value >> 8) & 0xf00); |
|
77 } |
|
78 |
|
79 class TRenderKey |
|
80 { |
|
81 public: |
|
82 TCompactImageType iTargetType; |
|
83 TCompactImageType iSourceType; |
|
84 TUint32 iTransform; |
|
85 TInt iComposite; |
|
86 |
|
87 inline TBool operator == (const TRenderKey& aKey) const |
|
88 { |
|
89 return (iComposite == aKey.iComposite) && |
|
90 (iTransform == aKey.iTransform) && |
|
91 (iSourceType == aKey.iSourceType) && |
|
92 (iTargetType == aKey.iTargetType); |
|
93 } |
|
94 |
|
95 inline TBool Match(const TRenderKey& aKey) const |
|
96 { |
|
97 return (iComposite == aKey.iComposite) && |
|
98 (iTransform & aKey.iTransform) && |
|
99 (iSourceType == aKey.iSourceType) && |
|
100 (iTargetType == aKey.iTargetType); |
|
101 } |
|
102 }; |
|
103 |
|
104 // |
|
105 // |
|
106 // |
|
107 class TRenderEntry |
|
108 { |
|
109 public: |
|
110 TImageRenderer iRenderer; |
|
111 TRenderKey iKey; |
|
112 |
|
113 inline TRenderKey Key() const |
|
114 { |
|
115 return iKey; |
|
116 } |
|
117 }; |
|
118 |
|
119 class TRenderHash |
|
120 { |
|
121 public: |
|
122 inline TUint32 Hash(const TRenderKey& aKey) |
|
123 { |
|
124 return (::Hash(aKey.iTargetType) << 3) |
|
125 ^ ::Hash(aKey.iSourceType) |
|
126 ^ aKey.iComposite << 1 |
|
127 ^ aKey.iTransform; |
|
128 } |
|
129 }; |
|
130 |
|
131 // |
|
132 // Device render functions supporting the target displaymode only. |
|
133 // |
|
134 class CRenderFunctions : public CBase |
|
135 { |
|
136 public: |
|
137 ~CRenderFunctions(); |
|
138 const TImageRenderer* Get(const TRenderKey& aKey); |
|
139 void AppendL(const TImageRenderer& aRenderer); |
|
140 |
|
141 private: |
|
142 RArray<TRenderEntry> iEntries; |
|
143 const TRenderEntry* iLast; |
|
144 }; |
|
145 |
|
146 class CLcdGraphicsDeviceImpl : public CLcdGraphicsDevice |
|
147 { |
|
148 public: |
|
149 CLcdGraphicsDeviceImpl |
|
150 ( |
|
151 CLcdGraphicsDriver& aDriver, |
|
152 const TImageType& aTargetType, |
|
153 CRenderFunctions* aBitBltFunctions, |
|
154 const TColorMap& aColorMap, |
|
155 const TDrawFunctions& aDrawFunctions |
|
156 ); |
|
157 ~CLcdGraphicsDeviceImpl(); |
|
158 |
|
159 virtual TUint32 DrawingCaps() const; |
|
160 |
|
161 /** |
|
162 *@return closest RGB color on 888 lattice to aRGB that can |
|
163 * be mapped without loss of information between 888 RGB color |
|
164 * space and the RGB color space of the target drawing surface. |
|
165 */ |
|
166 virtual TUint32 Quantize(TUint32 aRGB) const; |
|
167 |
|
168 /** |
|
169 * Transforming biblt from aColorBitmap/aAlphaBitmap to target surface |
|
170 * Composites source image over destination image (either alpha blending |
|
171 * or masking as appropriate to <CODE>aSrcTransparency</CODE>). |
|
172 */ |
|
173 virtual TInt DrawRegion |
|
174 ( |
|
175 const TAcceleratedBitmapInfo* aDstBitmap, |
|
176 const TRect& aDstRect, |
|
177 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
178 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
179 TTransparency aSrcTransparency, |
|
180 const TRect& aSrcRect, |
|
181 TTransformType aSrcTransform, |
|
182 const TRect& aClipRect |
|
183 ); |
|
184 |
|
185 /** |
|
186 * Transforming biblt from <CODE>aSrcColorBitmap,aSrcAlphaBitmap<CODE> |
|
187 * to <CODE>aDstColorBitmap,aDstAlphaBitmap</CODE>. |
|
188 * Copies source image pixels to destination image converting color |
|
189 * and transparency pixels to the destination format. Supports translation |
|
190 * and symmetry transformation of source image region, specified by |
|
191 * <CODE>aSrcTransform</CODE>. |
|
192 */ |
|
193 virtual TInt CopyRegion |
|
194 ( |
|
195 const TAcceleratedBitmapInfo* aDstBitmap, |
|
196 const TRect& aDstRect, |
|
197 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
198 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
199 TTransparency aSrcTransparency, |
|
200 const TRect& aSrcRect, |
|
201 TTransformType aSrcTransform, |
|
202 const TRect& aClipRect |
|
203 ); |
|
204 |
|
205 /* |
|
206 * Draw line from aStart to aEnd including both end points and |
|
207 * using line style TStrokeStyle. |
|
208 */ |
|
209 virtual TInt DrawLine |
|
210 ( |
|
211 const TAcceleratedBitmapInfo* aDstBitmap, |
|
212 const TPoint& aStart, |
|
213 const TPoint& aEnd, |
|
214 TUint32 aRGB, |
|
215 TStrokeStyle aStyle, |
|
216 const TRect& aClipRect |
|
217 ); |
|
218 |
|
219 /** |
|
220 * Draw outline of <CODE>aRect</CODE> |
|
221 */ |
|
222 virtual TInt DrawRect |
|
223 ( |
|
224 const TAcceleratedBitmapInfo* aDstBitmap, |
|
225 const TRect& aRect, |
|
226 TUint32 aRGB, |
|
227 TStrokeStyle aStyle, |
|
228 const TRect& aClipRect |
|
229 ); |
|
230 |
|
231 /** |
|
232 * Fill interior of <CODE>aRect</CODE> with color <CODE>aRGB</CODE> |
|
233 */ |
|
234 virtual TInt FillRect |
|
235 ( |
|
236 const TAcceleratedBitmapInfo* aDstBitmap, |
|
237 const TRect& aRect, |
|
238 TUint32 aRGB, |
|
239 const TRect& aClipRect |
|
240 ); |
|
241 |
|
242 /** |
|
243 * Draw the arc of an ellipse bounded by aBoundingRect in device coordinates, |
|
244 * starting the arc at aStartAngle from the ellipse horizontal axis and |
|
245 * extending for aArcAngle degrees anticlockwise. Draw with color aRGB and |
|
246 * clip to aClipRect in device coords. |
|
247 */ |
|
248 virtual TInt DrawArc |
|
249 ( |
|
250 const TAcceleratedBitmapInfo* aDstBitmap, |
|
251 const TRect& aBoundingRect, |
|
252 const TInt aStartAngle, |
|
253 const TInt aArcAngle, |
|
254 TUint32 aRGB, |
|
255 TStrokeStyle aStyle, |
|
256 const TRect& aClipRect |
|
257 ); |
|
258 |
|
259 /** |
|
260 * Fill the region bounded by an arc and the radii of its end points of an ellipse bounded |
|
261 * by aBoundingRect in device coordinates. The first radius lies at aStartAngle from the |
|
262 * ellipse horizontal axis and the second radies lies aArcAngle degrees anticlockwise |
|
263 * from the first. Fill with color aRGB and clip to aClipRect in device coords. |
|
264 */ |
|
265 virtual TInt FillArc |
|
266 ( |
|
267 const TAcceleratedBitmapInfo* aDstBitmap, |
|
268 const TRect& aBoundingRect, |
|
269 const TInt aStartAngle, |
|
270 const TInt aArcAngle, |
|
271 TUint32 aRGB, |
|
272 const TRect& aClipRect |
|
273 ); |
|
274 |
|
275 /** |
|
276 * Fill a triangle in device coordinates with color aRGB, |
|
277 * clipping to aClipRect in device coordinates. |
|
278 */ |
|
279 virtual TInt FillTriangle |
|
280 ( |
|
281 const TAcceleratedBitmapInfo* aDstBitmap, |
|
282 const TPoint aPoints[3], |
|
283 TUint32 aRGB, |
|
284 const TRect& aClipRect |
|
285 ); |
|
286 |
|
287 virtual TInt DrawText |
|
288 ( |
|
289 const TAcceleratedBitmapInfo* aDstBitmap, |
|
290 const TDesC& aText, |
|
291 const TPoint& aPoint, |
|
292 const CFont* aFont, |
|
293 TUint32 aRGB, |
|
294 const TRect& aClipRect |
|
295 ); |
|
296 |
|
297 /** |
|
298 * This function is used, when image is drawn and rendering |
|
299 * target is framebuffer of CanavsGraphicsItem. |
|
300 */ |
|
301 virtual TInt DrawRegionForCanvasGraphicsItem |
|
302 ( |
|
303 const TAcceleratedBitmapInfo* aDstBitmap, |
|
304 const TRect& aDstRect, |
|
305 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
306 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
307 TTransparency aSrcTransparency, |
|
308 const TRect& aSrcRect, |
|
309 TTransformType aSrcTransform, |
|
310 const TRect& aClipRect, |
|
311 const TCanvasGraphicsItemOperationsType& aOperation |
|
312 ); |
|
313 |
|
314 private: |
|
315 |
|
316 // support for rendering image on CanavsGraphicsItem frame buffer |
|
317 TInt PixelPitch(const TAcceleratedBitmapInfo* aBitmap); |
|
318 |
|
319 // support for rendering image on CanavsGraphicsItem frame buffer |
|
320 void CLcdGraphicsDeviceImpl::DoBlit |
|
321 ( |
|
322 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
323 const TRect& aDstRect, // must be clipped to destination |
|
324 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
325 const TLcdTransform& aTransform, // includes anchor |
|
326 const TCanvasGraphicsItemOperationsType& aOperation |
|
327 ); |
|
328 |
|
329 // support for rendering image on CanavsGraphicsItem frame buffer |
|
330 void CLcdGraphicsDeviceImpl::DoBlitLineForImage |
|
331 ( |
|
332 TUint8* aDstAddress, |
|
333 TInt aWidth, |
|
334 TUint8* aColorAddress, |
|
335 TInt aColorPixelPitch |
|
336 ); |
|
337 |
|
338 // support for rendering image on CanavsGraphicsItem frame buffer |
|
339 void CLcdGraphicsDeviceImpl::DoBlitLineForRgb |
|
340 ( |
|
341 TUint8* aDstAddress, |
|
342 TInt aWidth, |
|
343 TUint8* aColorAddress, |
|
344 TInt aColorPixelPitch |
|
345 ); |
|
346 |
|
347 protected: |
|
348 CLcdGraphicsDriver& iDriver; |
|
349 TRenderKey iRenderKey; |
|
350 CRenderFunctions* iRenderers; |
|
351 const TColorMap& iColorMap; |
|
352 const TDrawFunctions& iDrawFunctions; |
|
353 }; |
|
354 |
|
355 |
|
356 #endif // LCDGDEV_H |