|
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 #include <j2me/jdebug.h> |
|
21 |
|
22 |
|
23 #include "lcdgdrvif.h" |
|
24 #include "lcdtransform.h" |
|
25 #include "lcd16bpp.h" |
|
26 #include "lcdgdrvutil.h" |
|
27 #include "lcdgd.hrh" |
|
28 #include "lcdbitblt.h" |
|
29 #include "collision.h" |
|
30 |
|
31 const TInt KColor4KRedShift = 8; |
|
32 const TInt KColor4KRedMax = 0xf; |
|
33 const TInt KColor4KGreenShift = 4; |
|
34 const TInt KColor4KGreenMax = 0xf; |
|
35 const TInt KColor4KBlueShift = 0; |
|
36 const TInt KColor4KBlueMax = 0xf; |
|
37 |
|
38 INLINE TInt Color4KRed(TInt aColor4K) |
|
39 { |
|
40 TUint32 red = (aColor4K>>KColor4KRedShift) & KColor4KRedMax; |
|
41 return (red << 4) + red; |
|
42 } |
|
43 |
|
44 INLINE TInt Color4KGreen(TInt aColor4K) |
|
45 { |
|
46 TUint32 green = (aColor4K>>KColor4KGreenShift) & KColor4KGreenMax; |
|
47 return (green << 4) + green; |
|
48 } |
|
49 |
|
50 INLINE TInt Color4KBlue(TInt aColor4K) |
|
51 { |
|
52 TUint32 blue = (aColor4K>>KColor4KBlueShift) & KColor4KBlueMax; |
|
53 return (blue << 4) + blue; |
|
54 } |
|
55 |
|
56 INLINE TInt Color4K(TInt aRed, TInt aGreen, TInt aBlue) |
|
57 { |
|
58 return ((aRed & 0xf0)<<4) | (aGreen & 0xf0) | ((aBlue & 0xf0)>>4); |
|
59 } |
|
60 |
|
61 INLINE TUint16 ARGB8888ToColor4K(TUint32 aPixel) |
|
62 { |
|
63 return ((aPixel & 0xf00000) >> 12) | |
|
64 ((aPixel & 0x00f000) >> 8) | |
|
65 ((aPixel & 0x0000f0) >> 4); |
|
66 } |
|
67 |
|
68 INLINE TUint32 Color4KToARGB8888(TUint16 aColor4K) |
|
69 { |
|
70 return (Color4KRed(aColor4K)<<16)|(Color4KGreen(aColor4K)<<8)|(Color4KBlue(aColor4K)); |
|
71 } |
|
72 |
|
73 LOCAL_C INLINE TUint32 Color4KForward(TUint32 aRGB) |
|
74 { |
|
75 return ARGB8888ToColor4K(aRGB); |
|
76 } |
|
77 |
|
78 LOCAL_C INLINE TUint32 Color4KReverse(TUint32 aColor4K) |
|
79 { |
|
80 return Color4KToARGB8888(aColor4K); |
|
81 } |
|
82 |
|
83 LOCAL_C INLINE TUint32 Color4KQuantize(TUint32 aRGB) |
|
84 { |
|
85 return Color4KReverse(Color4KForward(aRGB)); |
|
86 } |
|
87 |
|
88 |
|
89 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
90 LOCAL_C void DrawImageColor4KAlphaToColor4K |
|
91 ( |
|
92 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
93 const TAcceleratedBitmapInfo* aDstAlphaBitmap, //ignored |
|
94 const TRect& aDstRect, // must be clipped to destination |
|
95 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
96 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
97 const TLcdTransform& aTransform // includes anchor |
|
98 ); |
|
99 LOCAL_C void DrawRegionColor4KAlphaToColor4K |
|
100 ( |
|
101 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
102 const TAcceleratedBitmapInfo* aDstAlphaBitmap, //ignored |
|
103 const TRect& aDstRect, // must be clipped to destination |
|
104 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
105 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
106 const TLcdTransform& aTransform // includes anchor |
|
107 ); |
|
108 #endif |
|
109 |
|
110 |
|
111 LOCAL_C void DrawRegionARGB8888AlphaToColor4K |
|
112 ( |
|
113 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
114 const TAcceleratedBitmapInfo* aDstAlphaBitmap, // ignored |
|
115 const TRect& aDstRect, // must be clipped to destination |
|
116 const TAcceleratedBitmapInfo* aSrcColorBitmap, // ARGB8888 |
|
117 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
118 const TLcdTransform& aTransform // includes anchor |
|
119 ); |
|
120 |
|
121 // |
|
122 // Blitters |
|
123 // |
|
124 LOCAL_C void BitBltColor4KToARGB8888 |
|
125 ( |
|
126 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
127 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
128 const TRect& aDstRect, |
|
129 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
130 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
131 const TLcdTransform& aTransform |
|
132 ); |
|
133 |
|
134 LOCAL_C void BitBltARGB8888ToColor4K |
|
135 ( |
|
136 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
137 const TAcceleratedBitmapInfo* aDstAlphaBitmap, // ignored |
|
138 const TRect& aDstRect, |
|
139 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
140 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
141 const TLcdTransform& aTransform |
|
142 ); |
|
143 |
|
144 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
145 LOCAL_C void BitBltColor4KGray2ToARGB8888 |
|
146 ( |
|
147 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
148 const TAcceleratedBitmapInfo* aDstAlphaBitmap, // ignored |
|
149 const TRect& aDstRect, |
|
150 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
151 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
152 const TLcdTransform& aTransform |
|
153 ); |
|
154 LOCAL_C void BitBltARGB8888ToColor4KGray2 |
|
155 ( |
|
156 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
157 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
158 const TRect& aDstRect, |
|
159 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
160 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
161 const TLcdTransform& aTransform |
|
162 ); |
|
163 #endif |
|
164 |
|
165 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
166 LOCAL_C void BitBltColor4KColor4KToARGB8888 |
|
167 ( |
|
168 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
169 const TAcceleratedBitmapInfo* aDstAlphaBitmap, // ignored |
|
170 const TRect& aDstRect, |
|
171 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
172 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
173 const TLcdTransform& aTransform |
|
174 ); |
|
175 LOCAL_C void BitBltARGB8888ToColor4KColor4K |
|
176 ( |
|
177 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
178 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
179 const TRect& aDstRect, |
|
180 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
181 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
182 const TLcdTransform& aTransform |
|
183 ); |
|
184 #endif |
|
185 |
|
186 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
187 LOCAL_C void BitBltColor4KGray256ToARGB8888 |
|
188 ( |
|
189 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
190 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
191 const TRect& aDstRect, |
|
192 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
193 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
194 const TLcdTransform& aTransform |
|
195 ); |
|
196 LOCAL_C void BitBltARGB8888ToColor4KGray256 |
|
197 ( |
|
198 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
199 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
200 const TRect& aDstRect, |
|
201 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
202 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
203 const TLcdTransform& aTransform |
|
204 ); |
|
205 #endif |
|
206 |
|
207 // |
|
208 // Supported Image Types |
|
209 // |
|
210 #define COLOR4K_OPAQUE IMAGE_TYPE(EColor4K,ENone,ETransparencyNone) |
|
211 |
|
212 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
213 #define COLOR4K_MASK_1BPP IMAGE_TYPE(EColor4K,EGray2,ETransparencyMaskBitmap) |
|
214 #endif |
|
215 |
|
216 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
217 #define COLOR4K_MASK_MATCHED IMAGE_TYPE(EColor4K,EColor4K,ETransparencyMaskBitmap) |
|
218 #endif |
|
219 |
|
220 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
221 #define COLOR4K_ALPHA IMAGE_TYPE(EColor4K,EGray256,ETransparencyAlphaBitmap) |
|
222 #endif |
|
223 |
|
224 // |
|
225 // Supportd blitters |
|
226 // |
|
227 const TImageRenderer ImageRendererArray[] = |
|
228 { |
|
229 // |
|
230 // SrcOver |
|
231 // |
|
232 /* target, source, transform mask, function */ |
|
233 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
234 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_ALPHA, KTransSimpleMask, DrawImageColor4KAlphaToColor4K), |
|
235 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_ALPHA, KTransAllMask, DrawRegionColor4KAlphaToColor4K), |
|
236 #endif |
|
237 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_OPAQUE, KTransSimpleMask, BitBltSixteenBppSimple), |
|
238 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_OPAQUE, KTransAllMask, BitBltSixteenBpp), |
|
239 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
240 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_MASK_1BPP, KTransNoneMask, DrawImage16Bpp1BppTo16BppOpaque), |
|
241 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_MASK_1BPP, KTransAllMask, DrawRegion16Bpp1BppTo16BppOpaque), |
|
242 #endif |
|
243 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
244 RENDER_ENTRY(COLOR4K_OPAQUE, COLOR4K_MASK_MATCHED, KTransAllMask, DrawRegion16Bpp16BppTo16BppOpaque), |
|
245 #endif |
|
246 RENDER_ENTRY(COLOR4K_OPAQUE, JAVA_OPAQUE_IMAGE, KTransAllMask, BitBltARGB8888ToColor4K), |
|
247 RENDER_ENTRY(COLOR4K_OPAQUE, JAVA_ALPHA_IMAGE, KTransAllMask, DrawRegionARGB8888AlphaToColor4K), |
|
248 |
|
249 // |
|
250 // SrcCopy |
|
251 // |
|
252 /* target, source, function */ |
|
253 SIMPLE_BLITTER_ENTRY(COLOR4K_OPAQUE, COLOR4K_OPAQUE, BitBltSixteenBppSimple), |
|
254 BLITTER_ENTRY(COLOR4K_OPAQUE, COLOR4K_OPAQUE, BitBltSixteenBpp), |
|
255 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR4K_OPAQUE, BitBltColor4KToARGB8888), |
|
256 BLITTER_ENTRY(COLOR4K_OPAQUE, JAVA_OPAQUE_IMAGE, BitBltARGB8888ToColor4K), |
|
257 BLITTER_ENTRY(JAVA_OPAQUE_IMAGE, COLOR4K_OPAQUE, BitBltColor4KToARGB8888), |
|
258 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
259 BLITTER_ENTRY(COLOR4K_MASK_1BPP, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor4KGray2), |
|
260 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR4K_MASK_1BPP, BitBltColor4KGray2ToARGB8888), |
|
261 BLITTER_ENTRY(COLOR4K_MASK_1BPP, COLOR4K_MASK_1BPP, BitBltSixteenBppOneBpp), |
|
262 #endif |
|
263 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
264 BLITTER_ENTRY(COLOR4K_MASK_MATCHED, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor4KColor4K), |
|
265 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR4K_MASK_MATCHED, BitBltColor4KColor4KToARGB8888), |
|
266 BLITTER_ENTRY(COLOR4K_MASK_MATCHED, COLOR4K_MASK_MATCHED, BitBltSixteenBppSixteenBpp), |
|
267 #endif |
|
268 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
269 BLITTER_ENTRY(COLOR4K_ALPHA, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor4KGray256), |
|
270 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR4K_ALPHA, BitBltColor4KGray256ToARGB8888), |
|
271 BLITTER_ENTRY(COLOR4K_ALPHA, COLOR4K_ALPHA, BitBltSixteenBppEightBpp), |
|
272 #endif |
|
273 }; |
|
274 const TInt ImageRendererCount = sizeof(ImageRendererArray)/sizeof(ImageRendererArray[0]); |
|
275 |
|
276 const TCollisionDetector CollisionDetectorArray[] = |
|
277 { |
|
278 // |
|
279 // Supported collision detectors. |
|
280 // |
|
281 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray2Gray2), |
|
282 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, ENoneBit,ETransparencyNoneBit, DetectCollisionGray2Gray2), |
|
283 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray2Gray2), |
|
284 |
|
285 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
286 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray256Gray256), |
|
287 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray2Gray256), |
|
288 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray256Gray2), |
|
289 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, ENoneBit,ETransparencyNoneBit, DetectCollisionGray256Gray256), |
|
290 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray256Gray256), |
|
291 #endif |
|
292 |
|
293 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
294 COLLISION_DETECTOR_ENTRY(KGenericModesMask,KGenericTransMask, KGenericModesMask,KGenericTransMask, GenericDetectCollision), |
|
295 #endif |
|
296 }; |
|
297 const TInt CollisionDetectorCount = sizeof(CollisionDetectorArray)/sizeof(CollisionDetectorArray[0]); |
|
298 |
|
299 const TColorMap ColorMapArray[] = |
|
300 { |
|
301 { EColor4K, Color4KForward, Color4KReverse, Color4KQuantize } |
|
302 }; |
|
303 const TInt ColorMapCount = sizeof(ColorMapArray)/sizeof(ColorMapArray[0]); |
|
304 |
|
305 const TDrawFunctions DrawFunctionsArray[] = |
|
306 { |
|
307 { |
|
308 EColor4K, |
|
309 CLcdGraphicsDevice::ECapFillTriangle, |
|
310 NULL, // drawLine |
|
311 NULL, // drawRect |
|
312 NULL, // fillRect |
|
313 NULL, // drawArc |
|
314 NULL, // fillArc |
|
315 &FillTriangle16Bpp, |
|
316 NULL // drawText |
|
317 } |
|
318 }; |
|
319 const TInt DrawFunctionsCount = sizeof(DrawFunctionsArray)/sizeof(DrawFunctionsArray[0]); |
|
320 |
|
321 |
|
322 const TInt KVersionBuild = 0; |
|
323 |
|
324 _LIT(KProviderSymbianSoftwareLtd, "Symbian Software Ltd"); |
|
325 |
|
326 |
|
327 LOCAL_C CLcdGraphicsDriverImpl* CreateColor4KDriverL(); |
|
328 |
|
329 // |
|
330 // Could support more than one implementation |
|
331 // |
|
332 const TImplementationProxy ImplementationTable[] = |
|
333 { |
|
334 IMPLEMENTATION_PROXY_ENTRY(LCDGD_COLOR4K_IMPLEMENTATION_UID, CreateColor4KDriverL) |
|
335 }; |
|
336 |
|
337 /** |
|
338 * Exported @ Ordinal 1 |
|
339 */ |
|
340 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
341 { |
|
342 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
343 return ImplementationTable; |
|
344 } |
|
345 |
|
346 CLcdGraphicsDriverImpl* CreateColor4KDriverL() |
|
347 { |
|
348 CLcdGraphicsDriver::TDriverInfo driverInfo; |
|
349 |
|
350 driverInfo.iVersion = TVersion(KLcdImgVersionMajor, KLcdImgVersionMinor, KVersionBuild); |
|
351 driverInfo.iProvider = KProviderSymbianSoftwareLtd; |
|
352 driverInfo.iTransparencyCaps = CAP_1BPP_MASK_BITMAP|CAP_MATCHED_MASK_BITMAP|CAP_ALPHA_BITMAP; |
|
353 driverInfo.iDisplayMode = EColor4K; |
|
354 driverInfo.iARGB8888Mode = EColorARGB8888; |
|
355 |
|
356 return new(ELeave) CLcdGraphicsDriverImpl |
|
357 ( |
|
358 driverInfo, |
|
359 ImageRendererArray, |
|
360 ImageRendererCount, |
|
361 ColorMapArray, |
|
362 ColorMapCount, |
|
363 CollisionDetectorArray, |
|
364 CollisionDetectorCount, |
|
365 DrawFunctionsArray, |
|
366 DrawFunctionsCount |
|
367 ); |
|
368 } |
|
369 |
|
370 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
371 LOCAL_C void BlitLineColor4KAlphaToColor4KNoTrans |
|
372 ( |
|
373 TUint8* aDstAddress, |
|
374 TInt aWidth, |
|
375 TUint8* aColorAddress, |
|
376 TInt DEBUG_ONLY(aColorPixelPitch), |
|
377 TUint8* aAlphaAddress, |
|
378 TInt DEBUG_ONLY(aAlphaPixelPitch) |
|
379 ) |
|
380 { |
|
381 ASSERT(aColorPixelPitch == sizeof(TUint16)); |
|
382 ASSERT(aAlphaPixelPitch == sizeof(TUint8)); |
|
383 |
|
384 TUint16* dst = (TUint16*)aDstAddress; |
|
385 TUint16* end = dst + aWidth; |
|
386 |
|
387 TUint16* colorAddr = (TUint16*)aColorAddress; |
|
388 TUint8* alphaAddr = aAlphaAddress; |
|
389 |
|
390 while (dst < end) |
|
391 { |
|
392 TUint alpha = *alphaAddr++; |
|
393 if (alpha == 0xFF) |
|
394 { |
|
395 *dst = *colorAddr; |
|
396 } |
|
397 else |
|
398 { |
|
399 if (alpha) |
|
400 { |
|
401 TUint16 dstColor = *dst; |
|
402 TUint16 srcColor = *(TUint16*)colorAddr; |
|
403 |
|
404 alpha = (alpha << 8) | alpha; |
|
405 |
|
406 TUint32 dr = Blend16(alpha, Color4KRed(srcColor), Color4KRed(dstColor)); |
|
407 TUint32 dg = Blend16(alpha, Color4KGreen(srcColor), Color4KGreen(dstColor)); |
|
408 TUint32 db = Blend16(alpha, Color4KBlue(srcColor), Color4KBlue(dstColor)); |
|
409 |
|
410 ASSERT(dr <= 255); |
|
411 ASSERT(dg <= 255); |
|
412 ASSERT(db <= 255); |
|
413 |
|
414 // map back to Color4K |
|
415 *dst = Color4K(dr, dg, db); |
|
416 } |
|
417 } |
|
418 dst++; |
|
419 colorAddr++; |
|
420 } |
|
421 } |
|
422 |
|
423 LOCAL_C void DrawImageColor4KAlphaToColor4K |
|
424 ( |
|
425 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
426 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
427 const TRect& aDstRect, // must be clipped to destination |
|
428 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
429 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
430 const TLcdTransform& aTransform // includes anchor |
|
431 ) |
|
432 { |
|
433 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
434 ASSERT(aSrcColorBitmap->iDisplayMode == EColor4K); |
|
435 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
436 |
|
437 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
438 aSrcAlphaBitmap, ETrue, BlitLineColor4KAlphaToColor4KNoTrans); |
|
439 } |
|
440 |
|
441 LOCAL_C void BlitLineColor4KAlphaToColor4K |
|
442 ( |
|
443 TUint8* aDstAddress, |
|
444 TInt aWidth, |
|
445 TUint8* aColorAddress, |
|
446 TInt aColorPixelPitch, |
|
447 TUint8* aAlphaAddress, |
|
448 TInt aAlphaPixelPitch |
|
449 ) |
|
450 { |
|
451 TUint16* dst = (TUint16*)(aDstAddress); |
|
452 TUint16* end = dst + aWidth; |
|
453 |
|
454 TUint8* colorAddr = aColorAddress; |
|
455 TUint8* alphaAddr = aAlphaAddress; |
|
456 |
|
457 while (dst < end) |
|
458 { |
|
459 TUint alpha = *alphaAddr; |
|
460 if (alpha == 0xFF) |
|
461 { |
|
462 *dst = *(TUint16*)colorAddr; |
|
463 } |
|
464 else |
|
465 { |
|
466 if (alpha) |
|
467 { |
|
468 TUint16 dstColor = *dst; |
|
469 TUint16 srcColor = *(TUint16*)colorAddr; |
|
470 |
|
471 alpha = (alpha << 8) | alpha; |
|
472 |
|
473 TUint32 dr = Blend16(alpha, Color4KRed(srcColor), Color4KRed(dstColor)); |
|
474 TUint32 dg = Blend16(alpha, Color4KGreen(srcColor), Color4KGreen(dstColor)); |
|
475 TUint32 db = Blend16(alpha, Color4KBlue(srcColor), Color4KBlue(dstColor)); |
|
476 |
|
477 ASSERT(dr <= 255); |
|
478 ASSERT(dg <= 255); |
|
479 ASSERT(db <= 255); |
|
480 |
|
481 // map back to Color4K |
|
482 *dst = Color4K(dr, dg, db); |
|
483 } |
|
484 } |
|
485 |
|
486 // Advance to next pixel in the line in each bitmap. |
|
487 ++dst; // TUint16* so adds two to the address. |
|
488 colorAddr += aColorPixelPitch; |
|
489 alphaAddr += aAlphaPixelPitch; |
|
490 } |
|
491 } |
|
492 |
|
493 LOCAL_C void DrawRegionColor4KAlphaToColor4K |
|
494 ( |
|
495 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
496 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
497 const TRect& aDstRect, // must be clipped to destination |
|
498 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
499 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
500 const TLcdTransform& aTransform // includes anchor |
|
501 ) |
|
502 { |
|
503 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
504 ASSERT(aSrcColorBitmap->iDisplayMode == EColor4K); |
|
505 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
506 |
|
507 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
508 aSrcAlphaBitmap, ETrue, BlitLineColor4KAlphaToColor4K); |
|
509 } |
|
510 #endif |
|
511 |
|
512 |
|
513 LOCAL_C void BlitLineARGB8888AlphaToColor4K |
|
514 ( |
|
515 TUint8* aDstAddress, |
|
516 TInt aWidth, |
|
517 TUint8* aColorAddress, |
|
518 TInt aColorPixelPitch |
|
519 ) |
|
520 { |
|
521 TUint16* dst = (TUint16*)(aDstAddress); |
|
522 TUint16* end = dst + aWidth; |
|
523 |
|
524 TUint8* colorAddr = aColorAddress; |
|
525 |
|
526 while (dst < end) |
|
527 { |
|
528 TUint32 argb = *(TUint32*)colorAddr; |
|
529 TInt alpha = argb>>24; |
|
530 if (alpha == 0xFF) |
|
531 { |
|
532 // Trivial case: opaque |
|
533 *dst = ARGB8888ToColor4K(argb); |
|
534 } |
|
535 else |
|
536 { |
|
537 // Check for the other trivial case: clear |
|
538 if (alpha) |
|
539 { |
|
540 TUint16 dstColor = *dst; |
|
541 |
|
542 alpha = (alpha << 8) | alpha; |
|
543 |
|
544 TUint32 dr = Blend16(alpha, ((argb>>16)&0xff), Color4KRed(dstColor)); |
|
545 TUint32 dg = Blend16(alpha, ((argb>>8)&0xff), Color4KGreen(dstColor)); |
|
546 TUint32 db = Blend16(alpha, (argb&0xff), Color4KBlue(dstColor)); |
|
547 |
|
548 ASSERT(dr <= 255); |
|
549 ASSERT(dg <= 255); |
|
550 ASSERT(db <= 255); |
|
551 |
|
552 *dst = Color4K(dr, dg, db); |
|
553 } |
|
554 } |
|
555 dst++; |
|
556 colorAddr += aColorPixelPitch; |
|
557 } |
|
558 } |
|
559 |
|
560 LOCAL_C void DrawRegionARGB8888AlphaToColor4K |
|
561 ( |
|
562 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
563 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
564 const TRect& aDstRect, // must be clipped to destination |
|
565 const TAcceleratedBitmapInfo* aSrcColorBitmap, // ARGB8888 |
|
566 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // ignored |
|
567 const TLcdTransform& aTransform // includes anchor |
|
568 ) |
|
569 { |
|
570 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
571 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
572 |
|
573 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
574 BlitLineARGB8888AlphaToColor4K); |
|
575 } |
|
576 |
|
577 // ************************************************* |
|
578 // Blitters. |
|
579 // ************************************************* |
|
580 |
|
581 LOCAL_C void BlitLineColor4KToARGB8888 |
|
582 ( |
|
583 TUint8* aDstAddress, |
|
584 TInt aWidth, |
|
585 TUint8* aColorAddress, |
|
586 TInt aColorPixelPitch |
|
587 ) |
|
588 { |
|
589 TUint32* dst = (TUint32*)(aDstAddress); |
|
590 TUint32* end = dst + aWidth; |
|
591 |
|
592 TUint8* colorAddr = aColorAddress; |
|
593 |
|
594 while (dst < end) |
|
595 { |
|
596 *dst++ = Color4KReverse(*(TUint16*)colorAddr) | 0xFF000000; |
|
597 colorAddr += aColorPixelPitch; |
|
598 } |
|
599 } |
|
600 |
|
601 LOCAL_C void BitBltColor4KToARGB8888 |
|
602 ( |
|
603 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
604 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
605 const TRect& aDstRect, |
|
606 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
607 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
608 const TLcdTransform& aTransform |
|
609 ) |
|
610 { |
|
611 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
612 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
613 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
614 ASSERT(aSrcColorBitmap->iDisplayMode == EColor4K); |
|
615 |
|
616 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
617 BlitLineColor4KToARGB8888); |
|
618 } |
|
619 |
|
620 LOCAL_C void BlitLineARGB8888OpaqueToColor4K |
|
621 ( |
|
622 TUint8* aDstAddress, |
|
623 TInt aWidth, |
|
624 TUint8* aColorAddress, |
|
625 TInt aColorPixelPitch |
|
626 ) |
|
627 { |
|
628 TUint16* dst = (TUint16*)(aDstAddress); |
|
629 TUint16* end = dst + aWidth; |
|
630 |
|
631 TUint8* colorAddr = aColorAddress; |
|
632 |
|
633 while (dst < end) |
|
634 { |
|
635 *dst++ = ARGB8888ToColor4K(*(TUint32*)colorAddr); |
|
636 colorAddr += aColorPixelPitch; |
|
637 } |
|
638 } |
|
639 |
|
640 LOCAL_C void BitBltARGB8888ToColor4K |
|
641 ( |
|
642 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
643 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
644 const TRect& aDstRect, |
|
645 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
646 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
647 const TLcdTransform& aTransform |
|
648 ) |
|
649 { |
|
650 ASSERT(aDstColorBitmap); |
|
651 ASSERT(aSrcColorBitmap); |
|
652 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
653 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
654 |
|
655 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
656 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
657 |
|
658 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
659 BlitLineARGB8888OpaqueToColor4K); |
|
660 } |
|
661 |
|
662 |
|
663 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
664 LOCAL_C void BitBltColor4KGray2ToARGB8888 |
|
665 ( |
|
666 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
667 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
668 const TRect& aDstRect, |
|
669 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
670 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
671 const TLcdTransform& aTransform |
|
672 ) |
|
673 { |
|
674 ASSERT(aDstColorBitmap); |
|
675 ASSERT(aSrcColorBitmap); |
|
676 ASSERT(aSrcAlphaBitmap); |
|
677 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
678 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
679 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
680 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
681 ASSERT(aSrcColorBitmap->iDisplayMode == EColor4K); |
|
682 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray2); |
|
683 |
|
684 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
685 |
|
686 TInt dudx = aTransform.iDuDx; |
|
687 TInt dudy = aTransform.iDuDy; |
|
688 TInt dvdx = aTransform.iDvDx; |
|
689 TInt dvdy = aTransform.iDvDy; |
|
690 TInt u0 = srcPoint.iX; |
|
691 TInt v0 = srcPoint.iY; |
|
692 TInt u = u0; |
|
693 TInt v = v0; |
|
694 |
|
695 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
696 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
697 TUint8* mskAddress = aSrcAlphaBitmap->iAddress; |
|
698 |
|
699 TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
700 TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
701 TInt mskLinePitch = aSrcAlphaBitmap->iLinePitch; |
|
702 |
|
703 dstAddress += dstLinePitch*aDstRect.iTl.iY; |
|
704 dstAddress += aDstRect.iTl.iX*sizeof(TUint32); |
|
705 |
|
706 TInt height = aDstRect.Height(); |
|
707 TInt width = aDstRect.Width(); |
|
708 for (; height>0; --height) |
|
709 { |
|
710 TUint32* dst = (TUint32*)dstAddress; |
|
711 TUint32* end = dst + width; |
|
712 |
|
713 u=u0; |
|
714 v=v0; |
|
715 while (dst < end) |
|
716 { |
|
717 TUint8* src = srcAddress + v*srcLinePitch + u*sizeof(TUint16); |
|
718 TUint8* msk = mskAddress + v*mskLinePitch + (u>>3); |
|
719 |
|
720 TUint16 spix = *(TUint16*)src; |
|
721 TUint8 smsk = *msk; |
|
722 TUint32 dpix = (smsk & 1<<(u&0x7))?0xff000000:0; |
|
723 |
|
724 dpix |= Color4KToARGB8888(spix); |
|
725 |
|
726 *dst++ = dpix; |
|
727 u+=dudx; |
|
728 v+=dvdx; |
|
729 } |
|
730 u0+=dudy; |
|
731 v0+=dvdy; |
|
732 dstAddress += dstLinePitch; |
|
733 } |
|
734 } |
|
735 |
|
736 LOCAL_C void BitBltARGB8888ToColor4KGray2 |
|
737 ( |
|
738 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
739 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
740 const TRect& aDstRect, |
|
741 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
742 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
743 const TLcdTransform& aTransform |
|
744 ) |
|
745 { |
|
746 ASSERT(aDstColorBitmap); |
|
747 ASSERT(aDstAlphaBitmap); |
|
748 ASSERT(aSrcColorBitmap); |
|
749 |
|
750 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
751 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
752 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
753 |
|
754 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
755 ASSERT(aDstAlphaBitmap->iDisplayMode == EGray2); |
|
756 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
757 |
|
758 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
759 |
|
760 TInt dudx = aTransform.iDuDx; |
|
761 TInt dudy = aTransform.iDuDy; |
|
762 TInt dvdx = aTransform.iDvDx; |
|
763 TInt dvdy = aTransform.iDvDy; |
|
764 TInt u0 = srcPoint.iX; |
|
765 TInt v0 = srcPoint.iY; |
|
766 TInt u = u0; |
|
767 TInt v = v0; |
|
768 |
|
769 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
770 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
771 TUint8* mskAddress = aDstAlphaBitmap->iAddress; |
|
772 |
|
773 TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
774 TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
775 TInt mskLinePitch = aDstAlphaBitmap->iLinePitch; |
|
776 |
|
777 dstAddress += dstLinePitch*aDstRect.iTl.iY; |
|
778 dstAddress += aDstRect.iTl.iX*sizeof(TUint16); |
|
779 |
|
780 mskAddress += mskLinePitch*aDstRect.iTl.iY; |
|
781 mskAddress += (aDstRect.iTl.iX>>3); |
|
782 |
|
783 TInt height = aDstRect.Height(); |
|
784 TInt width = aDstRect.Width(); |
|
785 |
|
786 for (; height>0; --height) |
|
787 { |
|
788 TUint16* dst = (TUint16*)dstAddress; |
|
789 TUint8* msk = mskAddress; |
|
790 |
|
791 TInt x0 = aDstRect.iTl.iX; |
|
792 TInt x1 = Min((aDstRect.iTl.iX | 0x7)+1, aDstRect.iBr.iX); |
|
793 TInt x2 = (aDstRect.iBr.iX & ~0x7); |
|
794 TInt x3 = aDstRect.iBr.iX; |
|
795 TInt x; |
|
796 |
|
797 u=u0; |
|
798 v=v0; |
|
799 |
|
800 // |
|
801 // Leading mask byte |
|
802 // |
|
803 for (x = x0; x<x1; x++) |
|
804 { |
|
805 TUint32 pixel = *(TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
806 TUint8 alpha = pixel>>24; |
|
807 |
|
808 TInt xBit = (1<<(x&0x7)); |
|
809 if (alpha == 0xff) |
|
810 { |
|
811 *msk |= xBit; |
|
812 } |
|
813 else |
|
814 { |
|
815 *msk &= ~xBit; |
|
816 } |
|
817 |
|
818 *dst++ = ARGB8888ToColor4K(pixel); |
|
819 u+=dudx; |
|
820 v+=dvdx; |
|
821 } |
|
822 ++msk; |
|
823 |
|
824 // |
|
825 // Middle section |
|
826 // |
|
827 for (ASSERT(x==x1); x<x2; x+=8) |
|
828 { |
|
829 TUint8 mask = 0; |
|
830 |
|
831 TUint16* end = dst + 8; |
|
832 TInt mbit = 1; |
|
833 while (dst < end) |
|
834 { |
|
835 TUint32 pixel = *(TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
836 if ((pixel >> 24)==0xff) |
|
837 { |
|
838 mask |= mbit; |
|
839 } |
|
840 *dst++ = ARGB8888ToColor4K(pixel); |
|
841 mbit <<= 1; |
|
842 u+=dudx; |
|
843 v+=dvdx; |
|
844 } |
|
845 |
|
846 *msk++ = mask; |
|
847 } |
|
848 |
|
849 // |
|
850 // Trailing mask byte |
|
851 // |
|
852 for (ASSERT((x>=x2)&&(x<=x3)); x<x3; x++) |
|
853 { |
|
854 TUint32 pixel = *(TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
855 TUint8 alpha = pixel>>24; |
|
856 |
|
857 TInt xBit = (1<<(x&0x7)); |
|
858 if (alpha == 0xff) |
|
859 { |
|
860 *msk |= xBit; |
|
861 } |
|
862 else |
|
863 { |
|
864 *msk &= ~xBit; |
|
865 } |
|
866 |
|
867 *dst++ = ARGB8888ToColor4K(pixel); |
|
868 u+=dudx; |
|
869 v+=dvdx; |
|
870 } |
|
871 |
|
872 u0+=dudy; |
|
873 v0+=dvdy; |
|
874 dstAddress += dstLinePitch; |
|
875 mskAddress += mskLinePitch; |
|
876 } |
|
877 } |
|
878 #endif |
|
879 |
|
880 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
881 LOCAL_C void BlitLineColor4KColor4KToARGB8888 |
|
882 ( |
|
883 TUint8* aDstAddress, |
|
884 TInt aWidth, |
|
885 TUint8* aColorAddress, |
|
886 TInt aColorPixelPitch, |
|
887 TUint8* aMaskAddress, |
|
888 TInt aMaskPixelPitch |
|
889 ) |
|
890 { |
|
891 TUint32* dst = (TUint32*)(aDstAddress); |
|
892 TUint32* end = dst + aWidth; |
|
893 |
|
894 TUint8* colorAddr = aColorAddress; |
|
895 TUint8* maskAddr = aMaskAddress; |
|
896 |
|
897 while (dst < end) |
|
898 { |
|
899 TUint16 smsk = *(TUint16*)maskAddr; |
|
900 TUint16 spix = *(TUint16*)colorAddr); |
|
901 |
|
902 TUint32 dpix = (smsk << 24); // bottom 8 bits of smsk should all be 1 if opaque |
|
903 ASSERT((smsk == 0) || (smsk == 0x0fff)); |
|
904 dpix |= Color4KRed(spix) << 16; |
|
905 dpix |= Color4KGreen(spix) << 8; |
|
906 dpix |= Color4KBlue(spix); |
|
907 *dst++ = dpix; |
|
908 |
|
909 // Advance to next pixel in the line in each bitmap. |
|
910 colorAddr += aColorPixelPitch; |
|
911 maskAddr += aMaskPixelPitch; |
|
912 } |
|
913 } |
|
914 |
|
915 LOCAL_C void BitBltColor4KColor4KToARGB8888 |
|
916 ( |
|
917 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
918 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
919 const TRect& aDstRect, |
|
920 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
921 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
922 const TLcdTransform& aTransform |
|
923 ) |
|
924 { |
|
925 ASSERT(aDstColorBitmap); |
|
926 ASSERT(aSrcColorBitmap); |
|
927 ASSERT(aSrcAlphaBitmap); |
|
928 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
929 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
930 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
931 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
932 ASSERT(aSrcColorBitmap->iDisplayMode == EColor4K); |
|
933 ASSERT(aSrcAlphaBitmap->iDisplayMode == EColor4K); |
|
934 |
|
935 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
936 aSrcAlphaBitmap, ETrue, BlitLineColor4KColor4KToARGB8888); |
|
937 } |
|
938 |
|
939 LOCAL_C void BlitLineARGB8888ToColor4KColor4K |
|
940 ( |
|
941 TUint8* aDstAddress, |
|
942 TInt aWidth, |
|
943 TUint8* aColorAddress, |
|
944 TInt aColorPixelPitch, |
|
945 TUint8* aMaskAddress, |
|
946 TInt aMaskPixelPitch |
|
947 ) |
|
948 { |
|
949 TUint16* dst = (TUint16*)(aDstAddress); |
|
950 TUint16* end = dst + aWidth; |
|
951 |
|
952 TUint8* colorAddr = aColorAddress; |
|
953 TUint16* maskAddr = aMaskAddress; |
|
954 |
|
955 ASSERT(aMaskPixelPitch == sizeof(TUint16)); |
|
956 UNUSED(aMaskPixelPitch); // ASSERT is the only use otherwise. |
|
957 |
|
958 while (dst < end) |
|
959 { |
|
960 TUint32 pixel = *(TUint32*)colorAddr; |
|
961 *dst++ = ARGB8888ToColor4K(pixel); |
|
962 *maskAddr++ = (TUint16)(((pixel >> 24) == 0xff) ? 0x0fff : 0); |
|
963 |
|
964 // Advance to next pixel in the line in each bitmap. |
|
965 colorAddr += aColorPixelPitch; |
|
966 } |
|
967 } |
|
968 |
|
969 LOCAL_C void BitBltARGB8888ToColor4KColor4K |
|
970 ( |
|
971 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
972 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
973 const TRect& aDstRect, |
|
974 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
975 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
976 const TLcdTransform& aTransform |
|
977 ) |
|
978 { |
|
979 ASSERT(aDstColorBitmap); |
|
980 ASSERT(aDstAlphaBitmap); |
|
981 ASSERT(aSrcColorBitmap); |
|
982 |
|
983 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
984 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
985 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
986 |
|
987 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
988 ASSERT(aDstAlphaBitmap->iDisplayMode == EColor4K); |
|
989 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
990 |
|
991 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
992 aDstAlphaBitmap, EFalse, BlitLineARGB8888ToColor4KColor4K); |
|
993 } |
|
994 #endif |
|
995 |
|
996 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
997 LOCAL_C void BlitLineColor4KGray256ToARGB8888 |
|
998 ( |
|
999 TUint8* aDstAddress, |
|
1000 TInt aWidth, |
|
1001 TUint8* aColorAddress, |
|
1002 TInt aColorPixelPitch, |
|
1003 TUint8* aMaskAddress, |
|
1004 TInt aMaskPixelPitch |
|
1005 ) |
|
1006 { |
|
1007 TUint32* dst = (TUint32*)(aDstAddress); |
|
1008 TUint32* end = dst + aWidth; |
|
1009 |
|
1010 TUint8* colorAddr = aColorAddress; |
|
1011 TUint8* maskAddr = aMaskAddress; |
|
1012 |
|
1013 while (dst < end) |
|
1014 { |
|
1015 TUint16 spix = *(TUint16*)colorAddr; |
|
1016 TUint32 dpix = *maskAddr << 24; |
|
1017 |
|
1018 dpix |= Color4KRed(spix) << 16; |
|
1019 dpix |= Color4KGreen(spix) << 8; |
|
1020 dpix |= Color4KBlue(spix); |
|
1021 *dst++ = dpix; |
|
1022 |
|
1023 // Advance to next pixel in the line in each bitmap. |
|
1024 colorAddr += aColorPixelPitch; |
|
1025 maskAddr += aMaskPixelPitch; |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 // |
|
1030 // Color4K, Gray256 -> ARGB8888 |
|
1031 // |
|
1032 LOCAL_C void BitBltColor4KGray256ToARGB8888 |
|
1033 ( |
|
1034 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
1035 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
1036 const TRect& aDstRect, |
|
1037 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1038 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
1039 const TLcdTransform& aTransform |
|
1040 ) |
|
1041 { |
|
1042 ASSERT(aDstColorBitmap); |
|
1043 ASSERT(aSrcColorBitmap); |
|
1044 ASSERT(aSrcAlphaBitmap); |
|
1045 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1046 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1047 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
1048 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
1049 ASSERT(aSrcColorBitmap->iDisplayMode == EColor4K); |
|
1050 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
1051 |
|
1052 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1053 aSrcAlphaBitmap, ETrue, BlitLineColor4KGray256ToARGB8888); |
|
1054 } |
|
1055 |
|
1056 LOCAL_C void BlitLineARGB8888ToColor4KGray256 |
|
1057 ( |
|
1058 TUint8* aDstAddress, |
|
1059 TInt aWidth, |
|
1060 TUint8* aColorAddress, |
|
1061 TInt aColorPixelPitch, |
|
1062 TUint8* aMaskAddress, |
|
1063 TInt aMaskPixelPitch |
|
1064 ) |
|
1065 { |
|
1066 TUint16* dst = (TUint16*)(aDstAddress); |
|
1067 TUint16* end = dst + aWidth; |
|
1068 |
|
1069 TUint8* colorAddr = aColorAddress; |
|
1070 TUint8* maskAddr = aMaskAddress; |
|
1071 |
|
1072 ASSERT(aMaskPixelPitch == sizeof(TUint8)); |
|
1073 UNUSED(aMaskPixelPitch); // ASSERT is the only use otherwise. |
|
1074 |
|
1075 while (dst < end) |
|
1076 { |
|
1077 TUint32 pixel = *(TUint32*)colorAddr; |
|
1078 *dst++ = ARGB8888ToColor4K(pixel); |
|
1079 *maskAddr++ = pixel >> 24; |
|
1080 |
|
1081 // Advance to next pixel in the line in each bitmap. |
|
1082 colorAddr += aColorPixelPitch; |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 LOCAL_C void BitBltARGB8888ToColor4KGray256 |
|
1087 ( |
|
1088 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
1089 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
1090 const TRect& aDstRect, |
|
1091 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1092 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
1093 const TLcdTransform& aTransform |
|
1094 ) |
|
1095 { |
|
1096 ASSERT(aDstColorBitmap); |
|
1097 ASSERT(aDstAlphaBitmap); |
|
1098 ASSERT(aSrcColorBitmap); |
|
1099 |
|
1100 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1101 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
1102 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1103 |
|
1104 ASSERT(aDstColorBitmap->iDisplayMode == EColor4K); |
|
1105 ASSERT(aDstAlphaBitmap->iDisplayMode == EGray256); |
|
1106 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
1107 |
|
1108 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1109 aDstAlphaBitmap, EFalse, BlitLineARGB8888ToColor4KGray256); |
|
1110 } |
|
1111 #endif |
|
1112 |