|
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 inline TUint32 ARGB8888ToColor16MA(TUint32 aARGB) |
|
30 { |
|
31 return aARGB; |
|
32 } |
|
33 |
|
34 inline TUint32 Color16MA(TInt aRed, TInt aGreen, TInt aBlue) |
|
35 { |
|
36 return TUint32((0xff<<24) | (aRed << 16) | (aGreen << 8) | aBlue); |
|
37 } |
|
38 |
|
39 LOCAL_C TUint32 Color16MAForward(TUint32 aRGB) |
|
40 { |
|
41 return ARGB8888ToColor16MA(aRGB); |
|
42 } |
|
43 |
|
44 LOCAL_C TUint32 Color16MAReverse(TUint32 aColor16MA) |
|
45 { |
|
46 return aColor16MA; |
|
47 } |
|
48 |
|
49 LOCAL_C TUint32 Color16MAQuantize(TUint32 aRGB) |
|
50 { |
|
51 return (aRGB & 0x00FFFFFF); // must ensure we only return RGB. |
|
52 } |
|
53 |
|
54 |
|
55 // |
|
56 // DrawRegion support |
|
57 // |
|
58 LOCAL_C void DrawRegionColor16MAMaskToColor16MAOpaque |
|
59 ( |
|
60 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
61 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
62 const TRect& aDstRect, // must be clipped to destination |
|
63 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
64 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
65 const TLcdTransform& aTransform // includes anchor |
|
66 ); |
|
67 |
|
68 |
|
69 LOCAL_C void DrawRegionColor16MAAlphaToColor16MAOpaque |
|
70 ( |
|
71 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
72 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
73 const TRect& aDstRect, // must be clipped to destination |
|
74 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
75 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
76 const TLcdTransform& aTransform // includes anchor |
|
77 ); |
|
78 |
|
79 |
|
80 // |
|
81 // BitBlt support |
|
82 // |
|
83 LOCAL_C void BitBltJavaOpaqueToColor16MAOpaque |
|
84 ( |
|
85 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
86 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
87 const TRect& aDstRect, |
|
88 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
89 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
90 const TLcdTransform& aTransform |
|
91 ); |
|
92 |
|
93 |
|
94 LOCAL_C void BitBltColor16MAAlphaToColor16MAMask |
|
95 ( |
|
96 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
97 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
98 const TRect& aDstRect, |
|
99 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
100 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
101 const TLcdTransform& aTransform |
|
102 ); |
|
103 |
|
104 |
|
105 #ifdef RD_JAVA_NGA_ENABLED |
|
106 /** |
|
107 * |
|
108 */ |
|
109 LOCAL_C void DrawRegionColor16MAMaskToColor16MAPre |
|
110 ( |
|
111 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
112 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
113 const TRect& aDstRect, // must be clipped to destination |
|
114 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
115 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
116 const TLcdTransform& aTransform // includes anchor |
|
117 ); |
|
118 |
|
119 /** |
|
120 * |
|
121 */ |
|
122 LOCAL_C void DrawRegionColor16MAAlphaToColor16MAPre |
|
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 #endif // RD_JAVA_NGA_ENABLED |
|
133 |
|
134 |
|
135 TBool DetectCollisionColor16MAColor16MA |
|
136 ( |
|
137 const TAcceleratedBitmapInfo* aBitmap1, |
|
138 const TAcceleratedBitmapInfo* aBitmap2, |
|
139 const TRect& aRect1, |
|
140 const TRect& aRect2, |
|
141 const TLcdTransform& aTransform1, |
|
142 const TLcdTransform& aTransform2 |
|
143 ); |
|
144 |
|
145 TBool HasOpaquePixelColor16MA(const TAcceleratedBitmapInfo* aBitmap, const TRect& aRect); |
|
146 |
|
147 // |
|
148 // Image types supported by this DLL. |
|
149 // |
|
150 #define COLOR16MA_OPAQUE IMAGE_TYPE(EColor16MA, ENone, ETransparencyNone) |
|
151 #define COLOR16MA_MASK IMAGE_TYPE(EColor16MA, ENone, ETransparencyMaskChannel) |
|
152 #define COLOR16MA_ALPHA IMAGE_TYPE(EColor16MA, ENone, ETransparencyAlphaChannel) |
|
153 |
|
154 #ifdef RD_JAVA_NGA_ENABLED |
|
155 #define COLOR16MA_ALPHA_PRE IMAGE_TYPE(EColor16MA, ENone, ETransparencyAlphaChannelPre) |
|
156 #define COLOR16MA_MASK_PRE IMAGE_TYPE(EColor16MA, ENone, ETransparencyMaskChannelPre) |
|
157 #endif // RD_JAVA_NGA_ENABLED |
|
158 |
|
159 const TImageRenderer ImageRendererArray[] = |
|
160 { |
|
161 // |
|
162 // SrcOver |
|
163 // |
|
164 /* target, source, transform mask, function */ |
|
165 RENDER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_OPAQUE, KTransSimpleMask, BitBltThirtyTwoBppSimple), |
|
166 RENDER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_OPAQUE, KTransAllMask, BitBltThirtyTwoBpp), |
|
167 RENDER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_MASK, KTransAllMask, DrawRegionColor16MAMaskToColor16MAOpaque), |
|
168 RENDER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_ALPHA, KTransAllMask, DrawRegionColor16MAAlphaToColor16MAOpaque), |
|
169 RENDER_ENTRY(COLOR16MA_OPAQUE, JAVA_OPAQUE_IMAGE, KTransAllMask, BitBltJavaOpaqueToColor16MAOpaque), |
|
170 RENDER_ENTRY(COLOR16MA_OPAQUE, JAVA_ALPHA_IMAGE, KTransAllMask, DrawRegionColor16MAAlphaToColor16MAOpaque), |
|
171 |
|
172 #ifdef RD_JAVA_NGA_ENABLED |
|
173 RENDER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_MASK_PRE, KTransAllMask, DrawRegionColor16MAMaskToColor16MAPre), |
|
174 RENDER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_ALPHA_PRE, KTransAllMask, DrawRegionColor16MAAlphaToColor16MAPre), |
|
175 #endif // RD_JAVA_NGA_ENABLED |
|
176 |
|
177 // |
|
178 // SrcCopy |
|
179 // |
|
180 /* target, source, function */ |
|
181 BLITTER_ENTRY(COLOR16MA_OPAQUE, JAVA_OPAQUE_IMAGE, BitBltJavaOpaqueToColor16MAOpaque), |
|
182 SIMPLE_BLITTER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_OPAQUE, BitBltThirtyTwoBppSimple), |
|
183 BLITTER_ENTRY(COLOR16MA_OPAQUE, COLOR16MA_OPAQUE, BitBltThirtyTwoBpp), |
|
184 SIMPLE_BLITTER_ENTRY(JAVA_OPAQUE_IMAGE, COLOR16MA_OPAQUE, BitBltThirtyTwoBppSimple), |
|
185 BLITTER_ENTRY(JAVA_OPAQUE_IMAGE, COLOR16MA_OPAQUE, BitBltThirtyTwoBpp), |
|
186 BLITTER_ENTRY(COLOR16MA_OPAQUE, JAVA_ALPHA_IMAGE, BitBltJavaOpaqueToColor16MAOpaque), // entry shouldn't be needed |
|
187 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MA_OPAQUE, BitBltThirtyTwoBpp), |
|
188 // |
|
189 BLITTER_ENTRY(COLOR16MA_MASK, JAVA_ALPHA_IMAGE, BitBltColor16MAAlphaToColor16MAMask), |
|
190 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MA_MASK, BitBltThirtyTwoBpp), // mask(0,255)==alpha |
|
191 BLITTER_ENTRY(COLOR16MA_MASK, COLOR16MA_MASK, BitBltThirtyTwoBpp), |
|
192 // |
|
193 BLITTER_ENTRY(COLOR16MA_ALPHA, JAVA_ALPHA_IMAGE, BitBltThirtyTwoBpp), |
|
194 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR16MA_ALPHA, BitBltThirtyTwoBpp) |
|
195 }; |
|
196 const TInt ImageRendererCount = sizeof(ImageRendererArray)/sizeof(ImageRendererArray[0]); |
|
197 |
|
198 const TCollisionDetector CollisionDetectorArray[] = |
|
199 { |
|
200 COLLISION_DETECTOR_ENTRY(EColor16MABit,ETransparencyMaskChannelBit, EColor16MABit,ETransparencyMaskChannelBit, DetectCollisionColor16MAColor16MA), |
|
201 COLLISION_DETECTOR_ENTRY(EColor16MABit,ETransparencyAlphaChannelBit, EColor16MABit,ETransparencyAlphaChannelBit, DetectCollisionColor16MAColor16MA), |
|
202 COLLISION_DETECTOR_ENTRY(EColor16MABit,ETransparencyMaskChannelBit, EColor16MABit,ETransparencyAlphaChannelBit, DetectCollisionColor16MAColor16MA), |
|
203 COLLISION_DETECTOR_ENTRY(EColor16MABit,ETransparencyAlphaChannelBit, EColor16MABit,ETransparencyMaskChannelBit, DetectCollisionColor16MAColor16MA), |
|
204 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EColor16MABit,ETransparencyMaskChannelBit, DetectCollisionColor16MAColor16MA), |
|
205 COLLISION_DETECTOR_ENTRY(EColor16MABit,ETransparencyMaskChannelBit, ENoneBit,ETransparencyNoneBit, DetectCollisionColor16MAColor16MA), |
|
206 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EColor16MABit,ETransparencyAlphaChannelBit, DetectCollisionColor16MAColor16MA), |
|
207 COLLISION_DETECTOR_ENTRY(EColor16MABit,ETransparencyAlphaChannelBit, ENoneBit,ETransparencyNoneBit, DetectCollisionColor16MAColor16MA) |
|
208 }; |
|
209 const TInt CollisionDetectorCount = sizeof(CollisionDetectorArray)/sizeof(CollisionDetectorArray[0]); |
|
210 |
|
211 const TColorMap ColorMapArray[] = |
|
212 { |
|
213 { EColor16MA, Color16MAForward, Color16MAReverse, Color16MAQuantize } |
|
214 }; |
|
215 const TInt ColorMapCount = sizeof(ColorMapArray)/sizeof(ColorMapArray[0]); |
|
216 |
|
217 const TDrawFunctions DrawFunctionsArray[] = |
|
218 { |
|
219 { |
|
220 EColor16MA, |
|
221 CLcdGraphicsDevice::ECapFillTriangle, |
|
222 NULL, // drawLine |
|
223 NULL, // drawRect |
|
224 NULL, // fillRect |
|
225 NULL, // drawArc |
|
226 NULL, // fillArc |
|
227 &FillTriangle32Bpp, |
|
228 NULL // drawText |
|
229 } |
|
230 }; |
|
231 const TInt DrawFunctionsCount = sizeof(DrawFunctionsArray)/sizeof(DrawFunctionsArray[0]); |
|
232 |
|
233 const TInt KVersionBuild = 0; |
|
234 |
|
235 _LIT(KProviderSymbianSoftwareLtd, "Symbian Software Ltd"); |
|
236 |
|
237 LOCAL_C CLcdGraphicsDriverImpl* CreateColor16MADriverL(); |
|
238 |
|
239 const TImplementationProxy ImplementationTable[] = |
|
240 { |
|
241 IMPLEMENTATION_PROXY_ENTRY(LCDGD_COLOR16MA_IMPLEMENTATION_UID, CreateColor16MADriverL) |
|
242 }; |
|
243 |
|
244 /** |
|
245 * Ordinal 1 |
|
246 */ |
|
247 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
248 { |
|
249 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
250 return ImplementationTable; |
|
251 } |
|
252 |
|
253 CLcdGraphicsDriverImpl* CreateColor16MADriverL() |
|
254 { |
|
255 CLcdGraphicsDriver::TDriverInfo driverInfo; |
|
256 |
|
257 driverInfo.iVersion = TVersion(KLcdImgVersionMajor, KLcdImgVersionMinor, KVersionBuild); |
|
258 driverInfo.iProvider = KProviderSymbianSoftwareLtd; |
|
259 driverInfo.iTransparencyCaps = CAP_1BPP_MASK_BITMAP|CAP_MATCHED_MASK_BITMAP|CAP_ALPHA_BITMAP; |
|
260 driverInfo.iARGB8888Mode = EColorARGB8888; |
|
261 driverInfo.iDisplayMode = EColor16MA; |
|
262 |
|
263 return new(ELeave) CLcdGraphicsDriverImpl |
|
264 ( |
|
265 driverInfo, |
|
266 ImageRendererArray, |
|
267 ImageRendererCount, |
|
268 ColorMapArray, |
|
269 ColorMapCount, |
|
270 CollisionDetectorArray, |
|
271 CollisionDetectorCount, |
|
272 DrawFunctionsArray, |
|
273 DrawFunctionsCount |
|
274 ); |
|
275 } |
|
276 |
|
277 // *************************************************************** |
|
278 // Render Functions |
|
279 // *************************************************************** |
|
280 |
|
281 LOCAL_C void BlitLineColor16MAMaskToColor16MAOpaque |
|
282 ( |
|
283 TUint8* aDstAddress, |
|
284 TInt aWidth, |
|
285 TUint8* aColorAddress, |
|
286 TInt aColorPixelPitch |
|
287 ) |
|
288 { |
|
289 TUint32* dst = (TUint32*)(aDstAddress); |
|
290 TUint32* end = dst + aWidth; |
|
291 |
|
292 TUint8* colorAddr = aColorAddress; |
|
293 |
|
294 while (dst < end) |
|
295 { |
|
296 TUint32 dstColor = *dst; |
|
297 TUint32 srcColor = *(TUint32*)colorAddr; |
|
298 |
|
299 TUint32 mask = (TUint32)(((TInt32)srcColor) >> 24); // Sign extend down. |
|
300 ASSERT(mask == 0 || mask == (TUint32)-1); |
|
301 |
|
302 dstColor = (dstColor & ~mask) | (srcColor & mask); |
|
303 ASSERT((dstColor >> 24) == 0xff); |
|
304 |
|
305 *dst++ = dstColor; |
|
306 colorAddr += aColorPixelPitch; |
|
307 } |
|
308 } |
|
309 |
|
310 |
|
311 LOCAL_C void DrawRegionColor16MAMaskToColor16MAOpaque |
|
312 ( |
|
313 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
314 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
315 const TRect& aDstRect, // must be clipped to destination |
|
316 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
317 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // mask |
|
318 const TLcdTransform& aTransform // includes anchor |
|
319 ) |
|
320 { |
|
321 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MA); |
|
322 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MA); |
|
323 |
|
324 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
325 BlitLineColor16MAMaskToColor16MAOpaque); |
|
326 } |
|
327 |
|
328 |
|
329 LOCAL_C void BlitLineColor16MAAlphaToColor16MAOpaque |
|
330 ( |
|
331 TUint8* aDstAddress, |
|
332 TInt aWidth, |
|
333 TUint8* aColorAddress, |
|
334 TInt aColorPixelPitch |
|
335 ) |
|
336 { |
|
337 TUint32* dst = (TUint32*)(aDstAddress); |
|
338 TUint32* end = dst + aWidth; |
|
339 |
|
340 TUint8* colorAddr = aColorAddress; |
|
341 |
|
342 while (dst < end) |
|
343 { |
|
344 TUint32 argb = *(TUint32*)colorAddr; |
|
345 TInt alpha = argb >> 24; |
|
346 if (alpha == 0xFF) |
|
347 { |
|
348 *dst = argb; |
|
349 } |
|
350 else |
|
351 { |
|
352 if (alpha) |
|
353 { |
|
354 // |
|
355 // alpha blend src over dst. |
|
356 // |
|
357 TUint32 drgb= *dst; |
|
358 |
|
359 alpha = (alpha << 8) | alpha; |
|
360 |
|
361 TUint32 dr = Blend32(alpha, ((argb>>16)&0xff), ((drgb>>16)&0xff)); |
|
362 TUint32 dg = Blend32(alpha, ((argb>>8)&0xff), ((drgb>>8)&0xff)); |
|
363 TUint32 db = Blend32(alpha, (argb&0xff), (drgb&0xff)); |
|
364 |
|
365 ASSERT(dr < 256); |
|
366 ASSERT(dg < 256); |
|
367 ASSERT(db < 256); |
|
368 |
|
369 *dst = Color16MA(dr, dg, db); |
|
370 } |
|
371 } |
|
372 |
|
373 dst++; |
|
374 colorAddr += aColorPixelPitch; |
|
375 } |
|
376 } |
|
377 |
|
378 // |
|
379 // NB destination is fully opaque. |
|
380 // |
|
381 LOCAL_C void DrawRegionColor16MAAlphaToColor16MAOpaque |
|
382 ( |
|
383 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
384 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
385 const TRect& aDstRect, // must be clipped to destination |
|
386 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
387 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // ignored |
|
388 const TLcdTransform& aTransform // includes anchor |
|
389 ) |
|
390 { |
|
391 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MA); |
|
392 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
393 |
|
394 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
395 BlitLineColor16MAAlphaToColor16MAOpaque); |
|
396 } |
|
397 |
|
398 |
|
399 #ifdef RD_JAVA_NGA_ENABLED |
|
400 // --------------------------------------------------------------------------- |
|
401 // BlitLineColor16MAMaskToColor16MAPre |
|
402 // Target's color components are premultiplied |
|
403 // --------------------------------------------------------------------------- |
|
404 // |
|
405 LOCAL_C void BlitLineColor16MAMaskToColor16MAPre |
|
406 ( |
|
407 TUint8* aDstAddress, |
|
408 TInt aWidth, |
|
409 TUint8* aColorAddress, |
|
410 TInt aColorPixelPitch |
|
411 ) |
|
412 { |
|
413 TUint32* dst = (TUint32*)(aDstAddress); |
|
414 TUint32* end = dst + aWidth; |
|
415 |
|
416 TUint8* colorAddr = aColorAddress; |
|
417 |
|
418 while (dst < end) |
|
419 { |
|
420 TUint32 dstColor = *dst; |
|
421 TUint32 srcColor = *(TUint32*)colorAddr; |
|
422 |
|
423 TUint32 mask = (TUint32)(((TInt32)srcColor) >> 24); // Sign extend down. |
|
424 ASSERT(mask == 0 || mask == (TUint32)-1); |
|
425 |
|
426 if (mask) |
|
427 { |
|
428 // Note that the target is not always opaque anymore |
|
429 dstColor = srcColor; |
|
430 } |
|
431 *dst++ = dstColor; |
|
432 colorAddr += aColorPixelPitch; |
|
433 } |
|
434 } |
|
435 |
|
436 |
|
437 // --------------------------------------------------------------------------- |
|
438 // DrawRegionColor16MAMaskToColor16MAPre |
|
439 // --------------------------------------------------------------------------- |
|
440 // |
|
441 LOCAL_C void DrawRegionColor16MAMaskToColor16MAPre |
|
442 ( |
|
443 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
444 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
445 const TRect& aDstRect, // must be clipped to destination |
|
446 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
447 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // mask |
|
448 const TLcdTransform& aTransform // includes anchor |
|
449 ) |
|
450 { |
|
451 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MA); |
|
452 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MA); |
|
453 |
|
454 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
455 BlitLineColor16MAMaskToColor16MAPre); |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // BlitLineColor16MAMaskToColor16MAPre |
|
460 // Target's color components are premultiplied |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 LOCAL_C void BlitLineColor16MAAlphaToColor16MAPre |
|
464 ( |
|
465 TUint8* aDstAddress, |
|
466 TInt aWidth, |
|
467 TUint8* aColorAddress, |
|
468 TInt aColorPixelPitch |
|
469 ) |
|
470 { |
|
471 |
|
472 TUint32* dstAddress = (TUint32*)(aDstAddress); |
|
473 TUint32* end = dstAddress + aWidth; |
|
474 |
|
475 TUint8* srcAddress = aColorAddress; |
|
476 |
|
477 while (dstAddress < end) |
|
478 { |
|
479 const TUint32 src=*(TUint32*)srcAddress; |
|
480 |
|
481 if (src >= 0xFF000000) |
|
482 { |
|
483 *(TUint32*)dstAddress = src; |
|
484 } |
|
485 else |
|
486 { |
|
487 const TUint32 srcAlpha = src >> 24; |
|
488 |
|
489 if (srcAlpha) |
|
490 { |
|
491 TUint32 destA; |
|
492 TUint32 destAG; |
|
493 TUint32 destRB; |
|
494 TUint32 destMultAlpha; |
|
495 |
|
496 const TUint32 dst = *(TUint32*)dstAddress; |
|
497 const TUint32 dstAlpha = dst >> 24; |
|
498 |
|
499 destA = dstAlpha << 16; |
|
500 destA = destA * (0x100 - srcAlpha); |
|
501 destA += srcAlpha << 24; |
|
502 destMultAlpha = 0xFF - srcAlpha; |
|
503 |
|
504 const TUint32 srcPixel = *(TUint32*)srcAddress; |
|
505 const TUint32 dstPixel = *(TUint32*)dstAddress; |
|
506 |
|
507 destAG = (dstPixel & 0xFF00FF00) >> 8; |
|
508 destAG = destAG * destMultAlpha; |
|
509 TUint32 srcAG = (srcPixel & 0xFF00FF00) >> 8; |
|
510 destAG &= 0xFF00FF00; |
|
511 TUint32 alphaPlus1 = srcAlpha + 1; |
|
512 destAG += srcAG * alphaPlus1; |
|
513 |
|
514 destRB = dstPixel & 0x00FF00FF; |
|
515 destRB = destRB * destMultAlpha; |
|
516 destRB &= 0xFF00FF00; |
|
517 TUint32 srcRB = (srcPixel & 0x00FF00FF); |
|
518 destRB += srcRB * alphaPlus1; |
|
519 destRB >>= 8; |
|
520 |
|
521 *(TUint32*)dstAddress = (destAG & 0x0000FF00) | |
|
522 (destRB & 0x00FF00FF) | |
|
523 (destA & 0xFF000000); |
|
524 } |
|
525 } |
|
526 |
|
527 dstAddress++; |
|
528 srcAddress += aColorPixelPitch; |
|
529 } // while( dstAddress < end ) |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // DrawRegionColor16MAAlphaToColor16MAPre |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 LOCAL_C void DrawRegionColor16MAAlphaToColor16MAPre |
|
537 ( |
|
538 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
539 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
540 const TRect& aDstRect, // must be clipped to destination |
|
541 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
542 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // ignored |
|
543 const TLcdTransform& aTransform // includes anchor |
|
544 ) |
|
545 { |
|
546 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MA); |
|
547 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
548 |
|
549 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
550 BlitLineColor16MAAlphaToColor16MAPre); |
|
551 } |
|
552 |
|
553 #endif // RD_JAVA_NGA_ENABLED |
|
554 |
|
555 // *************************************************************** |
|
556 // BitBlt Functions |
|
557 // *************************************************************** |
|
558 |
|
559 LOCAL_C void BlitLineJavaOpaqueToColor16MAOpaque |
|
560 ( |
|
561 TUint8* aDstAddress, |
|
562 TInt aWidth, |
|
563 TUint8* aColorAddress, |
|
564 TInt aColorPixelPitch |
|
565 ) |
|
566 { |
|
567 TUint32* dst = (TUint32*)(aDstAddress); |
|
568 TUint32* end = dst + aWidth; |
|
569 |
|
570 TUint8* colorAddr = aColorAddress; |
|
571 |
|
572 while (dst < end) |
|
573 { |
|
574 // Force alpha to opaque, because top bits in Java are 'don't care'. |
|
575 *dst++ = *(TUint32*)colorAddr | 0xFF000000; |
|
576 colorAddr += aColorPixelPitch; |
|
577 } |
|
578 } |
|
579 |
|
580 // |
|
581 // XRGB8888 to Color16MA opaque. |
|
582 // |
|
583 // We cannot guarantee that the java image has fully opaque pixels |
|
584 // so we need to ensure that the alpha component is initialized |
|
585 // in the destination image. Consider using COLOR16MU for java opaque |
|
586 // images. |
|
587 // |
|
588 LOCAL_C void BitBltJavaOpaqueToColor16MAOpaque |
|
589 ( |
|
590 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
591 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
592 const TRect& aDstRect, |
|
593 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
594 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
595 const TLcdTransform& aTransform |
|
596 ) |
|
597 { |
|
598 ASSERT(aDstColorBitmap); |
|
599 ASSERT(aSrcColorBitmap); |
|
600 |
|
601 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
602 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
603 |
|
604 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
605 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MA); |
|
606 |
|
607 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
608 BlitLineJavaOpaqueToColor16MAOpaque); |
|
609 } |
|
610 |
|
611 |
|
612 LOCAL_C void BlitLineColor16MAAlphaToColor16MAMask |
|
613 ( |
|
614 TUint8* aDstAddress, |
|
615 TInt aWidth, |
|
616 TUint8* aColorAddress, |
|
617 TInt aColorPixelPitch |
|
618 ) |
|
619 { |
|
620 TUint32* dst = (TUint32*)(aDstAddress); |
|
621 TUint32* end = dst + aWidth; |
|
622 |
|
623 TUint8* colorAddr = aColorAddress; |
|
624 |
|
625 while (dst < end) |
|
626 { |
|
627 TUint32 argb = *(TUint32*)colorAddr; |
|
628 |
|
629 TUint32 alpha = argb & 0xff000000; |
|
630 argb ^= alpha; |
|
631 |
|
632 // Anything other than full alpha is set to zero alpha |
|
633 alpha *= !(alpha + 0x01000000); |
|
634 |
|
635 argb |= alpha; |
|
636 *dst++ = argb; |
|
637 colorAddr += aColorPixelPitch; |
|
638 } |
|
639 } |
|
640 |
|
641 // |
|
642 // ARGB8888 -> Color16MA, Gray2 |
|
643 // |
|
644 LOCAL_C void BitBltColor16MAAlphaToColor16MAMask |
|
645 ( |
|
646 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
647 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
648 const TRect& aDstRect, |
|
649 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
650 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
651 const TLcdTransform& aTransform |
|
652 ) |
|
653 { |
|
654 ASSERT(aDstColorBitmap); |
|
655 ASSERT(aSrcColorBitmap); |
|
656 |
|
657 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
658 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
659 |
|
660 ASSERT(aDstColorBitmap->iDisplayMode == EColor16MA); |
|
661 ASSERT(aSrcColorBitmap->iDisplayMode == EColor16MA); // EColorARGB8888 on SymbianOS < 9.1 |
|
662 |
|
663 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
664 BlitLineColor16MAAlphaToColor16MAMask); |
|
665 } |
|
666 |
|
667 TBool DetectCollisionColor16MAColor16MA |
|
668 ( |
|
669 const TAcceleratedBitmapInfo* aBitmap1, |
|
670 const TAcceleratedBitmapInfo* aBitmap2, |
|
671 const TRect& aRect1, |
|
672 const TRect& aRect2, |
|
673 const TLcdTransform& aTransform1, |
|
674 const TLcdTransform& aTransform2 |
|
675 ) |
|
676 { |
|
677 // if only one mask, just need to check if it has any opaque pixels |
|
678 if (aBitmap1 == NULL) |
|
679 { |
|
680 return ::HasOpaquePixelColor16MA(aBitmap2, aRect2); |
|
681 } |
|
682 |
|
683 if (aBitmap2 == NULL) |
|
684 { |
|
685 return ::HasOpaquePixelColor16MA(aBitmap1, aRect1); |
|
686 } |
|
687 |
|
688 ASSERT(aBitmap1->iDisplayMode == EColor16MA); |
|
689 ASSERT(aBitmap2->iDisplayMode == EColor16MA); |
|
690 |
|
691 TLcdTransform transform = aTransform1 * aTransform2.Inverse(); |
|
692 TRect rect = aRect2; |
|
693 |
|
694 TInt h= rect.Height(); |
|
695 TInt w = rect.Width(); |
|
696 |
|
697 TPoint srcPoint = transform(rect.iTl); |
|
698 TInt dudx = transform.iDuDx; |
|
699 TInt dudy = transform.iDuDy; |
|
700 TInt dvdx = transform.iDvDx; |
|
701 TInt dvdy = transform.iDvDy; |
|
702 TInt u0 = srcPoint.iX; |
|
703 TInt v0 = srcPoint.iY; |
|
704 TInt u = u0; |
|
705 TInt v = v0; |
|
706 |
|
707 const TInt linePitch1 = aBitmap1->iLinePitch; |
|
708 const TInt linePitch2 = aBitmap2->iLinePitch; |
|
709 |
|
710 TUint8* address1 = aBitmap1->iAddress; |
|
711 TUint8* address2 = aBitmap2->iAddress; |
|
712 |
|
713 address2 += rect.iTl.iY*linePitch2 + rect.iTl.iX*sizeof(TUint32); |
|
714 |
|
715 if ((dudx == 1) && (dvdx == 0) && (dudy == 0) && (dvdy == 1)) |
|
716 { |
|
717 address1 += v0*linePitch1 + u0*sizeof(TUint32); |
|
718 for (; h>0; --h) |
|
719 { |
|
720 TUint32* pixel1 = (TUint32*)address1; |
|
721 TUint32* pixel2 = (TUint32*)address2; |
|
722 TUint32* end = pixel2 + w; |
|
723 |
|
724 while (pixel2 < end) |
|
725 { |
|
726 TUint32 m2 = *pixel2++; |
|
727 TUint32 m1 = *pixel1++; |
|
728 if ((m2>>24) == 255 && (m1>>24) == 255) |
|
729 { |
|
730 return ETrue; |
|
731 } |
|
732 } |
|
733 |
|
734 address1 += linePitch1; |
|
735 address2 += linePitch2; |
|
736 } |
|
737 } |
|
738 else |
|
739 { |
|
740 for (; h>0; --h) |
|
741 { |
|
742 u=u0; |
|
743 v=v0; |
|
744 |
|
745 TUint32* pixel2 = (TUint32*)address2; |
|
746 TUint32* end = pixel2 + w; |
|
747 |
|
748 while (pixel2 < end) |
|
749 { |
|
750 TUint32 m2 = *pixel2++; |
|
751 TUint32 m1 = *(TUint32*)(address1 + v*linePitch1 + u*sizeof(TUint32)); |
|
752 |
|
753 if ((m2>>24) == 255 && (m1>>24) == 255) |
|
754 { |
|
755 return ETrue; |
|
756 } |
|
757 |
|
758 u+=dudx; |
|
759 v+=dvdx; |
|
760 } |
|
761 |
|
762 u0+=dudy; |
|
763 v0+=dvdy; |
|
764 address2 += linePitch2; |
|
765 } |
|
766 } |
|
767 |
|
768 return EFalse; |
|
769 } |
|
770 |
|
771 |
|
772 TBool HasOpaquePixelColor16MA |
|
773 ( |
|
774 const TAcceleratedBitmapInfo* aBitmap, |
|
775 const TRect& aRect |
|
776 ) |
|
777 { |
|
778 const TInt linePitch = aBitmap->iLinePitch; |
|
779 TUint8* address = aBitmap->iAddress; |
|
780 |
|
781 TInt h = aRect.Height(); |
|
782 TInt w = aRect.Width(); |
|
783 |
|
784 address += aRect.iTl.iY*linePitch + aRect.iTl.iX*sizeof(TUint32); |
|
785 for (; h>0; --h) |
|
786 { |
|
787 TUint32* pix = (TUint32*)address; |
|
788 TUint32* end = pix + w; |
|
789 while (pix < end) |
|
790 { |
|
791 if (((*pix) >> 24) == 255) |
|
792 { |
|
793 return ETrue; |
|
794 } |
|
795 ++pix; |
|
796 } |
|
797 address += linePitch; |
|
798 } |
|
799 |
|
800 return EFalse; |
|
801 } |
|
802 |