|
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 "lcdgd.hrh" |
|
24 #include "lcdgdrvif.h" |
|
25 #include "lcdgdrvutil.h" |
|
26 #include "lcdtransform.h" |
|
27 #include "lcdbitblt.h" |
|
28 #include "lcd16bpp.h" |
|
29 #include "collision.h" |
|
30 |
|
31 const TInt KColor64KRedBits = 5; |
|
32 const TInt KColor64KRedShift = 11; |
|
33 const TInt KColor64KRedMax = (1<<KColor64KRedBits)-1; |
|
34 |
|
35 const TInt KColor64KGreenBits = 6; |
|
36 const TInt KColor64KGreenShift = 5; |
|
37 const TInt KColor64KGreenMax = (1<<KColor64KGreenBits)-1; |
|
38 |
|
39 const TInt KColor64KBlueBits = 5; |
|
40 const TInt KColor64KBlueShift = 0; |
|
41 const TInt KColor64KBlueMax = (1<<KColor64KBlueBits)-1; |
|
42 |
|
43 #ifdef _DEBUG |
|
44 const TInt KColor64KRedMask = KColor64KRedMax<<KColor64KRedShift; |
|
45 const TInt KColor64KGreenMask = KColor64KGreenMax<<KColor64KGreenShift; |
|
46 const TInt KColor64KBlueMask = KColor64KBlueMax<<KColor64KBlueShift; |
|
47 #endif |
|
48 |
|
49 INLINE TInt Color64KRed(TInt aColor64K) |
|
50 { |
|
51 TUint32 red = (aColor64K>>KColor64KRedShift) & KColor64KRedMax; |
|
52 |
|
53 red = (red << 3) + (red >> 2); |
|
54 |
|
55 ASSERT(red <= 255); |
|
56 |
|
57 return red; |
|
58 } |
|
59 |
|
60 INLINE TInt Color64KGreen(TInt aColor64K) |
|
61 { |
|
62 TUint32 green = (aColor64K>>KColor64KGreenShift) & KColor64KGreenMax; |
|
63 |
|
64 green = (green << 2) + (green >> 4); |
|
65 |
|
66 ASSERT(green <= 255); |
|
67 |
|
68 return green; |
|
69 } |
|
70 |
|
71 INLINE TInt Color64KBlue(TInt aColor64K) |
|
72 { |
|
73 TUint32 blue = (aColor64K>>KColor64KBlueShift) & KColor64KBlueMax; |
|
74 |
|
75 blue = (blue << 3) + (blue >> 2); |
|
76 |
|
77 ASSERT(blue <= 255); |
|
78 |
|
79 return blue; |
|
80 } |
|
81 |
|
82 INLINE TUint16 Color64K(TInt aRed, TInt aGreen, TInt aBlue) |
|
83 { |
|
84 TUint16 r = (aRed & 0xf8) << 8; |
|
85 TUint16 g = (aGreen & 0xfc) << 3; |
|
86 TUint16 b = (aBlue & 0xf8) >> 3; |
|
87 |
|
88 ASSERT((r & (KColor64KGreenMask|KColor64KBlueMask)) == 0); |
|
89 ASSERT((g & (KColor64KRedMask |KColor64KBlueMask)) == 0); |
|
90 ASSERT((b & (KColor64KRedMask |KColor64KGreenMask)) == 0); |
|
91 |
|
92 return (r | g | b); |
|
93 } |
|
94 |
|
95 INLINE TUint16 ARGB8888ToColor64K(TUint32 aPixel) |
|
96 { |
|
97 return ((aPixel >> 8) & 0xf800)| // 5 // 23,16 -> 15,11 |
|
98 ((aPixel >> 5) & 0x07E0)| // 6 // 15,8 -> 10,5 |
|
99 ((aPixel >> 3) & 0x001F); // 5 |
|
100 } |
|
101 |
|
102 LOCAL_C INLINE TUint32 Color64KForward(TUint32 aRGB) |
|
103 { |
|
104 return ARGB8888ToColor64K(aRGB); |
|
105 } |
|
106 |
|
107 LOCAL_C INLINE TUint32 Color64KReverse(TUint32 aColor64K) |
|
108 { |
|
109 return (Color64KRed(aColor64K)<<16)|(Color64KGreen(aColor64K)<<8)|(Color64KBlue(aColor64K)); |
|
110 } |
|
111 |
|
112 LOCAL_C INLINE TUint32 Color64KQuantize(TUint32 aRGB) |
|
113 { |
|
114 return Color64KReverse(Color64KForward(aRGB)); |
|
115 } |
|
116 |
|
117 // |
|
118 // Renderers |
|
119 // |
|
120 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
121 LOCAL_C void DrawImageColor64KAlphaToColor64K |
|
122 ( |
|
123 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
124 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
125 const TRect& aDstRect, // must be clipped to destination |
|
126 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
127 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // alpha |
|
128 const TLcdTransform& aTransform // includes anchor |
|
129 ); |
|
130 LOCAL_C void DrawRegionColor64KAlphaToColor64K |
|
131 ( |
|
132 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
133 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
134 const TRect& aDstRect, // must be clipped to destination |
|
135 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
136 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
137 const TLcdTransform& aTransform // includes anchor |
|
138 ); |
|
139 #endif |
|
140 |
|
141 |
|
142 LOCAL_C void DrawRegionARGB8888AlphaToColor64K |
|
143 ( |
|
144 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
145 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
146 const TRect& aDstRect, // must be clipped to destination |
|
147 const TAcceleratedBitmapInfo* aSrcColorBitmap, // ARGB8888 |
|
148 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // ignored |
|
149 const TLcdTransform& aTransform // includes anchor |
|
150 ); |
|
151 |
|
152 // |
|
153 // Blitters |
|
154 // |
|
155 |
|
156 LOCAL_C void BitBltColor64KToARGB8888 |
|
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 |
|
166 LOCAL_C void BitBltARGB8888ToColor64K |
|
167 ( |
|
168 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
169 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
170 const TRect& aDstRect, |
|
171 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
172 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
173 const TLcdTransform& aTransform |
|
174 ); |
|
175 |
|
176 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
177 LOCAL_C void BitBltARGB8888ToColor64KGray2 |
|
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 |
|
187 LOCAL_C void BitBltColor64KGray2ToARGB8888 |
|
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 #endif |
|
197 |
|
198 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
199 LOCAL_C void BitBltColor64KColor64KToARGB8888 |
|
200 ( |
|
201 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
202 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
203 const TRect& aDstRect, |
|
204 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
205 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
206 const TLcdTransform& aTransform |
|
207 ); |
|
208 |
|
209 LOCAL_C void BitBltARGB8888ToColor64KColor64K |
|
210 ( |
|
211 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
212 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
213 const TRect& aDstRect, |
|
214 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
215 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
216 const TLcdTransform& aTransform |
|
217 ); |
|
218 #endif |
|
219 |
|
220 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
221 LOCAL_C void BitBltColor64KGray256ToARGB8888 |
|
222 ( |
|
223 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
224 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
225 const TRect& aDstRect, |
|
226 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
227 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
228 const TLcdTransform& aTransform |
|
229 ); |
|
230 LOCAL_C void BitBltARGB8888ToColor64KGray256 |
|
231 ( |
|
232 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
233 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
234 const TRect& aDstRect, |
|
235 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
236 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
237 const TLcdTransform& aTransform |
|
238 ); |
|
239 #endif |
|
240 |
|
241 // |
|
242 // Supported image types. |
|
243 // |
|
244 #define COLOR64K_OPAQUE IMAGE_TYPE(EColor64K,ENone,ETransparencyNone) |
|
245 #define COLOR64K_MASK_1BPP IMAGE_TYPE(EColor64K,EGray2,ETransparencyMaskBitmap) |
|
246 #define COLOR64K_MASK_MATCHED IMAGE_TYPE(EColor64K,EColor64K,ETransparencyMaskBitmap) |
|
247 #define COLOR64K_ALPHA IMAGE_TYPE(EColor64K,EGray256,ETransparencyAlphaBitmap) |
|
248 |
|
249 // |
|
250 // General transforming blitters. |
|
251 // |
|
252 const TImageRenderer ImageRendererArray[] = |
|
253 { |
|
254 // |
|
255 // SrcOver |
|
256 // |
|
257 /* target, source, transform mask, function */ |
|
258 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
259 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_ALPHA, KTransSimpleMask, DrawImageColor64KAlphaToColor64K), |
|
260 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_ALPHA, KTransAllMask, DrawRegionColor64KAlphaToColor64K), |
|
261 #endif |
|
262 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_OPAQUE, KTransSimpleMask, BitBltSixteenBppSimple), |
|
263 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_OPAQUE, KTransAllMask, BitBltSixteenBpp), |
|
264 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
265 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_MASK_1BPP, KTransNoneMask, DrawImage16Bpp1BppTo16BppOpaque), |
|
266 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_MASK_1BPP, KTransAllMask, DrawRegion16Bpp1BppTo16BppOpaque), |
|
267 #endif |
|
268 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
269 RENDER_ENTRY(COLOR64K_OPAQUE, COLOR64K_MASK_MATCHED, KTransAllMask, DrawRegion16Bpp16BppTo16BppOpaque), |
|
270 #endif |
|
271 RENDER_ENTRY(COLOR64K_OPAQUE, JAVA_OPAQUE_IMAGE, KTransAllMask, BitBltARGB8888ToColor64K), |
|
272 RENDER_ENTRY(COLOR64K_OPAQUE, JAVA_ALPHA_IMAGE, KTransAllMask, DrawRegionARGB8888AlphaToColor64K), |
|
273 |
|
274 // |
|
275 // SrcCopy |
|
276 // |
|
277 /* target, source, function */ |
|
278 SIMPLE_BLITTER_ENTRY(COLOR64K_OPAQUE, COLOR64K_OPAQUE, BitBltSixteenBppSimple), |
|
279 BLITTER_ENTRY(COLOR64K_OPAQUE, COLOR64K_OPAQUE, BitBltSixteenBpp), |
|
280 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR64K_OPAQUE, BitBltColor64KToARGB8888), |
|
281 BLITTER_ENTRY(COLOR64K_OPAQUE, JAVA_OPAQUE_IMAGE, BitBltARGB8888ToColor64K), |
|
282 BLITTER_ENTRY(JAVA_OPAQUE_IMAGE, COLOR64K_OPAQUE, BitBltColor64KToARGB8888), |
|
283 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
284 BLITTER_ENTRY(COLOR64K_MASK_1BPP, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor64KGray2), |
|
285 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR64K_MASK_1BPP, BitBltColor64KGray2ToARGB8888), |
|
286 BLITTER_ENTRY(COLOR64K_MASK_1BPP, COLOR64K_MASK_1BPP, BitBltSixteenBppOneBpp), |
|
287 #endif |
|
288 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
289 BLITTER_ENTRY(COLOR64K_MASK_MATCHED, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor64KColor64K), |
|
290 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR64K_MASK_MATCHED, BitBltColor64KColor64KToARGB8888), |
|
291 BLITTER_ENTRY(COLOR64K_MASK_MATCHED, COLOR64K_MASK_MATCHED, BitBltSixteenBppSixteenBpp), |
|
292 #endif |
|
293 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
294 BLITTER_ENTRY(COLOR64K_ALPHA, JAVA_ALPHA_IMAGE, BitBltARGB8888ToColor64KGray256), |
|
295 BLITTER_ENTRY(JAVA_ALPHA_IMAGE, COLOR64K_ALPHA, BitBltColor64KGray256ToARGB8888), |
|
296 BLITTER_ENTRY(COLOR64K_ALPHA, COLOR64K_ALPHA, BitBltSixteenBppEightBpp), |
|
297 #endif |
|
298 }; |
|
299 const TInt ImageRendererCount = sizeof(ImageRendererArray)/sizeof(ImageRendererArray[0]); |
|
300 |
|
301 const TCollisionDetector CollisionDetectorArray[] = |
|
302 { |
|
303 // |
|
304 // Supported collision detectors. |
|
305 // |
|
306 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray2Gray2), |
|
307 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, ENoneBit,ETransparencyNoneBit, DetectCollisionGray2Gray2), |
|
308 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray2Gray2), |
|
309 |
|
310 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
311 COLLISION_DETECTOR_ENTRY(ENoneBit,ETransparencyNoneBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray256Gray256), |
|
312 COLLISION_DETECTOR_ENTRY(EGray2Bit,ETransparencyMaskBitmapBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray2Gray256), |
|
313 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, EGray2Bit,ETransparencyMaskBitmapBit, DetectCollisionGray256Gray2), |
|
314 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, ENoneBit,ETransparencyNoneBit, DetectCollisionGray256Gray256), |
|
315 COLLISION_DETECTOR_ENTRY(EGray256Bit,ETransparencyAlphaBitmapBit, EGray256Bit,ETransparencyAlphaBitmapBit, DetectCollisionGray256Gray256), |
|
316 #endif |
|
317 |
|
318 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
319 COLLISION_DETECTOR_ENTRY(KGenericModesMask,KGenericTransMask, KGenericModesMask,KGenericTransMask, GenericDetectCollision), |
|
320 #endif |
|
321 |
|
322 }; |
|
323 const TInt CollisionDetectorCount = sizeof(CollisionDetectorArray)/sizeof(CollisionDetectorArray[0]); |
|
324 |
|
325 const TColorMap ColorMapArray[] = |
|
326 { |
|
327 { EColor64K, Color64KForward, Color64KReverse, Color64KQuantize } |
|
328 }; |
|
329 const TInt ColorMapCount = sizeof(ColorMapArray)/sizeof(ColorMapArray[0]); |
|
330 |
|
331 |
|
332 const TDrawFunctions DrawFunctionsArray[] = |
|
333 { |
|
334 { |
|
335 EColor64K, |
|
336 CLcdGraphicsDevice::ECapFillTriangle, |
|
337 NULL, // drawLine |
|
338 NULL, // drawRect |
|
339 NULL, // fillRect |
|
340 NULL, // drawArc |
|
341 NULL, // fillArc |
|
342 &FillTriangle16Bpp, |
|
343 NULL // drawText |
|
344 } |
|
345 }; |
|
346 const TInt DrawFunctionsCount = sizeof(DrawFunctionsArray)/sizeof(DrawFunctionsArray[0]); |
|
347 |
|
348 // |
|
349 // Build number of this DLL. |
|
350 // |
|
351 const TInt KVersionBuild = 0; |
|
352 |
|
353 _LIT(KProviderSymbianSoftwareLtd, "Symbian Software Ltd"); |
|
354 |
|
355 LOCAL_C CLcdGraphicsDriverImpl* CreateColor64KDriverL(); |
|
356 |
|
357 // |
|
358 // Could support more than one implementation |
|
359 // |
|
360 const TImplementationProxy ImplementationTable[] = |
|
361 { |
|
362 IMPLEMENTATION_PROXY_ENTRY(LCDGD_COLOR64K_IMPLEMENTATION_UID, CreateColor64KDriverL) |
|
363 }; |
|
364 |
|
365 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
366 { |
|
367 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
368 return ImplementationTable; |
|
369 } |
|
370 |
|
371 CLcdGraphicsDriverImpl* CreateColor64KDriverL() |
|
372 { |
|
373 CLcdGraphicsDriver::TDriverInfo driverInfo; |
|
374 |
|
375 driverInfo.iVersion = TVersion(KLcdImgVersionMajor, KLcdImgVersionMinor, KVersionBuild); |
|
376 driverInfo.iProvider = KProviderSymbianSoftwareLtd; |
|
377 driverInfo.iTransparencyCaps = CAP_1BPP_MASK_BITMAP|CAP_MATCHED_MASK_BITMAP|CAP_ALPHA_BITMAP; |
|
378 driverInfo.iARGB8888Mode = EColorARGB8888; |
|
379 driverInfo.iDisplayMode = EColor64K; |
|
380 |
|
381 return new(ELeave) CLcdGraphicsDriverImpl |
|
382 ( |
|
383 driverInfo, |
|
384 ImageRendererArray, |
|
385 ImageRendererCount, |
|
386 ColorMapArray, |
|
387 ColorMapCount, |
|
388 CollisionDetectorArray, |
|
389 CollisionDetectorCount, |
|
390 DrawFunctionsArray, |
|
391 DrawFunctionsCount |
|
392 ); |
|
393 } |
|
394 |
|
395 // *********************************************************** |
|
396 // Render (SrcOver) routines |
|
397 // *********************************************************** |
|
398 |
|
399 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
400 LOCAL_C void BlitLineColor64KAlphaToColor64KNoTrans |
|
401 ( |
|
402 TUint8* aDstAddress, |
|
403 TInt aWidth, |
|
404 TUint8* aColorAddress, |
|
405 TInt DEBUG_ONLY(aColorPixelPitch), |
|
406 TUint8* aAlphaAddress, |
|
407 TInt DEBUG_ONLY(aAlphaPixelPitch) |
|
408 ) |
|
409 { |
|
410 ASSERT(aColorPixelPitch == sizeof(TUint16)); |
|
411 ASSERT(aAlphaPixelPitch == sizeof(TUint8)); |
|
412 |
|
413 TUint16* dst = (TUint16*)aDstAddress; |
|
414 TUint16* end = dst + aWidth; |
|
415 |
|
416 TUint16* colorAddr = (TUint16*)aColorAddress; |
|
417 TUint8* alphaAddr = aAlphaAddress; |
|
418 |
|
419 while (dst < end) |
|
420 { |
|
421 TUint alpha = *alphaAddr++; |
|
422 if (alpha == 0xFF) |
|
423 { |
|
424 *dst = *colorAddr; |
|
425 } |
|
426 else |
|
427 { |
|
428 if (alpha) |
|
429 { |
|
430 TUint16 dstColor = *dst; |
|
431 TUint16 srcColor = *(TUint16*)colorAddr; |
|
432 |
|
433 alpha = (alpha << 8) | alpha; |
|
434 |
|
435 TUint32 dr = Blend16(alpha, Color64KRed(srcColor), Color64KRed(dstColor)); |
|
436 TUint32 dg = Blend16(alpha, Color64KGreen(srcColor), Color64KGreen(dstColor)); |
|
437 TUint32 db = Blend16(alpha, Color64KBlue(srcColor), Color64KBlue(dstColor)); |
|
438 |
|
439 ASSERT(dr <= 255); |
|
440 ASSERT(dg <= 255); |
|
441 ASSERT(db <= 255); |
|
442 |
|
443 // map back to Color64K |
|
444 *dst = Color64K(dr, dg, db); |
|
445 } |
|
446 } |
|
447 dst++; |
|
448 colorAddr++; |
|
449 } |
|
450 } |
|
451 |
|
452 LOCAL_C void DrawImageColor64KAlphaToColor64K |
|
453 ( |
|
454 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
455 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
456 const TRect& aDstRect, // must be clipped to destination |
|
457 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
458 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // alpha |
|
459 const TLcdTransform& aTransform // includes anchor |
|
460 ) |
|
461 { |
|
462 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
463 ASSERT(aSrcColorBitmap->iDisplayMode == EColor64K); |
|
464 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
465 |
|
466 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
467 aSrcAlphaBitmap, ETrue, BlitLineColor64KAlphaToColor64KNoTrans); |
|
468 } |
|
469 |
|
470 LOCAL_C void BlitLineColor64KAlphaToColor64K |
|
471 ( |
|
472 TUint8* aDstAddress, |
|
473 TInt aWidth, |
|
474 TUint8* aColorAddress, |
|
475 TInt aColorPixelPitch, |
|
476 TUint8* aAlphaAddress, |
|
477 TInt aAlphaPixelPitch |
|
478 ) |
|
479 { |
|
480 TUint16* dst = (TUint16*)(aDstAddress); |
|
481 TUint16* end = dst + aWidth; |
|
482 |
|
483 TUint8* colorAddr = aColorAddress; |
|
484 TUint8* alphaAddr = aAlphaAddress; |
|
485 |
|
486 while (dst < end) |
|
487 { |
|
488 TUint alpha = *alphaAddr; |
|
489 if (alpha == 0xFF) |
|
490 { |
|
491 *dst = *(TUint16*)colorAddr; |
|
492 } |
|
493 else |
|
494 { |
|
495 if (alpha) |
|
496 { |
|
497 TUint16 dstColor = *dst; |
|
498 TUint16 srcColor = *(TUint16*)colorAddr; |
|
499 |
|
500 alpha = (alpha << 8) | alpha; |
|
501 |
|
502 TUint32 dr = Blend16(alpha, Color64KRed(srcColor), Color64KRed(dstColor)); |
|
503 TUint32 dg = Blend16(alpha, Color64KGreen(srcColor), Color64KGreen(dstColor)); |
|
504 TUint32 db = Blend16(alpha, Color64KBlue(srcColor), Color64KBlue(dstColor)); |
|
505 |
|
506 ASSERT(dr <= 255); |
|
507 ASSERT(dg <= 255); |
|
508 ASSERT(db <= 255); |
|
509 |
|
510 // map back to Color64K |
|
511 *dst = Color64K(dr, dg, db); |
|
512 } |
|
513 } |
|
514 |
|
515 // Advance to next pixel in the line in each bitmap. |
|
516 ++dst; // TUint16* so adds two to the address. |
|
517 colorAddr += aColorPixelPitch; |
|
518 alphaAddr += aAlphaPixelPitch; |
|
519 } |
|
520 } |
|
521 |
|
522 LOCAL_C void DrawRegionColor64KAlphaToColor64K |
|
523 ( |
|
524 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
525 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
526 const TRect& aDstRect, // must be clipped to destination |
|
527 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
528 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, // alpha |
|
529 const TLcdTransform& aTransform // includes anchor |
|
530 ) |
|
531 { |
|
532 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
533 ASSERT(aSrcColorBitmap->iDisplayMode == EColor64K); |
|
534 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
535 |
|
536 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
537 aSrcAlphaBitmap, ETrue, BlitLineColor64KAlphaToColor64K); |
|
538 } |
|
539 #endif |
|
540 |
|
541 |
|
542 LOCAL_C void BlitLineARGB8888AlphaToColor64K |
|
543 ( |
|
544 TUint8* aDstAddress, |
|
545 TInt aWidth, |
|
546 TUint8* aColorAddress, |
|
547 TInt aColorPixelPitch |
|
548 ) |
|
549 { |
|
550 TUint16* dst = (TUint16*)(aDstAddress); |
|
551 TUint16* end = dst + aWidth; |
|
552 |
|
553 TUint8* colorAddr = aColorAddress; |
|
554 |
|
555 while (dst < end) |
|
556 { |
|
557 TUint32 argb = *(TUint32*)colorAddr; |
|
558 TInt alpha = argb>>24; |
|
559 if (alpha == 0xFF) |
|
560 { |
|
561 // Trivial case: opaque |
|
562 *dst = ARGB8888ToColor64K(argb); |
|
563 } |
|
564 else |
|
565 { |
|
566 // Check for the other trivial case: clear |
|
567 if (alpha) |
|
568 { |
|
569 TUint16 dstColor = *dst; |
|
570 |
|
571 alpha = (alpha << 8) | alpha; |
|
572 |
|
573 TUint32 dr = Blend16(alpha, ((argb>>16)&0xff), Color64KRed(dstColor)); |
|
574 TUint32 dg = Blend16(alpha, ((argb>>8)&0xff), Color64KGreen(dstColor)); |
|
575 TUint32 db = Blend16(alpha, (argb&0xff), Color64KBlue(dstColor)); |
|
576 |
|
577 ASSERT(dr <= 255); |
|
578 ASSERT(dg <= 255); |
|
579 ASSERT(db <= 255); |
|
580 |
|
581 *dst = Color64K(dr, dg, db); |
|
582 } |
|
583 } |
|
584 dst++; |
|
585 colorAddr += aColorPixelPitch; |
|
586 } |
|
587 } |
|
588 |
|
589 LOCAL_C void DrawRegionARGB8888AlphaToColor64K |
|
590 ( |
|
591 const TAcceleratedBitmapInfo* aDstColorBitmap, // |
|
592 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
593 const TRect& aDstRect, // must be clipped to destination |
|
594 const TAcceleratedBitmapInfo* aSrcColorBitmap, // ARGB8888 |
|
595 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // ignored |
|
596 const TLcdTransform& aTransform // includes anchor |
|
597 ) |
|
598 { |
|
599 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
600 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
601 |
|
602 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
603 BlitLineARGB8888AlphaToColor64K); |
|
604 } |
|
605 |
|
606 // *********************************************************** |
|
607 // Blitter (SrcCopy) functions. |
|
608 // *********************************************************** |
|
609 |
|
610 LOCAL_C void BlitLineColor64KToARGB8888 |
|
611 ( |
|
612 TUint8* aDstAddress, |
|
613 TInt aWidth, |
|
614 TUint8* aColorAddress, |
|
615 TInt aColorPixelPitch |
|
616 ) |
|
617 { |
|
618 TUint32* dst = (TUint32*)(aDstAddress); |
|
619 TUint32* end = dst + aWidth; |
|
620 |
|
621 TUint8* colorAddr = aColorAddress; |
|
622 |
|
623 while (dst < end) |
|
624 { |
|
625 *dst++ = Color64KReverse(*(TUint16*)colorAddr) | 0xFF000000; |
|
626 colorAddr += aColorPixelPitch; |
|
627 } |
|
628 } |
|
629 |
|
630 // |
|
631 // Color64K -> ARGB8888 |
|
632 // |
|
633 LOCAL_C void BitBltColor64KToARGB8888 |
|
634 ( |
|
635 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
636 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, // NULL |
|
637 const TRect& aDstRect, |
|
638 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
639 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, // NULL |
|
640 const TLcdTransform& aTransform |
|
641 ) |
|
642 { |
|
643 ASSERT(aDstColorBitmap); |
|
644 ASSERT(aSrcColorBitmap); |
|
645 |
|
646 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
647 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
648 |
|
649 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
650 ASSERT(aSrcColorBitmap->iDisplayMode == EColor64K); |
|
651 |
|
652 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
653 BlitLineColor64KToARGB8888); |
|
654 } |
|
655 |
|
656 LOCAL_C void BlitLineARGB8888OpaqueToColor64K |
|
657 ( |
|
658 TUint8* aDstAddress, |
|
659 TInt aWidth, |
|
660 TUint8* aColorAddress, |
|
661 TInt aColorPixelPitch |
|
662 ) |
|
663 { |
|
664 TUint16* dst = (TUint16*)(aDstAddress); |
|
665 TUint16* end = dst + aWidth; |
|
666 |
|
667 TUint8* colorAddr = aColorAddress; |
|
668 |
|
669 while (dst < end) |
|
670 { |
|
671 *dst++ = ARGB8888ToColor64K(*(TUint32*)colorAddr); |
|
672 colorAddr += aColorPixelPitch; |
|
673 } |
|
674 } |
|
675 |
|
676 // |
|
677 // ARGB8888 -> Color64K |
|
678 // |
|
679 LOCAL_C void BitBltARGB8888ToColor64K |
|
680 ( |
|
681 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
682 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
683 const TRect& aDstRect, |
|
684 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
685 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
686 const TLcdTransform& aTransform |
|
687 ) |
|
688 { |
|
689 ASSERT(aDstColorBitmap); |
|
690 ASSERT(aSrcColorBitmap); |
|
691 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
692 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
693 |
|
694 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
695 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
696 |
|
697 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
698 BlitLineARGB8888OpaqueToColor64K); |
|
699 } |
|
700 |
|
701 #ifdef LCDGD_SUPPORT_1BPP_MASK_BITMAP |
|
702 // |
|
703 // Color64K, Gray2 -> ARGB8888 |
|
704 // |
|
705 // Very slow. Would be better to iterate over source rectangle as this |
|
706 // would allow multi-pixel mask reads. Alternatively just implemement |
|
707 // the simple no-transform or vert reflection only case. |
|
708 // |
|
709 LOCAL_C void BitBltColor64KGray2ToARGB8888 |
|
710 ( |
|
711 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
712 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
713 const TRect& aDstRect, |
|
714 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
715 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
716 const TLcdTransform& aTransform |
|
717 ) |
|
718 { |
|
719 ASSERT(aDstColorBitmap); |
|
720 ASSERT(aSrcColorBitmap); |
|
721 ASSERT(aSrcAlphaBitmap); |
|
722 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
723 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
724 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
725 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
726 ASSERT(aSrcColorBitmap->iDisplayMode == EColor64K); |
|
727 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray2); |
|
728 |
|
729 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
730 |
|
731 TInt dudx = aTransform.iDuDx; |
|
732 TInt dudy = aTransform.iDuDy; |
|
733 TInt dvdx = aTransform.iDvDx; |
|
734 TInt dvdy = aTransform.iDvDy; |
|
735 TInt u0 = srcPoint.iX; |
|
736 TInt v0 = srcPoint.iY; |
|
737 TInt u = u0; |
|
738 TInt v = v0; |
|
739 |
|
740 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
741 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
742 TUint8* mskAddress = aSrcAlphaBitmap->iAddress; |
|
743 |
|
744 TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
745 TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
746 TInt mskLinePitch = aSrcAlphaBitmap->iLinePitch; |
|
747 |
|
748 #ifdef _DEBUG |
|
749 const TSize srcSize = aSrcColorBitmap->iSize; |
|
750 const TUint8* srcBeg = srcAddress; |
|
751 const TUint8* srcEnd = srcAddress + srcLinePitch*(srcSize.iHeight - 1) + (srcSize.iWidth-1)*sizeof(TUint16); |
|
752 |
|
753 const TUint8* mskBeg = mskAddress; |
|
754 const TUint8* mskEnd = mskAddress + mskLinePitch*(srcSize.iHeight - 1) + ((srcSize.iWidth-1)>>3); |
|
755 |
|
756 const TSize dstSize = aDstColorBitmap->iSize; |
|
757 const TUint32* dstBeg = (TUint32*)dstAddress; |
|
758 const TUint32* dstEnd = (TUint32*)(dstAddress + dstLinePitch*(dstSize.iHeight - 1) + (dstSize.iWidth-1)*sizeof(TUint32)); |
|
759 #endif |
|
760 |
|
761 dstAddress += dstLinePitch*aDstRect.iTl.iY; |
|
762 dstAddress += aDstRect.iTl.iX*sizeof(TUint32); |
|
763 |
|
764 TInt height = aDstRect.Height(); |
|
765 TInt width = aDstRect.Width(); |
|
766 for (; height>0; --height) |
|
767 { |
|
768 TUint32* dst = (TUint32*)dstAddress; |
|
769 TUint32* end = dst + width; |
|
770 |
|
771 u=u0; |
|
772 v=v0; |
|
773 while (dst < end) |
|
774 { |
|
775 TUint8* src = srcAddress + v*srcLinePitch + u*sizeof(TUint16); |
|
776 TUint8* msk = mskAddress + v*mskLinePitch + (u>>3); |
|
777 |
|
778 #ifdef _DEBUG |
|
779 ASSERT(srcBeg <= src && src <= srcEnd); |
|
780 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
781 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
782 #endif |
|
783 |
|
784 TUint16 spix = *(TUint16*)src; |
|
785 TUint8 smsk = *msk; |
|
786 TUint32 dpix = (smsk & 1<<(u&0x7))?0xff000000:0; |
|
787 |
|
788 dpix |= Color64KRed(spix) << 16; |
|
789 dpix |= Color64KGreen(spix) << 8; |
|
790 dpix |= Color64KBlue(spix); |
|
791 *dst++ = dpix; |
|
792 u+=dudx; |
|
793 v+=dvdx; |
|
794 } |
|
795 u0+=dudy; |
|
796 v0+=dvdy; |
|
797 dstAddress += dstLinePitch; |
|
798 } |
|
799 } |
|
800 |
|
801 // |
|
802 // ARGB8888 -> Color64K, Gray2 |
|
803 // |
|
804 LOCAL_C void BitBltARGB8888ToColor64KGray2 |
|
805 ( |
|
806 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
807 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
808 const TRect& aDstRect, |
|
809 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
810 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
811 const TLcdTransform& aTransform |
|
812 ) |
|
813 { |
|
814 ASSERT(aDstColorBitmap); |
|
815 ASSERT(aDstAlphaBitmap); |
|
816 ASSERT(aSrcColorBitmap); |
|
817 |
|
818 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
819 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
820 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
821 |
|
822 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
823 ASSERT(aDstAlphaBitmap->iDisplayMode == EGray2); |
|
824 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
825 |
|
826 TPoint srcPoint = aTransform(aDstRect.iTl); |
|
827 |
|
828 TInt dudx = aTransform.iDuDx; |
|
829 TInt dudy = aTransform.iDuDy; |
|
830 TInt dvdx = aTransform.iDvDx; |
|
831 TInt dvdy = aTransform.iDvDy; |
|
832 TInt u0 = srcPoint.iX; |
|
833 TInt v0 = srcPoint.iY; |
|
834 TInt u = u0; |
|
835 TInt v = v0; |
|
836 |
|
837 TUint8* srcAddress = aSrcColorBitmap->iAddress; |
|
838 TUint8* dstAddress = aDstColorBitmap->iAddress; |
|
839 TUint8* mskAddress = aDstAlphaBitmap->iAddress; |
|
840 |
|
841 TInt srcLinePitch = aSrcColorBitmap->iLinePitch; |
|
842 TInt dstLinePitch = aDstColorBitmap->iLinePitch; |
|
843 TInt mskLinePitch = aDstAlphaBitmap->iLinePitch; |
|
844 |
|
845 #ifdef _DEBUG |
|
846 const TSize srcSize = aSrcColorBitmap->iSize; |
|
847 const TUint32* srcBeg = (TUint32*)srcAddress; |
|
848 const TUint32* srcEnd = (TUint32*)(srcAddress + srcLinePitch*(srcSize.iHeight - 1) + (srcSize.iWidth-1)*sizeof(TUint32)); |
|
849 |
|
850 const TSize dstSize = aDstColorBitmap->iSize; |
|
851 const TUint16* dstBeg = (TUint16*)dstAddress; |
|
852 const TUint16* dstEnd = (TUint16*)(dstAddress + dstLinePitch*(dstSize.iHeight - 1) + (dstSize.iWidth-1)*sizeof(TUint16)); |
|
853 |
|
854 const TSize mskSize = aDstAlphaBitmap->iSize; |
|
855 const TUint8* mskBeg = mskAddress; |
|
856 const TUint8* mskEnd = mskAddress + mskLinePitch*(mskSize.iHeight-1) + ((mskSize.iWidth-1)>>3); |
|
857 #endif |
|
858 |
|
859 |
|
860 dstAddress += dstLinePitch*aDstRect.iTl.iY; |
|
861 dstAddress += aDstRect.iTl.iX*sizeof(TUint16); |
|
862 |
|
863 mskAddress += mskLinePitch*aDstRect.iTl.iY; |
|
864 mskAddress += (aDstRect.iTl.iX>>3); |
|
865 |
|
866 TInt height = aDstRect.Height(); |
|
867 TInt width = aDstRect.Width(); |
|
868 |
|
869 const TInt x0 = aDstRect.iTl.iX; |
|
870 const TInt x1 = Min((aDstRect.iTl.iX | 0x7)+1, aDstRect.iBr.iX); |
|
871 const TInt x2 = (aDstRect.iBr.iX & ~0x7); |
|
872 const TInt x3 = aDstRect.iBr.iX; |
|
873 |
|
874 for (; height>0; --height) |
|
875 { |
|
876 TUint16* dst = (TUint16*)dstAddress; |
|
877 TUint8* msk = mskAddress; |
|
878 |
|
879 #ifdef _DEBUG |
|
880 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
881 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
882 #endif |
|
883 |
|
884 TInt x; |
|
885 |
|
886 u=u0; |
|
887 v=v0; |
|
888 |
|
889 // |
|
890 // Leading mask byte |
|
891 // |
|
892 for (x = x0; x<x1; x++) |
|
893 { |
|
894 TUint32* src = (TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
895 |
|
896 #ifdef _DEBUG |
|
897 ASSERT(srcBeg <= src && src <= srcEnd); |
|
898 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
899 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
900 #endif |
|
901 |
|
902 TUint32 pixel = *src; |
|
903 TUint8 alpha = pixel>>24; |
|
904 |
|
905 TInt xBit = (1<<(x&0x7)); |
|
906 if (alpha == 0xff) |
|
907 { |
|
908 *msk |= xBit; |
|
909 } |
|
910 else |
|
911 { |
|
912 *msk &= ~xBit; |
|
913 } |
|
914 |
|
915 *dst++ = ARGB8888ToColor64K(pixel); |
|
916 u+=dudx; |
|
917 v+=dvdx; |
|
918 } |
|
919 ++msk; |
|
920 |
|
921 // |
|
922 // Middle section |
|
923 // |
|
924 for (ASSERT(x==x1); x<x2; x+=8) |
|
925 { |
|
926 TUint8 mask = 0; |
|
927 |
|
928 TUint16* end = dst + 8; |
|
929 TInt mbit = 1; |
|
930 while (dst < end) |
|
931 { |
|
932 TUint32* src = (TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
933 |
|
934 #ifdef _DEBUG |
|
935 ASSERT(srcBeg <= src && src <= srcEnd); |
|
936 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
937 #endif |
|
938 |
|
939 TUint32 pixel = *src; |
|
940 if ((pixel >> 24)==0xff) |
|
941 { |
|
942 mask |= mbit; |
|
943 } |
|
944 *dst++ = ARGB8888ToColor64K(pixel); |
|
945 mbit <<= 1; |
|
946 u+=dudx; |
|
947 v+=dvdx; |
|
948 } |
|
949 |
|
950 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
951 |
|
952 *msk++ = mask; |
|
953 } |
|
954 |
|
955 // |
|
956 // Trailing mask byte |
|
957 // |
|
958 for (ASSERT((x>=x2)&&(x<=x3)); x<x3; x++) |
|
959 { |
|
960 TUint32* src = (TUint32*)(srcAddress + v*srcLinePitch + u*sizeof(TUint32)); |
|
961 |
|
962 #ifdef _DEBUG |
|
963 ASSERT(srcBeg <= src && src <= srcEnd); |
|
964 ASSERT(dstBeg <= dst && dst <= dstEnd); |
|
965 ASSERT(mskBeg <= msk && msk <= mskEnd); |
|
966 #endif |
|
967 |
|
968 TUint32 pixel = *src; |
|
969 TUint8 alpha = pixel>>24; |
|
970 |
|
971 TInt xBit = (1<<(x&0x7)); |
|
972 if (alpha == 0xff) |
|
973 { |
|
974 *msk |= xBit; |
|
975 } |
|
976 else |
|
977 { |
|
978 *msk &= ~xBit; |
|
979 } |
|
980 |
|
981 *dst++ = ARGB8888ToColor64K(pixel); |
|
982 u+=dudx; |
|
983 v+=dvdx; |
|
984 } |
|
985 |
|
986 u0+=dudy; |
|
987 v0+=dvdy; |
|
988 dstAddress += dstLinePitch; |
|
989 mskAddress += mskLinePitch; |
|
990 } |
|
991 } |
|
992 #endif |
|
993 |
|
994 #ifdef LCDGD_SUPPORT_MATCHED_MASK_BITMAP |
|
995 LOCAL_C void BlitLineColor64KColor64KToARGB8888 |
|
996 ( |
|
997 TUint8* aDstAddress, |
|
998 TInt aWidth, |
|
999 TUint8* aColorAddress, |
|
1000 TInt aColorPixelPitch, |
|
1001 TUint8* aMaskAddress, |
|
1002 TInt aMaskPixelPitch |
|
1003 ) |
|
1004 { |
|
1005 TUint32* dst = (TUint32*)(aDstAddress); |
|
1006 TUint32* end = dst + aWidth; |
|
1007 |
|
1008 TUint8* colorAddr = aColorAddress; |
|
1009 TUint8* maskAddr = aMaskAddress; |
|
1010 |
|
1011 while (dst < end) |
|
1012 { |
|
1013 TUint16 smsk = *(TUint16*)maskAddr; |
|
1014 TUint16 spix = *(TUint16*)colorAddr; |
|
1015 |
|
1016 TUint32 dpix = (smsk << 24); // bottom 8 bits of smsk should all be 1 if opaque |
|
1017 ASSERT((smsk == 0) || (smsk == 0xffff)); |
|
1018 dpix |= Color64KRed(spix) << 16; |
|
1019 dpix |= Color64KGreen(spix) << 8; |
|
1020 dpix |= Color64KBlue(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 // |
|
1031 // |
|
1032 LOCAL_C void BitBltColor64KColor64KToARGB8888 |
|
1033 ( |
|
1034 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
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 == EColor64K); |
|
1050 ASSERT(aSrcAlphaBitmap->iDisplayMode == EColor64K); |
|
1051 |
|
1052 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1053 aSrcAlphaBitmap, ETrue, BlitLineColor64KColor64KToARGB8888); |
|
1054 } |
|
1055 |
|
1056 LOCAL_C void BlitLineARGB8888ToColor64KColor64K |
|
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 TUint16* maskAddr = aMaskAddress; |
|
1071 |
|
1072 ASSERT(aMaskPixelPitch == sizeof(TUint16)); |
|
1073 UNUSED(aMaskPixelPitch); // ASSERT is the only use otherwise. |
|
1074 |
|
1075 while (dst < end) |
|
1076 { |
|
1077 TUint32 pixel = *(TUint32*)colorAddr; |
|
1078 *dst++ = (TUint16)ARGB8888ToColor64K(pixel); |
|
1079 *maskAddr++ = (TUint16)(((pixel >> 24) == 0xff) ? -1 : 0); |
|
1080 |
|
1081 // Advance to next pixel in the line in each bitmap. |
|
1082 colorAddr += aColorPixelPitch; |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 // |
|
1087 // |
|
1088 // |
|
1089 LOCAL_C void BitBltARGB8888ToColor64KColor64K |
|
1090 ( |
|
1091 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
1092 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
1093 const TRect& aDstRect, |
|
1094 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1095 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
1096 const TLcdTransform& aTransform |
|
1097 ) |
|
1098 { |
|
1099 ASSERT(aDstColorBitmap); |
|
1100 ASSERT(aDstAlphaBitmap); |
|
1101 ASSERT(aSrcColorBitmap); |
|
1102 |
|
1103 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1104 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
1105 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1106 |
|
1107 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
1108 ASSERT(aDstAlphaBitmap->iDisplayMode == EColor64K); |
|
1109 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
1110 |
|
1111 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1112 aDstAlphaBitmap, EFalse, BlitLineARGB8888ToColor64KColor64K); |
|
1113 } |
|
1114 #endif |
|
1115 |
|
1116 #ifdef LCDGD_SUPPORT_ALPHA_BITMAP |
|
1117 LOCAL_C void BlitLineColor64KGray256ToARGB8888 |
|
1118 ( |
|
1119 TUint8* aDstAddress, |
|
1120 TInt aWidth, |
|
1121 TUint8* aColorAddress, |
|
1122 TInt aColorPixelPitch, |
|
1123 TUint8* aMaskAddress, |
|
1124 TInt aMaskPixelPitch |
|
1125 ) |
|
1126 { |
|
1127 TUint32* dst = (TUint32*)(aDstAddress); |
|
1128 TUint32* end = dst + aWidth; |
|
1129 |
|
1130 TUint8* colorAddr = aColorAddress; |
|
1131 TUint8* maskAddr = aMaskAddress; |
|
1132 |
|
1133 while (dst < end) |
|
1134 { |
|
1135 TUint16 spix = *(TUint16*)colorAddr; |
|
1136 TUint32 dpix = *maskAddr << 24; |
|
1137 |
|
1138 dpix |= Color64KRed(spix) << 16; |
|
1139 dpix |= Color64KGreen(spix) << 8; |
|
1140 dpix |= Color64KBlue(spix); |
|
1141 *dst++ = dpix; |
|
1142 |
|
1143 // Advance to next pixel in the line in each bitmap. |
|
1144 colorAddr += aColorPixelPitch; |
|
1145 maskAddr += aMaskPixelPitch; |
|
1146 } |
|
1147 } |
|
1148 |
|
1149 // |
|
1150 // Color64K, Gray256 -> ARGB8888 |
|
1151 // |
|
1152 LOCAL_C void BitBltColor64KGray256ToARGB8888 |
|
1153 ( |
|
1154 const TAcceleratedBitmapInfo* aDstColorBitmap, // ARGB32 array |
|
1155 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
1156 const TRect& aDstRect, |
|
1157 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1158 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
1159 const TLcdTransform& aTransform |
|
1160 ) |
|
1161 { |
|
1162 ASSERT(aDstColorBitmap); |
|
1163 ASSERT(aSrcColorBitmap); |
|
1164 ASSERT(aSrcAlphaBitmap); |
|
1165 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1166 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1167 ASSERT(aSrcAlphaBitmap->iAddress != NULL); |
|
1168 ASSERT(aDstColorBitmap->iDisplayMode == EColorARGB8888); |
|
1169 ASSERT(aSrcColorBitmap->iDisplayMode == EColor64K); |
|
1170 ASSERT(aSrcAlphaBitmap->iDisplayMode == EGray256); |
|
1171 |
|
1172 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1173 aSrcAlphaBitmap, ETrue, BlitLineColor64KGray256ToARGB8888); |
|
1174 } |
|
1175 |
|
1176 LOCAL_C void BlitLineARGB8888ToColor64KGray256 |
|
1177 ( |
|
1178 TUint8* aDstAddress, |
|
1179 TInt aWidth, |
|
1180 TUint8* aColorAddress, |
|
1181 TInt aColorPixelPitch, |
|
1182 TUint8* aMaskAddress, |
|
1183 TInt aMaskPixelPitch |
|
1184 ) |
|
1185 { |
|
1186 TUint16* dst = (TUint16*)(aDstAddress); |
|
1187 TUint16* end = dst + aWidth; |
|
1188 |
|
1189 TUint8* colorAddr = aColorAddress; |
|
1190 TUint8* maskAddr = aMaskAddress; |
|
1191 |
|
1192 ASSERT(aMaskPixelPitch == sizeof(TUint8)); |
|
1193 UNUSED(aMaskPixelPitch); // ASSERT is the only use otherwise. |
|
1194 |
|
1195 while (dst < end) |
|
1196 { |
|
1197 TUint32 pixel = *(TUint32*)colorAddr; |
|
1198 *dst++ = (TUint16)ARGB8888ToColor64K(pixel); |
|
1199 *maskAddr++ = pixel >> 24; |
|
1200 |
|
1201 // Advance to next pixel in the line in each bitmap. |
|
1202 colorAddr += aColorPixelPitch; |
|
1203 } |
|
1204 } |
|
1205 |
|
1206 // |
|
1207 // ARGB8888 -> Color64K, Gray256 |
|
1208 // |
|
1209 LOCAL_C void BitBltARGB8888ToColor64KGray256 |
|
1210 ( |
|
1211 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
1212 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
1213 const TRect& aDstRect, |
|
1214 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
1215 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
1216 const TLcdTransform& aTransform |
|
1217 ) |
|
1218 { |
|
1219 ASSERT(aDstColorBitmap); |
|
1220 ASSERT(aDstAlphaBitmap); |
|
1221 ASSERT(aSrcColorBitmap); |
|
1222 |
|
1223 ASSERT(aDstColorBitmap->iAddress != NULL); |
|
1224 ASSERT(aDstAlphaBitmap->iAddress != NULL); |
|
1225 ASSERT(aSrcColorBitmap->iAddress != NULL); |
|
1226 |
|
1227 ASSERT(aDstColorBitmap->iDisplayMode == EColor64K); |
|
1228 ASSERT(aDstAlphaBitmap->iDisplayMode == EGray256); |
|
1229 ASSERT(aSrcColorBitmap->iDisplayMode == EColorARGB8888); |
|
1230 |
|
1231 GenericMaskBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
1232 aDstAlphaBitmap, EFalse, BlitLineARGB8888ToColor64KGray256); |
|
1233 } |
|
1234 #endif |
|
1235 |