|
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 #include <graphicsaccelerator.h> |
|
19 #include <implementationproxy.h> |
|
20 |
|
21 #include "lcdgdrvif.h" |
|
22 #include "lcdtransform.h" |
|
23 #include "lcdgdrvutil.h" |
|
24 #include "lcdgd.hrh" |
|
25 #include "collision.h" |
|
26 #include "lcdbitblt.h" |
|
27 #include "lcd32bpp.h" |
|
28 |
|
29 |
|
30 inline TInt Color16MURed(TInt aColor16MU) |
|
31 { |
|
32 return (aColor16MU >> 16) & 0xff; |
|
33 } |
|
34 |
|
35 inline TInt Color16MUGreen(TInt aColor16MU) |
|
36 { |
|
37 return (aColor16MU >> 8) & 0xff; |
|
38 } |
|
39 |
|
40 inline TInt Color16MUBlue(TInt aColor16MU) |
|
41 { |
|
42 return (aColor16MU & 0xff); |
|
43 } |
|
44 |
|
45 inline TUint32 ARGB8888ToColor16MU(TUint32 aARGB) |
|
46 { |
|
47 return aARGB & 0xffffff; |
|
48 } |
|
49 |
|
50 inline TUint32 Color16MU(TInt aRed, TInt aGreen, TInt aBlue) |
|
51 { |
|
52 return TUint32((aRed << 16) | (aGreen << 8) | aBlue); |
|
53 } |
|
54 |
|
55 LOCAL_C TUint32 Color16MUForward(TUint32 aRGB) |
|
56 { |
|
57 return ARGB8888ToColor16MU(aRGB); |
|
58 } |
|
59 |
|
60 LOCAL_C TUint32 Color16MUReverse(TUint32 aColor16MU) |
|
61 { |
|
62 return aColor16MU; // NB: no transparency bits. |
|
63 } |
|
64 |
|
65 LOCAL_C TUint32 Color16MUQuantize(TUint32 aRGB) |
|
66 { |
|
67 return aRGB & 0xffffff; |
|
68 } |
|
69 |
|
70 // |
|
71 // DrawRegion support |
|
72 // |
|
73 |
|
74 |
|
75 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
76 LOCAL_C void DrawRegionColor16MUMaskToColor16MU |
|
77 ( |
|
78 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
79 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
80 const TRect& aDstRect, // must be clipped to destination |
|
81 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
82 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
83 const TLcdTransform& aTransform // includes anchor |
|
84 ); |
|
85 LOCAL_C void DrawImageColor16MUMaskToColor16MU |
|
86 ( |
|
87 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
88 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
89 const TRect& aDstRect, // must be clipped to destination |
|
90 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
91 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
92 const TLcdTransform& aTransform // includes anchor |
|
93 ); |
|
94 #endif |
|
95 |
|
96 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
97 LOCAL_C void DrawRegionColor16MUColor16MUToColor16MU |
|
98 ( |
|
99 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
100 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
101 const TRect& aDstRect, // must be clipped to destination |
|
102 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
103 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
104 const TLcdTransform& aTransform // includes anchor |
|
105 ); |
|
106 |
|
107 #endif |
|
108 |
|
109 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
110 LOCAL_C void DrawRegionColor16MUAlphaToColor16MU |
|
111 ( |
|
112 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
113 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
114 const TRect& aDstRect, // must be clipped to destination |
|
115 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
116 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
117 const TLcdTransform& aTransform // includes anchor |
|
118 ); |
|
119 #endif |
|
120 |
|
121 |
|
122 LOCAL_C void DrawRegionARGB8888AlphaChannelToColor16MU |
|
123 ( |
|
124 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
125 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
126 const TRect& aDstRect, // must be clipped to destination |
|
127 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
128 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
129 const TLcdTransform& aTransform // includes anchor |
|
130 ); |
|
131 |
|
132 // |
|
133 // BitBlt support |
|
134 // |
|
135 |
|
136 LOCAL_C void BitBltColor16MUToARGB8888 |
|
137 ( |
|
138 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
139 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
140 const TRect& aDstRect, |
|
141 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
142 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
143 const TLcdTransform& aTransform |
|
144 ); |
|
145 LOCAL_C void BitBltARGB8888ToColor16MU |
|
146 ( |
|
147 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
148 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
149 const TRect& aDstRect, |
|
150 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
151 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
152 const TLcdTransform& aTransform |
|
153 ); |
|
154 |
|
155 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
156 LOCAL_C void BitBltColor16MUGray2ToARGB8888 |
|
157 ( |
|
158 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
159 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
160 const TRect& aDstRect, |
|
161 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
162 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
163 const TLcdTransform& aTransform |
|
164 ); |
|
165 LOCAL_C void BitBltARGB8888ToColor16MUGray2 |
|
166 ( |
|
167 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
168 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
169 const TRect& aDstRect, |
|
170 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
171 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
172 const TLcdTransform& aTransform |
|
173 ); |
|
174 #endif |
|
175 |
|
176 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
177 LOCAL_C void BitBltColor16MUColor16MUToARGB8888 |
|
178 ( |
|
179 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
180 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
181 const TRect& aDstRect, |
|
182 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
183 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
184 const TLcdTransform& aTransform |
|
185 ); |
|
186 LOCAL_C void BitBltARGB8888ToColor16MUColor16MU |
|
187 ( |
|
188 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
189 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
190 const TRect& aDstRect, |
|
191 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
192 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
193 const TLcdTransform& aTransform |
|
194 ); |
|
195 #endif |
|
196 |
|
197 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
198 LOCAL_C void BitBltColor16MUGray256ToARGB8888 |
|
199 ( |
|
200 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
201 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
202 const TRect& aDstRect, |
|
203 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
204 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
205 const TLcdTransform& aTransform |
|
206 ); |
|
207 LOCAL_C void BitBltARGB8888ToColor16MUGray256 |
|
208 ( |
|
209 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
210 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
211 const TRect& aDstRect, |
|
212 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
213 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
214 const TLcdTransform& aTransform |
|
215 ); |
|
216 #endif |
|
217 |
|
218 // |
|
219 // Image types supported by this DLL. |
|
220 // |
|
221 #define COLOR16MU_OPAQUE IMAGE_TYPE(EColor16MU,ENone,ETransparencyNone) |
|
222 #define COLOR16MU_MASK_1BPP IMAGE_TYPE(EColor16MU,EGray2,ETransparencyMaskBitmap) |
|
223 #define COLOR16MU_MASK_MATCHED IMAGE_TYPE(EColor16MU,EColor16MU,ETransparencyMaskBitmap) |
|
224 #define COLOR16MU_ALPHA IMAGE_TYPE(EColor16MU,EGray256,ETransparencyAlphaBitmap) |
|
225 |
|
226 const TImageRenderer ImageRendererArray[] = |
|
227 { |
|
228 // |
|
229 // SrcOver |
|
230 // |
|
231 /* target, source, transform mask, function */ |
|
232 RENDER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_OPAQUE, KTransSimpleMask, BitBltThirtyTwoBppSimple), |
|
233 RENDER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_OPAQUE, KTransAllMask, BitBltThirtyTwoBpp), |
|
234 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
235 RENDER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_MASK_1BPP, KTransNoneMask, DrawImageColor16MUMaskToColor16MU), |
|
236 RENDER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_MASK_1BPP, KTransAllMask, DrawRegionColor16MUMaskToColor16MU), |
|
237 #endif |
|
238 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
239 RENDER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_MASK_MATCHED, KTransAllMask, DrawRegionColor16MUColor16MUToColor16MU), |
|
240 #endif |
|
241 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
242 RENDER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_ALPHA, KTransAllMask, DrawRegionColor16MUAlphaToColor16MU), |
|
243 #endif |
|
244 RENDER_ENTRY(COLOR16MU_OPAQUE, JAVA_OPAQUE_IMAGE, KTransAllMask, BitBltARGB8888ToColor16MU), |
|
245 RENDER_ENTRY(COLOR16MU_OPAQUE, JAVA_ALPHA_IMAGE, KTransAllMask, DrawRegionARGB8888AlphaChannelToColor16MU), |
|
246 |
|
247 // |
|
248 // SrcCopy |
|
249 // |
|
250 /* target, source, function */ |
|
251 BLITTER_ENTRY(COLOR16MU_OPAQUE, COLOR16MU_OPAQUE, BitBltARGB8888ToColor16MU), |
|
252 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MU_OPAQUE, BitBltColor16MUToARGB8888), |
|
253 BLITTER_ENTRY(COLOR16MU_OPAQUE, JAVA_OPAQUE_IMAGE, BitBltARGB8888ToColor16MU), |
|
254 BLITTER_ENTRY(JAVA_OPAQUE_IMAGE, COLOR16MU_OPAQUE, BitBltColor16MUToARGB8888), |
|
255 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
256 BLITTER_ENTRY(COLOR16MU_MASK_1BPP, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor16MUGray2), |
|
257 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MU_MASK_1BPP, BitBltColor16MUGray2ToARGB8888), |
|
258 BLITTER_ENTRY(COLOR16MU_MASK_1BPP, COLOR16MU_MASK_1BPP, BitBltThirtyTwoBppOneBpp), |
|
259 #endif |
|
260 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
261 BLITTER_ENTRY(COLOR16MU_MASK_MATCHED, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor16MUColor16MU), |
|
262 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MU_MASK_MATCHED, BitBltColor16MUColor16MUToARGB8888), |
|
263 BLITTER_ENTRY(COLOR16MU_MASK_MATCHED, COLOR16MU_MASK_MATCHED, BitBltThirtyTwoBppThirtyTwoBpp), |
|
264 #endif |
|
265 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
266 BLITTER_ENTRY(COLOR16MU_ALPHA, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor16MUGray256), |
|
267 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MU_ALPHA, BitBltColor16MUGray256ToARGB8888), |
|
268 BLITTER_ENTRY(COLOR16MU_ALPHA, COLOR16MU_ALPHA, BitBltThirtyTwoBppEightBpp), |
|
269 #endif |
|
270 }; |
|
271 const TInt ImageRendererCount = sizeof(ImageRendererArray)/sizeof(ImageRendererArray[0]); |
|
272 |
|
273 const TCollisionDetector CollisionDetectorArray[] = |
|
274 { |
|
275 // |
|
276 // Supported collision detectors. |
|
277 // |
|
278 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray2Gray2), |
|
279 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, ENoneBit,ETransparencyNoneBit, DetectCollisionGray2Gray2), |
|
280 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray2Gray2), |
|
281 |
|
282 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
283 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray256Gray256), |
|
284 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray2Gray256), |
|
285 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray256Gray2), |
|
286 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, ENoneBit,ETransparencyNoneBit, DetectCollisionGray256Gray256), |
|
287 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray256Gray256), |
|
288 #endif |
|
289 |
|
290 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
291 COLLISION_DETECTOR_ENTRY(KGenericModesMask,KGenericTransMask, KGenericModesMask,KGenericTransMask, GenericDetectCollision), |
|
292 #endif |
|
293 }; |
|
294 const TInt CollisionDetectorCount = sizeof(CollisionDetectorArray)/sizeof(CollisionDetectorArray[0]); |
|
295 |
|
296 const TColorMap ColorMapArray[] = |
|
297 { |
|
298 { EColor16MU, Color16MUForward, Color16MUReverse, Color16MUQuantize } |
|
299 }; |
|
300 const TInt ColorMapCount = sizeof(ColorMapArray)/sizeof(ColorMapArray[0]); |
|
301 |
|
302 const TDrawFunctions DrawFunctionsArray[] = |
|
303 { |
|
304 { |
|
305 EColor16MU, |
|
306 CLcdGraphicsDevice::ECapFillTriangle, |
|
307 NULL, // drawLine |
|
308 NULL, // drawRect |
|
309 NULL, // fillRect |
|
310 NULL, // drawArc |
|
311 NULL, // fillArc |
|
312 &FillTriangle32Bpp, |
|
313 NULL // drawText |
|
314 } |
|
315 }; |
|
316 const TInt DrawFunctionsCount = sizeof(DrawFunctionsArray)/sizeof(DrawFunctionsArray[0]); |
|
317 |
|
318 const TInt KVersionBuild = 0; |
|
319 |
|
320 _LIT(KProviderSymbianSoftwareLtd, "Symbian Software Ltd"); |
|
321 |
|
322 LOCAL_C CLcdGraphicsDriverImpl* CreateColor16MUDriverL(); |
|
323 |
|
324 const TImplementationProxy ImplementationTable[] = |
|
325 { |
|
326 IMPLEMENTATION_PROXY_ENTRY(LCDGD_COLOR16MU_IMPLEMENTATION_UID, CreateColor16MUDriverL) |
|
327 }; |
|
328 |
|
329 /** |
|
330 * Ordinal 1 |
|
331 */ |
|
332 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
333 { |
|
334 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
335 return ImplementationTable; |
|
336 } |
|
337 |
|
338 CLcdGraphicsDriverImpl* CreateColor16MUDriverL() |
|
339 { |
|
340 CLcdGraphicsDriver::TDriverInfo driverInfo; |
|
341 |
|
342 driverInfo.iVersion = TVersion(KLcdImgVersionMajor, KLcdImgVersionMinor, KVersionBuild); |
|
343 driverInfo.iProvider = KProviderSymbianSoftwareLtd; |
|
344 driverInfo.iTransparencyCaps = CAP_1BPP_MASK_BITMAP|CAP_MATCHED_MASK_BITMAP|CAP_ALPHA_BITMAP; |
|
345 driverInfo.iARGB8888Mode = EColorARGB8888; |
|
346 driverInfo.iDisplayMode = EColor16MU; |
|
347 |
|
348 return new(ELeave) CLcdGraphicsDriverImpl |
|
349 ( |
|
350 driverInfo, |
|
351 ImageRendererArray, |
|
352 ImageRendererCount, |
|
353 ColorMapArray, |
|
354 ColorMapCount, |
|
355 CollisionDetectorArray, |
|
356 CollisionDetectorCount, |
|
357 DrawFunctionsArray, |
|
358 DrawFunctionsCount |
|
359 ); |
|
360 } |
|
361 |
|
362 // *************************************************************** |
|
363 // Render Functions |
|
364 // *************************************************************** |
|
365 |
|
366 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
367 LOCAL_C void DrawRegionColor16MUMaskToColor16MU |
|
368 ( |
|
369 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
370 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
371 const TRect& aDstRect, // must be clipped to destination |
|
372 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
373 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // mask |
|
374 const TLcdTransform& aTransform // includes anchor |
|
375 ) |
|
376 { |
|
377 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
378 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
379 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray2); |
|
380 |
|
381 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
382 |
|
383 TInt dudx = aTransform.iDuDx; |
|
384 TInt dudy = aTransform.iDuDy; |
|
385 TInt dvdx = aTransform.iDvDx; |
|
386 TInt dvdy = aTransform.iDvDy; |
|
387 TInt u0 = srcPoint.iX; |
|
388 TInt v0 = srcPoint.iY; |
|
389 TInt u = u0; |
|
390 TInt v = v0; |
|
391 |
|
392 const TInt width = aDstRect.Width(); |
|
393 |
|
394 const TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
395 const TInt mskLinePitch = aSrcAlphaBitmap->iLinePitch; |
|
396 const TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
397 |
|
398 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
399 TUint8* mskAddress = aSrcAlphaBitmap->iAddress; // 1 bpp |
|
400 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
401 |
|
402 TInt x = aDstRect.iTl.iX; |
|
403 TInt y = aDstRect.iTl.iY; |
|
404 TInt h = aDstRect.Height(); |
|
405 |
|
406 // |
|
407 // Iterate over destination pixels. |
|
408 // |
|
409 dstAddress += (y*dstLinePitch + x*sizeof(TUint32)); |
|
410 for (; h>0; --h) |
|
411 { |
|
412 TUint32* dst = (TUint32*)(dstAddress); |
|
413 TUint32* end = dst + width; |
|
414 u=u0; |
|
415 v=v0; |
|
416 while (dst < end) |
|
417 { |
|
418 TInt m = *(mskAddress + v*mskLinePitch + (u>>3)); |
|
419 if (m & (1<<(u&0x7))) |
|
420 { |
|
421 TUint32 srcColor = *(TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
422 *dst = srcColor; |
|
423 } |
|
424 ++dst; |
|
425 u+=dudx; |
|
426 v+=dvdx; |
|
427 } |
|
428 u0+=dudy; |
|
429 v0+=dvdy; |
|
430 dstAddress += dstLinePitch; |
|
431 } |
|
432 } |
|
433 |
|
434 LOCAL_C void DrawImageColor16MUMaskToColor16MU |
|
435 ( |
|
436 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
437 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
438 const TRect& aDstRect, // must be clipped to destination |
|
439 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
440 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // mask |
|
441 const TLcdTransform& aTransform // includes anchor |
|
442 ) |
|
443 { |
|
444 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
445 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
446 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray2); |
|
447 |
|
448 ASSERT(aTransform.iDuDx == 1); |
|
449 ASSERT(aTransform.iDuDy == 0); |
|
450 ASSERT(aTransform.iDvDx == 0); |
|
451 ASSERT(aTransform.iDvDy == 1); |
|
452 |
|
453 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
454 |
|
455 ASSERT(srcPoint.iX == (aDstRect.iTl.iX + aTransform.iU0)); |
|
456 ASSERT(srcPoint.iY == (aDstRect.iTl.iY + aTransform.iV0)); |
|
457 |
|
458 TInt u0 = srcPoint.iX; |
|
459 TInt v0 = srcPoint.iY; |
|
460 TInt u = u0; |
|
461 TInt v = v0; |
|
462 TInt mu; // mask u coord |
|
463 TInt m = 0; // mask byte |
|
464 |
|
465 const TInt width = aDstRect.Width(); |
|
466 |
|
467 const TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
468 const TInt mskLinePitch = aSrcAlphaBitmap->iLinePitch; |
|
469 const TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
470 |
|
471 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
472 TUint8* mskAddress = aSrcAlphaBitmap->iAddress; // 1 bpp |
|
473 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
474 |
|
475 TInt x = aDstRect.iTl.iX; |
|
476 TInt y = aDstRect.iTl.iY; |
|
477 TInt h = aDstRect.Height(); |
|
478 |
|
479 #ifdef _DEBUG |
|
480 const TSize srcSize = aSrcColorBitmap->iSize; |
|
481 const TUint32* srcStart = (TUint32*)srcAddress; |
|
482 const TUint32* srcLimit = (TUint32*)(srcAddress + (srcSize.iHeight-1)*dstLinePitch + srcSize.iWidth*sizeof(TUint32)); |
|
483 #endif |
|
484 |
|
485 // |
|
486 // Start address of destination pixels. |
|
487 // |
|
488 dstAddress += ((y*dstLinePitch) + (x*sizeof(TUint32))); |
|
489 |
|
490 // |
|
491 // Start address of source pixels |
|
492 // |
|
493 srcAddress += ((v*srcLinePitch) + (u*sizeof(TUint32))); |
|
494 mskAddress += ((v*mskLinePitch) + (u>>3)); |
|
495 |
|
496 for (; h>0; --h) |
|
497 { |
|
498 TUint32* src = (TUint32*)srcAddress; |
|
499 TUint8* msk = mskAddress; |
|
500 TUint32* dst = (TUint32*)dstAddress; |
|
501 TUint32* end = dst + width; |
|
502 u=u0; |
|
503 mu=-1; |
|
504 while (dst < end) |
|
505 { |
|
506 #ifdef _DEBUG |
|
507 ASSERT((srcStart <= src) && (src <= srcLimit)); |
|
508 #endif |
|
509 if (mu != (u>>3)) |
|
510 { |
|
511 mu = (u>>3); |
|
512 m = *msk++; |
|
513 } |
|
514 if (m & (1<<(u&0x7))) |
|
515 { |
|
516 *dst = *src; |
|
517 } |
|
518 ++src; |
|
519 ++dst; |
|
520 ++u; |
|
521 } |
|
522 dstAddress += dstLinePitch; |
|
523 srcAddress += srcLinePitch; |
|
524 mskAddress += mskLinePitch; |
|
525 } |
|
526 } |
|
527 #endif |
|
528 |
|
529 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
530 LOCAL_C void BlitLineColor16MUColor16MUToColor16MU |
|
531 ( |
|
532 TUint8* aDstAddress, |
|
533 TInt aWidth, |
|
534 TUint8* aColorAddress, |
|
535 TInt aColorPixelPitch, |
|
536 TUint8* aMaskAddress, |
|
537 TInt aMaskPixelPitch |
|
538 ) |
|
539 { |
|
540 TUint32* dst = (TUint32*)(aDstAddress); |
|
541 TUint32* end = dst + aWidth; |
|
542 |
|
543 TUint8* colorAddr = aColorAddress; |
|
544 TUint8* maskAddr = aMaskAddress; |
|
545 |
|
546 while (dst < end) |
|
547 { |
|
548 TUint32 dstColor = *dst; |
|
549 TUint32 srcColor = *(TUint32*)colorAddr; |
|
550 TUint32 srcMask = *(TUint32*)maskAddr; |
|
551 |
|
552 dstColor = (dstColor & ~srcMask) | (srcColor & srcMask); |
|
553 |
|
554 *dst++ = dstColor; |
|
555 colorAddr += aColorPixelPitch; |
|
556 maskAddr += aMaskPixelPitch; |
|
557 } |
|
558 } |
|
559 |
|
560 |
|
561 // |
|
562 // |
|
563 // |
|
564 LOCAL_C void DrawRegionColor16MUColor16MUToColor16MU |
|
565 ( |
|
566 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
567 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
568 const TRect& aDstRect, // must be clipped to destination |
|
569 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
570 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // mask |
|
571 const TLcdTransform& aTransform // includes anchor |
|
572 ) |
|
573 { |
|
574 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
575 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
576 ASSERT(aSrcAlphaBitmap->iDisplayMode == EColor16MU); |
|
577 |
|
578 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
579 aSrcAlphaBitmap, ETrue, BlitLineColor16MUColor16MUToColor16MU); |
|
580 } |
|
581 #endif |
|
582 |
|
583 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
584 LOCAL_C void BlitLineColor16MUAlphaToColor16MU |
|
585 ( |
|
586 TUint8* aDstAddress, |
|
587 TInt aWidth, |
|
588 TUint8* aColorAddress, |
|
589 TInt aColorPixelPitch, |
|
590 TUint8* aAlphaAddress, |
|
591 TInt aAlphaPixelPitch |
|
592 ) |
|
593 { |
|
594 TUint32* dst = (TUint32*)(aDstAddress); |
|
595 TUint32* end = dst + aWidth; |
|
596 |
|
597 TUint8* colorAddr = aColorAddress; |
|
598 TUint8* alphaAddr = aAlphaAddress; |
|
599 |
|
600 while (dst < end) |
|
601 { |
|
602 TUint alpha = *alphaAddr; |
|
603 if (alpha == 0xFF) |
|
604 { |
|
605 *dst = *(TUint32*)colorAddr; |
|
606 } |
|
607 else |
|
608 { |
|
609 if (alpha) |
|
610 { |
|
611 TUint32 dstColor = *dst; |
|
612 TUint32 srcColor = *(TUint32*)colorAddr; |
|
613 |
|
614 alpha = (alpha << 8) | alpha; |
|
615 |
|
616 TUint32 dr = Blend32(alpha, Color16MURed(srcColor), Color16MURed(dstColor)); |
|
617 TUint32 dg = Blend32(alpha, Color16MUGreen(srcColor), Color16MUGreen(dstColor)); |
|
618 TUint32 db = Blend32(alpha, Color16MUBlue(srcColor), Color16MUBlue(dstColor)); |
|
619 |
|
620 ASSERT(dr < 256); |
|
621 ASSERT(dg < 256); |
|
622 ASSERT(db < 256); |
|
623 |
|
624 // map back to Color16MU |
|
625 *dst = Color16MU(dr, dg, db); |
|
626 } |
|
627 } |
|
628 |
|
629 // Advance to next pixel in the line in each bitmap. |
|
630 dst++; |
|
631 colorAddr += aColorPixelPitch; |
|
632 alphaAddr += aAlphaPixelPitch; |
|
633 } |
|
634 } |
|
635 |
|
636 // |
|
637 // |
|
638 // |
|
639 LOCAL_C void DrawRegionColor16MUAlphaToColor16MU |
|
640 ( |
|
641 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
642 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
643 const TRect& aDstRect, // must be clipped to destination |
|
644 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
645 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // alpha |
|
646 const TLcdTransform& aTransform // includes anchor |
|
647 ) |
|
648 { |
|
649 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
650 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
651 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
652 |
|
653 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
654 aSrcAlphaBitmap, ETrue, BlitLineColor16MUAlphaToColor16MU); |
|
655 } |
|
656 #endif |
|
657 |
|
658 |
|
659 LOCAL_C void BlitLineARGB8888AlphaChannelToColor16MU |
|
660 ( |
|
661 TUint8* aDstAddress, |
|
662 TInt aWidth, |
|
663 TUint8* aColorAddress, |
|
664 TInt aColorPixelPitch |
|
665 ) |
|
666 { |
|
667 TUint32* dst = (TUint32*)(aDstAddress); |
|
668 TUint32* end = dst + aWidth; |
|
669 |
|
670 TUint8* colorAddr = aColorAddress; |
|
671 |
|
672 while (dst < end) |
|
673 { |
|
674 TUint32 argb = *(TUint32*)colorAddr; |
|
675 TUint32 alpha = argb >> 24; |
|
676 |
|
677 if (alpha == 0xFF) |
|
678 { |
|
679 *dst = ARGB8888ToColor16MU(argb); |
|
680 } |
|
681 else |
|
682 { |
|
683 if (alpha) |
|
684 { |
|
685 TUint32 dstColor = *dst; |
|
686 |
|
687 alpha = (alpha << 8) | alpha; |
|
688 |
|
689 TUint32 dr = Blend32(alpha, Color16MURed(argb), Color16MURed(dstColor)); |
|
690 TUint32 dg = Blend32(alpha, Color16MUGreen(argb), Color16MUGreen(dstColor)); |
|
691 TUint32 db = Blend32(alpha, Color16MUBlue(argb), Color16MUBlue(dstColor)); |
|
692 |
|
693 ASSERT(dr < 256); |
|
694 ASSERT(dg < 256); |
|
695 ASSERT(db < 256); |
|
696 |
|
697 // map back to Color16MU |
|
698 *dst = Color16MU(dr, dg, db); |
|
699 } |
|
700 } |
|
701 |
|
702 // Advance to next pixel in the line in each bitmap. |
|
703 dst++; |
|
704 colorAddr += aColorPixelPitch; |
|
705 } |
|
706 } |
|
707 |
|
708 LOCAL_C void DrawRegionARGB8888AlphaChannelToColor16MU |
|
709 ( |
|
710 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
711 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
712 const TRect& aDstRect, // must be clipped to destination |
|
713 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
714 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // ignored |
|
715 const TLcdTransform& aTransform // includes anchor |
|
716 ) |
|
717 { |
|
718 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
719 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
720 |
|
721 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
722 BlitLineARGB8888AlphaChannelToColor16MU); |
|
723 } |
|
724 |
|
725 |
|
726 // *************************************************************** |
|
727 // BitBlt Functions |
|
728 // *************************************************************** |
|
729 |
|
730 LOCAL_C void BlitLineColor16MUToARGB8888 |
|
731 ( |
|
732 TUint8* aDstAddress, |
|
733 TInt aWidth, |
|
734 TUint8* aColorAddress, |
|
735 TInt aColorPixelPitch |
|
736 ) |
|
737 { |
|
738 TUint32* dst = (TUint32*)(aDstAddress); |
|
739 TUint32* end = dst + aWidth; |
|
740 |
|
741 TUint8* colorAddr = aColorAddress; |
|
742 |
|
743 while (dst < end) |
|
744 { |
|
745 // Force alpha to opaque, because top bits in Java are 'don't care'. |
|
746 *dst++ = *(TUint32*)colorAddr | 0xFF000000; |
|
747 colorAddr += aColorPixelPitch; |
|
748 } |
|
749 } |
|
750 |
|
751 // |
|
752 // Color16MU -> ARGB8888 |
|
753 // |
|
754 LOCAL_C void BitBltColor16MUToARGB8888 |
|
755 ( |
|
756 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
757 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
758 const TRect& aDstRect, |
|
759 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
760 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
761 const TLcdTransform& aTransform |
|
762 ) |
|
763 { |
|
764 ASSERT(aDstColorBitmap); |
|
765 ASSERT(aSrcColorBitmap); |
|
766 |
|
767 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
768 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
769 |
|
770 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
771 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
772 |
|
773 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
774 BlitLineColor16MUToARGB8888); |
|
775 } |
|
776 |
|
777 LOCAL_C void BlitLineARGB8888ToColor16MU |
|
778 ( |
|
779 TUint8* aDstAddress, |
|
780 TInt aWidth, |
|
781 TUint8* aColorAddress, |
|
782 TInt aColorPixelPitch |
|
783 ) |
|
784 { |
|
785 TUint32* dst = (TUint32*)(aDstAddress); |
|
786 TUint32* end = dst + aWidth; |
|
787 |
|
788 TUint8* colorAddr = aColorAddress; |
|
789 |
|
790 while (dst < end) |
|
791 { |
|
792 *dst++ = ARGB8888ToColor16MU(*(TUint32*)colorAddr); |
|
793 colorAddr += aColorPixelPitch; |
|
794 } |
|
795 } |
|
796 |
|
797 LOCAL_C void BitBltARGB8888ToColor16MU |
|
798 ( |
|
799 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
800 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
801 const TRect& aDstRect, |
|
802 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
803 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
804 const TLcdTransform& aTransform |
|
805 ) |
|
806 { |
|
807 ASSERT(aDstColorBitmap); |
|
808 ASSERT(aSrcColorBitmap); |
|
809 |
|
810 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
811 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
812 |
|
813 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
814 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888 || aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
815 |
|
816 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
817 BlitLineARGB8888ToColor16MU); |
|
818 } |
|
819 |
|
820 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
821 // |
|
822 // Color16MU, Gray2 -> ARGB8888 |
|
823 // |
|
824 LOCAL_C void BitBltColor16MUGray2ToARGB8888 |
|
825 ( |
|
826 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
827 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
828 const TRect& aDstRect, |
|
829 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
830 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
831 const TLcdTransform& aTransform |
|
832 ) |
|
833 { |
|
834 ASSERT(aDstColorBitmap); |
|
835 ASSERT(aSrcColorBitmap); |
|
836 ASSERT(aSrcAlphaBitmap); |
|
837 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
838 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
839 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
840 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
841 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
842 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray2); |
|
843 |
|
844 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
845 |
|
846 TInt dudx = aTransform.iDuDx; |
|
847 TInt dudy = aTransform.iDuDy; |
|
848 TInt dvdx = aTransform.iDvDx; |
|
849 TInt dvdy = aTransform.iDvDy; |
|
850 TInt u0 = srcPoint.iX; |
|
851 TInt v0 = srcPoint.iY; |
|
852 TInt u = u0; |
|
853 TInt v = v0; |
|
854 |
|
855 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
856 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
857 TUint8* mskAddress = aSrcAlphaBitmap->iAddress; |
|
858 |
|
859 TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
860 TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
861 TInt mskLinePitch = aSrcAlphaBitmap->iLinePitch; |
|
862 |
|
863 #ifdef _DEBUG |
|
864 const TSize srcSize = aSrcColorBitmap->iSize; |
|
865 const TUint8* srcBeg = srcAddress; |
|
866 const TUint8* srcEnd = srcAddress + srcLinePitch*(srcSize.iHeight - 1) + (srcSize.iWidth-1)*sizeof(TUint32); |
|
867 |
|
868 const TUint8* mskBeg = mskAddress; |
|
869 const TUint8* mskEnd = mskAddress + mskLinePitch*(srcSize.iHeight - 1) + ((srcSize.iWidth-1)>>3); |
|
870 |
|
871 const TSize dstSize = aDstColorBitmap->iSize; |
|
872 const TUint32* dstBeg = (TUint32*)dstAddress; |
|
873 const TUint32* dstEnd = (TUint32*)(dstAddress + dstLinePitch*(dstSize.iHeight - 1) + (dstSize.iWidth-1)*sizeof(TUint32)); |
|
874 #endif |
|
875 |
|
876 dstAddress += dstLinePitch*aDstRect.iTl.iY; |
|
877 dstAddress += aDstRect.iTl.iX*sizeof(TUint32); |
|
878 |
|
879 TInt height = aDstRect.Height(); |
|
880 TInt width = aDstRect.Width(); |
|
881 for (; height>0; --height) |
|
882 { |
|
883 TUint32* dst = (TUint32*)dstAddress; |
|
884 TUint32* end = dst + width; |
|
885 |
|
886 u=u0; |
|
887 v=v0; |
|
888 while (dst < end) |
|
889 { |
|
890 TUint8* src = srcAddress + v*srcLinePitch + u*sizeof(TUint32); |
|
891 TUint8* msk = mskAddress + v*mskLinePitch + (u>>3); |
|
892 |
|
893 #ifdef _DEBUG |
|
894 ASSERT(srcBeg <= src && src <= srcEnd); |
|
895 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
896 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
897 #endif |
|
898 |
|
899 TUint8 smsk = *msk; |
|
900 |
|
901 TUint32 dpix = *(TUint32*)src; |
|
902 if (smsk & 1<<(u&0x7)) |
|
903 { |
|
904 dpix |= 0xff000000; |
|
905 } |
|
906 else |
|
907 { |
|
908 dpix &= 0x00ffffff; |
|
909 } |
|
910 |
|
911 *dst++ = dpix; |
|
912 u+=dudx; |
|
913 v+=dvdx; |
|
914 } |
|
915 u0+=dudy; |
|
916 v0+=dvdy; |
|
917 dstAddress += dstLinePitch; |
|
918 } |
|
919 } |
|
920 |
|
921 // |
|
922 // ARGB8888 -> Color16MU, Gray2 |
|
923 // |
|
924 LOCAL_C void BitBltARGB8888ToColor16MUGray2 |
|
925 ( |
|
926 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
927 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
928 const TRect& aDstRect, |
|
929 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
930 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
931 const TLcdTransform& aTransform |
|
932 ) |
|
933 { |
|
934 ASSERT(aDstColorBitmap); |
|
935 ASSERT(aDstAlphaBitmap); |
|
936 ASSERT(aSrcColorBitmap); |
|
937 |
|
938 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
939 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
940 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
941 |
|
942 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
943 ASSERT(aDstAlphaBitmap->iDisplayMode == EGray2); |
|
944 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
945 |
|
946 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
947 |
|
948 TInt dudx = aTransform.iDuDx; |
|
949 TInt dudy = aTransform.iDuDy; |
|
950 TInt dvdx = aTransform.iDvDx; |
|
951 TInt dvdy = aTransform.iDvDy; |
|
952 TInt u0 = srcPoint.iX; |
|
953 TInt v0 = srcPoint.iY; |
|
954 TInt u = u0; |
|
955 TInt v = v0; |
|
956 |
|
957 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
958 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
959 TUint8* mskAddress = aDstAlphaBitmap->iAddress; |
|
960 |
|
961 TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
962 TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
963 TInt mskLinePitch = aDstAlphaBitmap->iLinePitch; |
|
964 |
|
965 #ifdef _DEBUG |
|
966 const TSize srcSize = aSrcColorBitmap->iSize; |
|
967 const TUint32* srcBeg = (TUint32*)srcAddress; |
|
968 const TUint32* srcEnd = (TUint32*)(srcAddress + srcLinePitch*(srcSize.iHeight - 1) + (srcSize.iWidth-1)*sizeof(TUint32)); |
|
969 |
|
970 const TSize dstSize = aDstColorBitmap->iSize; |
|
971 const TUint32* dstBeg = (TUint32*)dstAddress; |
|
972 const TUint32* dstEnd = (TUint32*)(dstAddress + dstLinePitch*(dstSize.iHeight - 1) + (dstSize.iWidth-1)*sizeof(TUint32)); |
|
973 |
|
974 const TSize mskSize = aDstAlphaBitmap->iSize; |
|
975 const TUint8* mskBeg = mskAddress; |
|
976 const TUint8* mskEnd = mskAddress + mskLinePitch*(mskSize.iHeight-1) + ((mskSize.iWidth-1)>>3); |
|
977 #endif |
|
978 |
|
979 |
|
980 dstAddress += dstLinePitch*aDstRect.iTl.iY; |
|
981 dstAddress += aDstRect.iTl.iX*sizeof(TUint32); |
|
982 |
|
983 mskAddress += mskLinePitch*aDstRect.iTl.iY; |
|
984 mskAddress += (aDstRect.iTl.iX>>3); |
|
985 |
|
986 TInt height = aDstRect.Height(); |
|
987 TInt width = aDstRect.Width(); |
|
988 |
|
989 const TInt x0 = aDstRect.iTl.iX; |
|
990 const TInt x1 = Min((aDstRect.iTl.iX | 0x7)+1, aDstRect.iBr.iX); |
|
991 const TInt x2 = (aDstRect.iBr.iX & ~0x7); |
|
992 const TInt x3 = aDstRect.iBr.iX; |
|
993 |
|
994 for (; height>0; --height) |
|
995 { |
|
996 TUint32* dst = (TUint32*)dstAddress; |
|
997 TUint8* msk = mskAddress; |
|
998 |
|
999 #ifdef _DEBUG |
|
1000 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
1001 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
1002 #endif |
|
1003 |
|
1004 TInt x; |
|
1005 |
|
1006 u=u0; |
|
1007 v=v0; |
|
1008 |
|
1009 // |
|
1010 // Leading mask byte |
|
1011 // |
|
1012 for (x = x0; x<x1; x++) |
|
1013 { |
|
1014 TUint32* src = (TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
1015 |
|
1016 #ifdef _DEBUG |
|
1017 ASSERT(srcBeg <= src && src <= srcEnd); |
|
1018 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
1019 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
1020 #endif |
|
1021 |
|
1022 TUint32 pixel = *src; |
|
1023 TUint8 alpha = pixel>>24; |
|
1024 |
|
1025 TInt xBit = (1<<(x&0x7)); |
|
1026 if (alpha == 0xff) |
|
1027 { |
|
1028 *msk |= xBit; |
|
1029 } |
|
1030 else |
|
1031 { |
|
1032 *msk &= ~xBit; |
|
1033 } |
|
1034 |
|
1035 *dst++ = ARGB8888ToColor16MU(pixel); |
|
1036 u+=dudx; |
|
1037 v+=dvdx; |
|
1038 } |
|
1039 ++msk; |
|
1040 |
|
1041 // |
|
1042 // Middle section |
|
1043 // |
|
1044 for (ASSERT(x==x1); x<x2; x+=8) |
|
1045 { |
|
1046 TUint8 mask = 0; |
|
1047 |
|
1048 TUint32* end = dst + 8; |
|
1049 TInt mbit = 1; |
|
1050 while (dst < end) |
|
1051 { |
|
1052 TUint32* src = (TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
1053 |
|
1054 #ifdef _DEBUG |
|
1055 ASSERT(srcBeg <= src && src <= srcEnd); |
|
1056 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
1057 #endif |
|
1058 |
|
1059 TUint32 pixel = *src; |
|
1060 if ((pixel >> 24)==0xff) |
|
1061 { |
|
1062 mask |= mbit; |
|
1063 } |
|
1064 *dst++ = ARGB8888ToColor16MU(pixel); |
|
1065 mbit <<= 1; |
|
1066 u+=dudx; |
|
1067 v+=dvdx; |
|
1068 } |
|
1069 |
|
1070 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
1071 |
|
1072 *msk++ = mask; |
|
1073 } |
|
1074 |
|
1075 // |
|
1076 // Trailing mask byte |
|
1077 // |
|
1078 for (ASSERT((x>=x2)&&(x<=x3)); x<x3; x++) |
|
1079 { |
|
1080 TUint32* src = (TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
1081 |
|
1082 #ifdef _DEBUG |
|
1083 ASSERT(srcBeg <= src && src <= srcEnd); |
|
1084 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
1085 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
1086 #endif |
|
1087 |
|
1088 TUint32 pixel = *src; |
|
1089 TUint8 alpha = pixel>>24; |
|
1090 |
|
1091 TInt xBit = (1<<(x&0x7)); |
|
1092 if (alpha == 0xff) |
|
1093 { |
|
1094 *msk |= xBit; |
|
1095 } |
|
1096 else |
|
1097 { |
|
1098 *msk &= ~xBit; |
|
1099 } |
|
1100 |
|
1101 *dst++ = ARGB8888ToColor16MU(pixel); |
|
1102 u+=dudx; |
|
1103 v+=dvdx; |
|
1104 } |
|
1105 |
|
1106 u0+=dudy; |
|
1107 v0+=dvdy; |
|
1108 dstAddress += dstLinePitch; |
|
1109 mskAddress += mskLinePitch; |
|
1110 } |
|
1111 } |
|
1112 #endif |
|
1113 |
|
1114 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
1115 LOCAL_C void BlitLineColor16MUColor16MUToARGB8888 |
|
1116 ( |
|
1117 TUint8* aDstAddress, |
|
1118 TInt aWidth, |
|
1119 TUint8* aColorAddress, |
|
1120 TInt aColorPixelPitch, |
|
1121 TUint8* aMaskAddress, |
|
1122 TInt aMaskPixelPitch |
|
1123 ) |
|
1124 { |
|
1125 TUint32* dst = (TUint32*)(aDstAddress); |
|
1126 TUint32* end = dst + aWidth; |
|
1127 |
|
1128 TUint8* colorAddr = aColorAddress; |
|
1129 TUint8* maskAddr = aMaskAddress; |
|
1130 |
|
1131 while (dst < end) |
|
1132 { |
|
1133 TUint32 srcColor = *(TUint32*)colorAddr; |
|
1134 TUint32 srcMask = *(TUint32*)maskAddr; |
|
1135 |
|
1136 ASSERT((srcMask == 0) || (srcMask == 0xffffff)); |
|
1137 |
|
1138 *dst++ = (srcMask << 24) | (srcColor & 0xffffff); |
|
1139 colorAddr += aColorPixelPitch; |
|
1140 maskAddr += aMaskPixelPitch; |
|
1141 } |
|
1142 } |
|
1143 |
|
1144 |
|
1145 // |
|
1146 // Color16MU, Color16MU -> ARGB8888 |
|
1147 // |
|
1148 LOCAL_C void BitBltColor16MUColor16MUToARGB8888 |
|
1149 ( |
|
1150 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
1151 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
1152 const TRect& aDstRect, |
|
1153 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1154 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
1155 const TLcdTransform& aTransform |
|
1156 ) |
|
1157 { |
|
1158 ASSERT(aDstColorBitmap); |
|
1159 ASSERT(aSrcColorBitmap); |
|
1160 ASSERT(aSrcAlphaBitmap); |
|
1161 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1162 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1163 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
1164 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
1165 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
1166 ASSERT(aSrcAlphaBitmap->iDisplayMode == EColor16MU); |
|
1167 |
|
1168 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1169 aSrcAlphaBitmap, ETrue, BlitLineColor16MUColor16MUToARGB8888); |
|
1170 } |
|
1171 |
|
1172 LOCAL_C void BlitLineARGB8888ToColor16MUColor16MU |
|
1173 ( |
|
1174 TUint8* aDstAddress, |
|
1175 TInt aWidth, |
|
1176 TUint8* aColorAddress, |
|
1177 TInt aColorPixelPitch, |
|
1178 TUint8* aMaskAddress, |
|
1179 TInt aMaskPixelPitch |
|
1180 ) |
|
1181 { |
|
1182 TUint32* dst = (TUint32*)(aDstAddress); |
|
1183 TUint32* end = dst + aWidth; |
|
1184 |
|
1185 TUint8* colorAddr = aColorAddress; |
|
1186 TUint32* maskAddr = aMaskAddress; |
|
1187 |
|
1188 while (dst < end) |
|
1189 { |
|
1190 TUint32 srcColor = *(TUint32*)colorAddr; |
|
1191 |
|
1192 *dst++ = ARGB8888ToColor16MU(srcColor); |
|
1193 *maskAddr++ = ((srcColor >> 24) == 0xff) ? 0xffffff : 0; |
|
1194 |
|
1195 colorAddr += aColorPixelPitch; |
|
1196 } |
|
1197 } |
|
1198 |
|
1199 |
|
1200 // |
|
1201 // ARGB8888 -> Color16MUColor16MU |
|
1202 // |
|
1203 LOCAL_C void BitBltARGB8888ToColor16MUColor16MU |
|
1204 ( |
|
1205 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
1206 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
1207 const TRect& aDstRect, |
|
1208 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1209 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
1210 const TLcdTransform& aTransform |
|
1211 ) |
|
1212 { |
|
1213 ASSERT(aDstColorBitmap); |
|
1214 ASSERT(aDstAlphaBitmap); |
|
1215 ASSERT(aSrcColorBitmap); |
|
1216 |
|
1217 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1218 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
1219 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1220 |
|
1221 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
1222 ASSERT(aDstAlphaBitmap->iDisplayMode == EColor16MU); |
|
1223 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
1224 |
|
1225 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1226 aDstAlphaBitmap, EFalse, BlitLineARGB8888ToColor16MUColor16MU); |
|
1227 } |
|
1228 #endif |
|
1229 |
|
1230 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
1231 LOCAL_C void BlitLineColor16MUGray256ToARGB8888 |
|
1232 ( |
|
1233 TUint8* aDstAddress, |
|
1234 TInt aWidth, |
|
1235 TUint8* aColorAddress, |
|
1236 TInt aColorPixelPitch, |
|
1237 TUint8* aMaskAddress, |
|
1238 TInt aMaskPixelPitch |
|
1239 ) |
|
1240 { |
|
1241 TUint32* dst = (TUint32*)(aDstAddress); |
|
1242 TUint32* end = dst + aWidth; |
|
1243 |
|
1244 TUint8* colorAddr = aColorAddress; |
|
1245 TUint8* maskAddr = aMaskAddress; |
|
1246 |
|
1247 while (dst < end) |
|
1248 { |
|
1249 TUint32 srcColor = *(TUint32*)colorAddr; |
|
1250 |
|
1251 *dst++ = (*maskAddr << 24) | (srcColor & 0xffffff); |
|
1252 |
|
1253 colorAddr += aColorPixelPitch; |
|
1254 maskAddr += aMaskPixelPitch; |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 |
|
1259 // |
|
1260 // Color16MU, Gray256 -> ARGB8888 |
|
1261 // |
|
1262 LOCAL_C void BitBltColor16MUGray256ToARGB8888 |
|
1263 ( |
|
1264 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
1265 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
1266 const TRect& aDstRect, |
|
1267 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1268 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
1269 const TLcdTransform& aTransform |
|
1270 ) |
|
1271 { |
|
1272 ASSERT(aDstColorBitmap); |
|
1273 ASSERT(aSrcColorBitmap); |
|
1274 ASSERT(aSrcAlphaBitmap); |
|
1275 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1276 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1277 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
1278 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
1279 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MU); |
|
1280 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
1281 |
|
1282 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1283 aSrcAlphaBitmap, ETrue, BlitLineColor16MUGray256ToARGB8888); |
|
1284 } |
|
1285 |
|
1286 LOCAL_C void BlitLineARGB8888ToColor16MUGray256 |
|
1287 ( |
|
1288 TUint8* aDstAddress, |
|
1289 TInt aWidth, |
|
1290 TUint8* aColorAddress, |
|
1291 TInt aColorPixelPitch, |
|
1292 TUint8* aMaskAddress, |
|
1293 TInt aMaskPixelPitch |
|
1294 ) |
|
1295 { |
|
1296 TUint32* dst = (TUint32*)(aDstAddress); |
|
1297 TUint32* end = dst + aWidth; |
|
1298 |
|
1299 TUint8* colorAddr = aColorAddress; |
|
1300 TUint8* maskAddr = aMaskAddress; |
|
1301 |
|
1302 ASSERT(aMaskPixelPitch == sizeof(TUint8)); |
|
1303 UNUSED(aMaskPixelPitch); // ASSERT is the only use otherwise. |
|
1304 |
|
1305 while (dst < end) |
|
1306 { |
|
1307 TUint32 srcColor = *(TUint32*)colorAddr; |
|
1308 |
|
1309 *dst++ = ARGB8888ToColor16MU(srcColor); |
|
1310 *maskAddr++ = (srcColor >> 24); |
|
1311 |
|
1312 colorAddr += aColorPixelPitch; |
|
1313 } |
|
1314 } |
|
1315 |
|
1316 |
|
1317 // |
|
1318 // ARGB8888 -> Color16MU, Gray256 |
|
1319 // |
|
1320 LOCAL_C void BitBltARGB8888ToColor16MUGray256 |
|
1321 ( |
|
1322 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
1323 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
1324 const TRect& aDstRect, |
|
1325 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1326 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
1327 const TLcdTransform& aTransform |
|
1328 ) |
|
1329 { |
|
1330 ASSERT(aDstColorBitmap); |
|
1331 ASSERT(aDstAlphaBitmap); |
|
1332 ASSERT(aSrcColorBitmap); |
|
1333 |
|
1334 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1335 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
1336 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1337 |
|
1338 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MU); |
|
1339 ASSERT(aDstAlphaBitmap->iDisplayMode == EGray256); |
|
1340 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
1341 |
|
1342 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1343 aDstAlphaBitmap, EFalse, BlitLineARGB8888ToColor16MUGray256); |
|
1344 } |
|
1345 |
|
1346 #endif |