|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "BMDRAW.H" |
|
17 #include "BitDrawInterfaceId.h" |
|
18 #include <graphics/lookuptable.h> |
|
19 |
|
20 #if defined(SYMBIAN_USE_FAST_FADING) |
|
21 // 16bpp fast fade - half the contrast and brighten |
|
22 const TInt K16bppFastFadeShift = 1; |
|
23 const TUint16 K16bppFastFadeMask = 0x8410; |
|
24 // Use the 32 -> 16 bit colour convesrion method to get |
|
25 // the 16 bit fading constant (K16bppFastFadeOffset) |
|
26 // from 32 bit fading constant (SYMBIAN_USE_FAST_FADING). |
|
27 const TUint16 K16bppFastFadeOffset = ((SYMBIAN_USE_FAST_FADING & 0x0000f8) >> 3) | |
|
28 ((SYMBIAN_USE_FAST_FADING & 0x00fc00) >> 5) | |
|
29 ((SYMBIAN_USE_FAST_FADING & 0xf80000) >> 8); |
|
30 #endif |
|
31 |
|
32 // CDrawSixteenBppBitmapCommon |
|
33 |
|
34 //Initializes iSize, iDrawRect, iLongWidth, iScanlineWords data members. |
|
35 //It should be called every time when iSize is going to be changed - from Construct(). |
|
36 //@param aSize Physical screen size in pixels. |
|
37 //@panic EScreenDriverPanicInvalidSize - Invalid aSize parameter. This might happen if the |
|
38 //device is scaled and the scaling origin goes outside physical drawing rectangle. |
|
39 void CDrawSixteenBppBitmapCommon::SetSize(const TSize& aSize) |
|
40 { |
|
41 CDrawBitmap::SetSize(aSize); |
|
42 __ASSERT_DEBUG(iSize == aSize, User::Invariant()); |
|
43 iLongWidth = (iSize.iWidth + 1) & ~1; |
|
44 iScanLineWords = iLongWidth >> 1; |
|
45 } |
|
46 |
|
47 TInt CDrawSixteenBppBitmapCommon::Construct(TSize aSize, TInt aStride) |
|
48 { |
|
49 iBits = NULL; |
|
50 CDrawBitmap::SetSize(aSize); |
|
51 __ASSERT_DEBUG(iSize == aSize, User::Invariant()); |
|
52 if (aStride & 3) |
|
53 return KErrArgument; |
|
54 iLongWidth = aStride >> 1; |
|
55 if (iLongWidth < aSize.iWidth) |
|
56 return KErrArgument; |
|
57 iScanLineWords = aStride >> 2; |
|
58 TInt size = Max(aSize.iWidth,aSize.iHeight) << 1; |
|
59 if(size < 0) |
|
60 return KErrArgument; |
|
61 iScanLineBuffer = (TUint32*)(User::Heap().Alloc(size)); |
|
62 if (iScanLineBuffer == NULL) |
|
63 return KErrNoMemory; |
|
64 return KErrNone; |
|
65 } |
|
66 |
|
67 TUint16* CDrawSixteenBppBitmapCommon::PixelAddress(TInt aX,TInt aY) const |
|
68 { |
|
69 return(((TUint16*)iBits) + (aY * iLongWidth) + aX); |
|
70 } |
|
71 |
|
72 void CDrawSixteenBppBitmapCommon::InvertBuffer(TInt aLength,TUint32* aBuffer) |
|
73 { |
|
74 __ASSERT_DEBUG(aLength>0,Panic(EScreenDriverPanicZeroLength)); |
|
75 __ASSERT_DEBUG(aBuffer,Panic(EScreenDriverPanicNullPointer)); |
|
76 |
|
77 const TUint32* limit = aBuffer + ((aLength + 1) >> 1); |
|
78 |
|
79 while (aBuffer < limit) |
|
80 *aBuffer++ ^= 0xffffffff; |
|
81 } |
|
82 |
|
83 void CDrawSixteenBppBitmapCommon::ShadowArea(const TRect& aRect) |
|
84 { |
|
85 const TRect rect(DeOrientate(aRect)); |
|
86 |
|
87 __ASSERT_DEBUG(rect.iTl.iX>=0 && rect.iBr.iX<=iSize.iWidth,Panic(EScreenDriverPanicOutOfBounds)); |
|
88 __ASSERT_DEBUG(rect.iTl.iY>=0 && rect.iBr.iY<=iSize.iHeight,Panic(EScreenDriverPanicOutOfBounds)); |
|
89 |
|
90 const TInt longWidth = iLongWidth; |
|
91 TUint16* pixelPtr = PixelAddress(rect.iTl.iX,rect.iTl.iY); |
|
92 const TUint16* pixelRowPtrLimit = pixelPtr + (rect.Height() * longWidth); |
|
93 |
|
94 if (iShadowMode & EFade) |
|
95 { |
|
96 TUint16* pixelRowPtr = pixelPtr; |
|
97 TUint16* pixelPtrLimit = pixelPtr + rect.Width(); |
|
98 |
|
99 while (pixelRowPtr < pixelRowPtrLimit) |
|
100 { |
|
101 for (TUint16* tempPixelPtr = pixelRowPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
102 tempPixelPtr[0] = FadeIndex(tempPixelPtr[0]); |
|
103 |
|
104 pixelRowPtr += longWidth; |
|
105 pixelPtrLimit += longWidth; |
|
106 } |
|
107 } |
|
108 |
|
109 if (iShadowMode & EShadow) |
|
110 { |
|
111 TUint16* pixelRowPtr = pixelPtr; |
|
112 TUint16* pixelPtrLimit = pixelPtr + rect.Width(); |
|
113 |
|
114 while (pixelRowPtr < pixelRowPtrLimit) |
|
115 { |
|
116 for (TUint16* tempPixelPtr = pixelRowPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
117 tempPixelPtr[0] = ShadowIndex(tempPixelPtr[0]); |
|
118 |
|
119 pixelRowPtr += longWidth; |
|
120 pixelPtrLimit += longWidth; |
|
121 } |
|
122 } |
|
123 } |
|
124 |
|
125 void CDrawSixteenBppBitmapCommon::ShadowBuffer(TInt aLength,TUint32* aBuffer) |
|
126 { |
|
127 __ASSERT_DEBUG(aLength>0,Panic(EScreenDriverPanicZeroLength)); |
|
128 __ASSERT_DEBUG(aBuffer,Panic(EScreenDriverPanicNullPointer)); |
|
129 |
|
130 const TUint16* limit = ((TUint16*)aBuffer) + aLength; |
|
131 |
|
132 if (iShadowMode & EFade) |
|
133 { |
|
134 for (TUint16* buffer = (TUint16*)aBuffer; buffer < limit; buffer++) |
|
135 buffer[0] = FadeIndex(buffer[0]); |
|
136 } |
|
137 |
|
138 if (iShadowMode & EShadow) |
|
139 { |
|
140 for (TUint16* buffer = (TUint16*)aBuffer; buffer < limit; buffer++) |
|
141 buffer[0] = ShadowIndex(buffer[0]); |
|
142 } |
|
143 } |
|
144 |
|
145 void CDrawSixteenBppBitmapCommon::ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const |
|
146 { |
|
147 const TUint16* pixelPtr = PixelAddress(aX,aY); |
|
148 if (iOrientation == EOrientationNormal && iScalingOff) |
|
149 Mem::Copy(aBuffer,pixelPtr,aLength * 2); |
|
150 else |
|
151 { |
|
152 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
153 TUint16* bufferPtr = STATIC_CAST(TUint16*,aBuffer); |
|
154 const TUint16* bufferPtrLimit = bufferPtr + aLength; |
|
155 while (bufferPtr < bufferPtrLimit) |
|
156 { |
|
157 *bufferPtr++ = *pixelPtr; |
|
158 pixelPtr += pixelPtrInc; |
|
159 } |
|
160 } |
|
161 } |
|
162 |
|
163 void CDrawSixteenBppBitmapCommon::WriteBinary(TInt aX,TInt aY,TUint32* aData,TInt aLength,TInt aHeight,TUint16 aColor) |
|
164 { |
|
165 DeOrientate(aX,aY); |
|
166 TInt pixelInc; |
|
167 TInt rowInc; |
|
168 SetPixelInc(pixelInc, rowInc); |
|
169 const TUint32* dataLimit = aData + aHeight; |
|
170 const TUint32 dataMaskLimit = (aLength < 32) ? 1 << aLength : 0; |
|
171 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
172 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
173 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
174 TInt orgY = aY; |
|
175 while (aData < dataLimit) |
|
176 { |
|
177 TUint32 dataWord = *aData++; |
|
178 TUint32 dataMask = 1; |
|
179 TUint16* tempPixelPtr = pixelPtr; |
|
180 if (iScalingOff) |
|
181 { |
|
182 while (dataMask != dataMaskLimit) |
|
183 { |
|
184 if(dataWord & dataMask) |
|
185 *tempPixelPtr = aColor; |
|
186 |
|
187 tempPixelPtr += pixelInc; |
|
188 dataMask <<= 1; |
|
189 } |
|
190 } |
|
191 else |
|
192 { |
|
193 while (dataMask != dataMaskLimit) |
|
194 { |
|
195 if(dataWord & dataMask) |
|
196 { |
|
197 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
198 SetPixels(tempPixelPtr, aColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
199 } |
|
200 tempPixelPtr += pixelInc; |
|
201 dataMask <<= 1; |
|
202 IncScaledY(aY); |
|
203 } |
|
204 } |
|
205 pixelPtr += rowInc; |
|
206 IncScaledY(aY, orgY); |
|
207 } |
|
208 } |
|
209 |
|
210 void CDrawSixteenBppBitmapCommon::WriteBinaryOp(TInt aX,TInt aY,TUint32* aData,TInt aLength,TInt aHeight,TUint16 aColor,CGraphicsContext::TDrawMode aDrawMode) |
|
211 { |
|
212 if (aLength <= 0) |
|
213 return; |
|
214 |
|
215 DeOrientate(aX,aY); |
|
216 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
217 const TUint32* dataPtrLimit = aData + aHeight; |
|
218 const TUint32 dataMaskLimit = (aLength < 32) ? 1 << aLength : 0; |
|
219 TInt pixelInc; |
|
220 TInt rowInc; |
|
221 SetPixelInc(pixelInc, rowInc); |
|
222 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
223 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
224 TInt orgY = aY; |
|
225 if (aColor) |
|
226 { |
|
227 while (aData < dataPtrLimit) |
|
228 { |
|
229 TUint32 dataWord = *aData++; |
|
230 TUint32 dataMask = 1; |
|
231 TUint16* tempPixelPtr = pixelPtr; |
|
232 if (iScalingOff) |
|
233 { |
|
234 while (dataMask != dataMaskLimit) |
|
235 { |
|
236 if(dataWord & dataMask) |
|
237 { |
|
238 if(aDrawMode==CGraphicsContext::EDrawModeXOR) |
|
239 *tempPixelPtr ^= aColor; |
|
240 else if(aDrawMode==CGraphicsContext::EDrawModeAND) |
|
241 *tempPixelPtr &= aColor; |
|
242 else if(aDrawMode==CGraphicsContext::EDrawModeOR) |
|
243 *tempPixelPtr |= aColor; |
|
244 } |
|
245 tempPixelPtr += pixelInc; |
|
246 dataMask <<= 1; |
|
247 } |
|
248 } |
|
249 else |
|
250 { |
|
251 while(dataMask != dataMaskLimit) |
|
252 { |
|
253 if(dataWord & dataMask) |
|
254 { |
|
255 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
256 if(aDrawMode==CGraphicsContext::EDrawModeXOR) |
|
257 { |
|
258 XORPixels(tempPixelPtr, aColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
259 } |
|
260 else if(aDrawMode==CGraphicsContext::EDrawModeAND) |
|
261 { |
|
262 ANDPixels(tempPixelPtr, aColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
263 } |
|
264 else if(aDrawMode==CGraphicsContext::EDrawModeOR) |
|
265 { |
|
266 ORPixels(tempPixelPtr, aColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
267 } |
|
268 } |
|
269 tempPixelPtr += pixelInc; |
|
270 dataMask <<= 1; |
|
271 IncScaledY(aY); |
|
272 } |
|
273 } |
|
274 pixelPtr += rowInc; |
|
275 IncScaledY(aY, orgY); |
|
276 } |
|
277 } |
|
278 else if(aDrawMode==CGraphicsContext::EDrawModeAND) |
|
279 { |
|
280 while (aData < dataPtrLimit) |
|
281 { |
|
282 TUint32 dataWord = *aData++; |
|
283 TUint32 dataMask = 1; |
|
284 TUint16* tempPixelPtr = pixelPtr; |
|
285 if (iScalingOff) |
|
286 { |
|
287 while (dataMask != dataMaskLimit) |
|
288 { |
|
289 if(dataWord & dataMask) |
|
290 *tempPixelPtr = 0; |
|
291 |
|
292 tempPixelPtr += pixelInc; |
|
293 dataMask <<= 1; |
|
294 } |
|
295 } |
|
296 else |
|
297 { |
|
298 while(dataMask != dataMaskLimit) |
|
299 { |
|
300 if(dataWord & dataMask) |
|
301 { |
|
302 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
303 SetPixels(tempPixelPtr, TUint16(0), pixelRowPtrLimit, bitsStart, bitsEnd); |
|
304 } |
|
305 tempPixelPtr += pixelInc; |
|
306 dataMask <<= 1; |
|
307 } |
|
308 } |
|
309 pixelPtr += rowInc; |
|
310 IncScaledY(aY, orgY); |
|
311 } |
|
312 } |
|
313 } |
|
314 |
|
315 void CDrawSixteenBppBitmapCommon::WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aData,TInt aHeight,TUint16 aColor,TBool aUp) |
|
316 { |
|
317 __ASSERT_DEBUG(iScalingOff, User::Invariant()); |
|
318 DeOrientate(aX,aY); |
|
319 |
|
320 TInt scanlineByteLength; |
|
321 |
|
322 switch(iOrientation) |
|
323 { |
|
324 case EOrientationNormal: |
|
325 scanlineByteLength = iLongWidth; |
|
326 break; |
|
327 case EOrientationRotated90: |
|
328 scanlineByteLength = -1; |
|
329 break; |
|
330 case EOrientationRotated180: |
|
331 scanlineByteLength = -iLongWidth; |
|
332 break; |
|
333 default: // EOrientationRotated270 |
|
334 scanlineByteLength = 1; |
|
335 } |
|
336 |
|
337 if (aUp) |
|
338 scanlineByteLength = -scanlineByteLength; |
|
339 |
|
340 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
341 const TUint16* pixelPtrLimit = pixelPtr + (aHeight * scanlineByteLength); |
|
342 TUint32 dataWord = *aData; |
|
343 TUint32 dataMask = 1; |
|
344 |
|
345 while(pixelPtr != pixelPtrLimit) |
|
346 { |
|
347 if(!dataMask) |
|
348 { |
|
349 dataMask = 1; |
|
350 aData++; |
|
351 dataWord = *aData; |
|
352 } |
|
353 |
|
354 if(dataWord & dataMask) |
|
355 *pixelPtr = aColor; |
|
356 |
|
357 dataMask <<= 1; |
|
358 pixelPtr += scanlineByteLength; |
|
359 } |
|
360 } |
|
361 |
|
362 |
|
363 void CDrawSixteenBppBitmapCommon::WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor) |
|
364 { |
|
365 const TInt longWidth = iLongWidth; |
|
366 const TInt scanLineWords = iScanLineWords; |
|
367 |
|
368 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
369 const TUint16* pixelRowPtrLimit = pixelPtr + (aHeight * longWidth); |
|
370 |
|
371 if ((aColor >> 8) == (TUint8)aColor) |
|
372 { |
|
373 while (pixelPtr < pixelRowPtrLimit) |
|
374 { |
|
375 Mem::Fill(pixelPtr,aLength * 2,TUint8(aColor)); |
|
376 pixelPtr += longWidth; |
|
377 } |
|
378 } |
|
379 else |
|
380 { |
|
381 const TBool leadingPixel = aX & 1; |
|
382 const TBool trailingPixel = (aX + aLength) & 1; |
|
383 const TUint32 colorWord = (aColor << 16) | aColor; |
|
384 |
|
385 TUint16* lastPixelPtr = pixelPtr + aLength - 1; |
|
386 TUint32* wordPtr = REINTERPRET_CAST(TUint32*,pixelPtr + (leadingPixel ? 1 : 0)); |
|
387 TUint32* wordPtrLimit = REINTERPRET_CAST(TUint32*,lastPixelPtr + (trailingPixel ? 0 : 1)); |
|
388 |
|
389 __ASSERT_DEBUG(!(TInt(wordPtr) & 3),Panic(EScreenDriverPanicInvalidPointer)); |
|
390 __ASSERT_DEBUG(!(TInt(wordPtrLimit) & 3),Panic(EScreenDriverPanicInvalidPointer)); |
|
391 |
|
392 if (leadingPixel) |
|
393 { |
|
394 while (pixelPtr < pixelRowPtrLimit) |
|
395 { |
|
396 pixelPtr[0] = aColor; |
|
397 pixelPtr += longWidth; |
|
398 } |
|
399 } |
|
400 |
|
401 while (wordPtr < (TUint32*)pixelRowPtrLimit) |
|
402 { |
|
403 MemFillTUint32(wordPtr, wordPtrLimit-wordPtr, colorWord); |
|
404 wordPtr += scanLineWords; |
|
405 wordPtrLimit += scanLineWords; |
|
406 } |
|
407 |
|
408 if (trailingPixel) |
|
409 { |
|
410 while (lastPixelPtr < pixelRowPtrLimit) |
|
411 { |
|
412 lastPixelPtr[0] = aColor; |
|
413 lastPixelPtr += longWidth; |
|
414 } |
|
415 } |
|
416 } |
|
417 } |
|
418 |
|
419 void CDrawSixteenBppBitmapCommon::WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor) |
|
420 { |
|
421 const TInt longWidth = iLongWidth; |
|
422 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
423 TUint16* pixelPtrLimit = pixelPtr + aLength; |
|
424 const TUint16* pixelRowPtrLimit = pixelPtr + (aHeight * longWidth); |
|
425 |
|
426 while (pixelPtr < pixelRowPtrLimit) |
|
427 { |
|
428 for (TUint16* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
429 tempPixelPtr[0] ^= aColor; |
|
430 |
|
431 pixelPtr += longWidth; |
|
432 pixelPtrLimit += longWidth; |
|
433 } |
|
434 } |
|
435 |
|
436 void CDrawSixteenBppBitmapCommon::WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor) |
|
437 { |
|
438 const TInt longWidth = iLongWidth; |
|
439 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
440 TUint16* pixelPtrLimit = pixelPtr + aLength; |
|
441 const TUint16* pixelRowPtrLimit = pixelPtr + (aHeight * longWidth); |
|
442 |
|
443 while (pixelPtr < pixelRowPtrLimit) |
|
444 { |
|
445 for (TUint16* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
446 tempPixelPtr[0] &= aColor; |
|
447 |
|
448 pixelPtr += longWidth; |
|
449 pixelPtrLimit += longWidth; |
|
450 } |
|
451 } |
|
452 |
|
453 void CDrawSixteenBppBitmapCommon::WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor) |
|
454 { |
|
455 const TInt longWidth = iLongWidth; |
|
456 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
457 TUint16* pixelPtrLimit = pixelPtr + aLength; |
|
458 const TUint16* pixelRowPtrLimit = pixelPtr + (aHeight * longWidth); |
|
459 |
|
460 while (pixelPtr < pixelRowPtrLimit) |
|
461 { |
|
462 for (TUint16* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
463 tempPixelPtr[0] |= aColor; |
|
464 |
|
465 pixelPtr += longWidth; |
|
466 pixelPtrLimit += longWidth; |
|
467 } |
|
468 } |
|
469 |
|
470 void CDrawSixteenBppBitmapCommon::WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) |
|
471 { |
|
472 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
473 if (iOrientation == EOrientationNormal && iScalingOff) |
|
474 Mem::Copy(pixelPtr,aBuffer,aLength * 2); |
|
475 else |
|
476 { |
|
477 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
478 TUint16* bufferPtr = REINTERPRET_CAST(TUint16*,aBuffer); |
|
479 TUint16* bufferPtrLimit = bufferPtr + aLength; |
|
480 if (iScalingOff) |
|
481 { |
|
482 while (bufferPtr < bufferPtrLimit) |
|
483 { |
|
484 *pixelPtr = *bufferPtr++; |
|
485 pixelPtr += pixelPtrInc; |
|
486 } |
|
487 } |
|
488 else |
|
489 { |
|
490 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
491 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
492 while(bufferPtr < bufferPtrLimit) |
|
493 { |
|
494 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
495 SetPixels(pixelPtr, *bufferPtr++, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
496 pixelPtr += pixelPtrInc; |
|
497 IncScaledY(aY); |
|
498 } |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 void CDrawSixteenBppBitmapCommon::WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) |
|
504 { |
|
505 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
506 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
507 TUint16* bufferPtr = REINTERPRET_CAST(TUint16*,aBuffer); |
|
508 const TUint16* bufferPtrLimit = bufferPtr + aLength; |
|
509 if (iScalingOff) |
|
510 { |
|
511 while (bufferPtr < bufferPtrLimit) |
|
512 { |
|
513 *pixelPtr ^= *bufferPtr++; |
|
514 pixelPtr += pixelPtrInc; |
|
515 } |
|
516 } |
|
517 else |
|
518 { |
|
519 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
520 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
521 while(bufferPtr < bufferPtrLimit) |
|
522 { |
|
523 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
524 XORPixels(pixelPtr, *bufferPtr++, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
525 pixelPtr += pixelPtrInc; |
|
526 IncScaledY(aY); |
|
527 } |
|
528 } |
|
529 } |
|
530 |
|
531 void CDrawSixteenBppBitmapCommon::WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) |
|
532 { |
|
533 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
534 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
535 TUint16* bufferPtr = REINTERPRET_CAST(TUint16*,aBuffer); |
|
536 const TUint16* bufferPtrLimit = bufferPtr + aLength; |
|
537 if (iScalingOff) |
|
538 { |
|
539 while (bufferPtr < bufferPtrLimit) |
|
540 { |
|
541 *pixelPtr &= *bufferPtr++; |
|
542 pixelPtr += pixelPtrInc; |
|
543 } |
|
544 } |
|
545 else |
|
546 { |
|
547 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
548 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
549 while(bufferPtr < bufferPtrLimit) |
|
550 { |
|
551 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
552 ANDPixels(pixelPtr, *bufferPtr++, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
553 pixelPtr += pixelPtrInc; |
|
554 IncScaledY(aY); |
|
555 } |
|
556 } |
|
557 } |
|
558 |
|
559 void CDrawSixteenBppBitmapCommon::WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) |
|
560 { |
|
561 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
562 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
563 TUint16* bufferPtr = REINTERPRET_CAST(TUint16*,aBuffer); |
|
564 const TUint16* bufferPtrLimit = bufferPtr + aLength; |
|
565 if (iScalingOff) |
|
566 { |
|
567 while (bufferPtr < bufferPtrLimit) |
|
568 { |
|
569 *pixelPtr |= *bufferPtr++; |
|
570 pixelPtr += pixelPtrInc; |
|
571 } |
|
572 } |
|
573 else |
|
574 { |
|
575 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
576 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
577 while(bufferPtr < bufferPtrLimit) |
|
578 { |
|
579 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
580 ORPixels(pixelPtr, *bufferPtr++, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
581 pixelPtr += pixelPtrInc; |
|
582 IncScaledY(aY); |
|
583 } |
|
584 } |
|
585 } |
|
586 |
|
587 /** |
|
588 Implementation for CFbsDrawDevice::GetInterface(). |
|
589 Retrieves a pointer to a specified interface of CFbsDrawDevice implementation. |
|
590 @param aInterfaceId Interface identifier of the interface to be retrieved. |
|
591 @param aInterface Address of variable that retrieves the specified interface. |
|
592 @return KErrNone If the interface is supported, KErrNotSupported otherwise. |
|
593 */ |
|
594 |
|
595 TInt CDrawSixteenBppBitmapCommon::GetInterface(TInt aInterfaceId, TAny*& aInterface) |
|
596 { |
|
597 aInterface = NULL; |
|
598 TInt ret = KErrNotSupported; |
|
599 |
|
600 if (aInterfaceId == KFastBlit2InterfaceID) |
|
601 { |
|
602 aInterface = static_cast<MFastBlit2*>(this); |
|
603 ret = KErrNone; |
|
604 } |
|
605 else |
|
606 return CDrawBitmap::GetInterface(aInterfaceId, aInterface); |
|
607 |
|
608 return ret; |
|
609 } |
|
610 |
|
611 /** |
|
612 CDrawSixteenBppBitmapCommon::WriteBitmapBlock() implementation. |
|
613 @internalTechnology |
|
614 @see MFastBlit2::WriteBitmapBlock() |
|
615 */ |
|
616 TInt CDrawSixteenBppBitmapCommon::WriteBitmapBlock(const TPoint& aDest, |
|
617 CFbsDrawDevice* aSrcDrawDevice, |
|
618 const TRect& aSrcRect) |
|
619 { |
|
620 __ASSERT_DEBUG(aSrcDrawDevice && ((aSrcDrawDevice->DisplayMode()==EColor64K) || (aSrcDrawDevice->DisplayMode()==EColor4K)), Panic(EScreenDriverPanicInvalidParameter)); |
|
621 |
|
622 TAny* interface=NULL; |
|
623 TInt ret = aSrcDrawDevice->GetInterface(KFastBlit2InterfaceID, interface); |
|
624 if (ret != KErrNone) |
|
625 { |
|
626 return KErrNotSupported; |
|
627 } |
|
628 |
|
629 TAny* interface1=NULL; |
|
630 ret = aSrcDrawDevice->GetInterface(KScalingSettingsInterfaceID, interface1); |
|
631 if(ret != KErrNone || (interface1 && !reinterpret_cast<MScalingSettings*>(interface1)->IsScalingOff())) |
|
632 { |
|
633 return KErrNotSupported; |
|
634 } |
|
635 |
|
636 ret = aSrcDrawDevice->GetInterface(KOrientationInterfaceID, interface1); |
|
637 if(ret != KErrNone || (interface1 && reinterpret_cast<MDrawDeviceOrientation*>(interface1)->Orientation() != 0)) |
|
638 { |
|
639 return KErrNotSupported; |
|
640 } |
|
641 |
|
642 ret = aSrcDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID, interface1); |
|
643 if(ret != KErrNone) |
|
644 { |
|
645 return KErrNotSupported; |
|
646 } |
|
647 |
|
648 if(interface1) |
|
649 { |
|
650 TPoint pt; |
|
651 reinterpret_cast<MDrawDeviceOrigin*>(interface1)->Get(pt); |
|
652 if(pt.iX != 0 || pt.iY != 0) |
|
653 { |
|
654 return KErrNotSupported; |
|
655 } |
|
656 } |
|
657 |
|
658 const TUint32* srcBase = reinterpret_cast<MFastBlit2*>(interface)->Bits(); |
|
659 __ASSERT_DEBUG(srcBase!=NULL, Panic(EScreenDriverPanicInvalidParameter)); |
|
660 TInt srcStride = aSrcDrawDevice->ScanLineBytes(); |
|
661 __ASSERT_DEBUG((srcStride&3)==0, Panic(EScreenDriverPanicInvalidParameter)); // stride is assumed to be a multiple of 4 |
|
662 TSize srcSize = aSrcDrawDevice->SizeInPixels(); |
|
663 |
|
664 return WriteBitmapBlock(aDest, srcBase, srcStride, srcSize, aSrcRect); |
|
665 } |
|
666 |
|
667 |
|
668 /** |
|
669 CDrawSixteenBppBitmapCommon::WriteBitmapBlock() implementation. |
|
670 @internalTechnology |
|
671 @see MFastBlit2::WriteBitmapBlock() |
|
672 */ |
|
673 TInt CDrawSixteenBppBitmapCommon::WriteBitmapBlock(const TPoint& aDest, |
|
674 const TUint32* aSrcBase, |
|
675 TInt aSrcStride, |
|
676 const TSize& aSrcSize, |
|
677 const TRect& aSrcRect) |
|
678 { |
|
679 __ASSERT_DEBUG(aSrcBase, Panic(EScreenDriverPanicInvalidParameter)); |
|
680 __ASSERT_DEBUG((aSrcStride&3)==0, Panic(EScreenDriverPanicInvalidParameter)); |
|
681 __ASSERT_DEBUG(iBits, Panic(EScreenDriverPanicInvalidPointer)); |
|
682 |
|
683 if (iShadowMode!=NULL || |
|
684 (iUserDispMode!=NULL && iUserDispMode!=iDispMode) || |
|
685 iOrientation!=EOrientationNormal || |
|
686 !IsScalingOff() || |
|
687 !iOriginIsZero) |
|
688 { |
|
689 return KErrNotSupported; |
|
690 } |
|
691 |
|
692 __ASSERT_DEBUG(aSrcRect.iTl.iX >= 0, Panic(EScreenDriverPanicOutOfBounds)); |
|
693 __ASSERT_DEBUG(aSrcRect.iTl.iY >= 0, Panic(EScreenDriverPanicOutOfBounds)); |
|
694 __ASSERT_DEBUG(aSrcRect.iBr.iX <= aSrcSize.iWidth, Panic(EScreenDriverPanicOutOfBounds)); |
|
695 __ASSERT_DEBUG(aSrcRect.iBr.iY <= aSrcSize.iHeight, Panic(EScreenDriverPanicOutOfBounds)); |
|
696 __ASSERT_DEBUG(aDest.iX >= 0, Panic(EScreenDriverPanicOutOfBounds)); |
|
697 __ASSERT_DEBUG(aDest.iY >= 0, Panic(EScreenDriverPanicOutOfBounds)); |
|
698 __ASSERT_DEBUG((aDest.iX + aSrcRect.Width()) <= SizeInPixels().iWidth, Panic(EScreenDriverPanicOutOfBounds)); |
|
699 __ASSERT_DEBUG((aDest.iY + aSrcRect.Height()) <= SizeInPixels().iHeight, Panic(EScreenDriverPanicOutOfBounds)); |
|
700 |
|
701 const TInt srcStride16 = aSrcStride >> 1; |
|
702 const TInt dstStride16 = iScanLineWords << 1; |
|
703 |
|
704 if (aSrcSize.iWidth == aSrcRect.Width() && |
|
705 aSrcSize.iWidth == SizeInPixels().iWidth && |
|
706 srcStride16 == dstStride16) |
|
707 { |
|
708 // Optimum case - one memcpy |
|
709 __ASSERT_DEBUG(aSrcRect.iTl.iX==0 && aDest.iX==0, Panic(EScreenDriverPanicInvalidParameter)); // this is implied by the above conditions |
|
710 const TUint32* srcPtr = aSrcBase + (iScanLineWords * aSrcRect.iTl.iY); |
|
711 TUint32* dstPtr = iBits + (iScanLineWords * aDest.iY); |
|
712 const TInt length = aSrcStride * aSrcRect.Height(); |
|
713 Mem::Move(dstPtr, srcPtr, length); |
|
714 return KErrNone; |
|
715 } |
|
716 |
|
717 // Sub-optimal case - one memcpy per line |
|
718 const TUint16* srcPtr = (TUint16*)aSrcBase + (srcStride16 * aSrcRect.iTl.iY) + aSrcRect.iTl.iX; |
|
719 TUint16* dstPtr = (TUint16*)iBits + (dstStride16 * aDest.iY ) + aDest.iX; |
|
720 const TInt length = aSrcRect.Width() << 1; |
|
721 TInt lines = aSrcRect.Height(); |
|
722 while (lines--) |
|
723 { |
|
724 Mem::Copy(dstPtr, srcPtr, length); |
|
725 srcPtr += srcStride16; |
|
726 dstPtr += dstStride16; |
|
727 } |
|
728 return KErrNone; |
|
729 } |
|
730 |
|
731 /** |
|
732 CDrawSixteenBppBitmapCommon::Bits() implementation. |
|
733 @internalTechnology |
|
734 @see MFastBlit2::Bits() |
|
735 */ |
|
736 const TUint32* CDrawSixteenBppBitmapCommon::Bits() const |
|
737 { |
|
738 return iBits; |
|
739 } |
|
740 |
|
741 // CDrawSixteenBppBitmap |
|
742 |
|
743 TInt CDrawSixteenBppBitmap::Construct(TSize aSize) |
|
744 { |
|
745 return Construct(aSize, ((aSize.iWidth + 1) & ~1) << 1); |
|
746 } |
|
747 |
|
748 TInt CDrawSixteenBppBitmap::Construct(TSize aSize, TInt aStride) |
|
749 { |
|
750 iDispMode = EColor64K; |
|
751 return CDrawSixteenBppBitmapCommon::Construct(aSize, aStride); |
|
752 } |
|
753 |
|
754 void CDrawSixteenBppBitmap::Shadow(TRgb& aColor) |
|
755 { |
|
756 if (iShadowMode & EFade) |
|
757 { |
|
758 #if defined(SYMBIAN_USE_FAST_FADING) |
|
759 TUint16 color = aColor._Color64K(); |
|
760 TInt alpha = aColor.Alpha(); |
|
761 color = TUint16(((color >> K16bppFastFadeShift) & ~K16bppFastFadeMask) + K16bppFastFadeOffset); |
|
762 aColor = TRgb::_Color64K(color); |
|
763 aColor.SetAlpha(alpha); |
|
764 #else |
|
765 TRgb fadeColor = TRgb::_Color64K(aColor._Color64K()); |
|
766 fadeColor.SetAlpha(aColor.Alpha()); |
|
767 aColor = FadeRgb(fadeColor); |
|
768 #endif |
|
769 } |
|
770 |
|
771 if (iShadowMode & EShadow) |
|
772 { |
|
773 TRgb shadowColor = TRgb::_Color64K(ShadowIndex(TUint16(aColor._Color64K()))); |
|
774 shadowColor.SetAlpha(aColor.Alpha()); |
|
775 aColor = shadowColor; |
|
776 } |
|
777 } |
|
778 |
|
779 /** |
|
780 The overloaded function for Shadow(TRgb) which works directly with |
|
781 the Red, Green and Blue colour components to increase the performance. |
|
782 @param aRed Red component of colour. |
|
783 @param aGreen Green component of colour. |
|
784 @param aBlue Blue component of colour. |
|
785 */ |
|
786 FORCEINLINE void CDrawSixteenBppBitmap::Shadow(TInt& aRed, TInt& aGreen, TInt& aBlue) |
|
787 { |
|
788 if (iShadowMode & EFade) |
|
789 { |
|
790 #if defined(SYMBIAN_USE_FAST_FADING) |
|
791 TUint16 color = PackColor64K(aRed, aGreen, aBlue); |
|
792 color = TUint16(((color >> K16bppFastFadeShift) & ~K16bppFastFadeMask) + K16bppFastFadeOffset); |
|
793 UnpackColor64K(color, aRed, aGreen, aBlue); |
|
794 #else |
|
795 FadeRgb(aRed, aGreen, aBlue); |
|
796 #endif |
|
797 } |
|
798 |
|
799 if (iShadowMode & EShadow) |
|
800 { |
|
801 ShadowIndex(aRed, aGreen, aBlue); |
|
802 } |
|
803 } |
|
804 |
|
805 /** |
|
806 The overloaded function for Shadow(TRgb) which works directly with |
|
807 16 bit colour instead of TRgb to increase the performance. |
|
808 @param a64KColor The 16 bit colour value. |
|
809 */ |
|
810 FORCEINLINE void CDrawSixteenBppBitmap::Shadow(TUint16& a64KColor) |
|
811 { |
|
812 if (iShadowMode & EFade) |
|
813 { |
|
814 #if defined(SYMBIAN_USE_FAST_FADING) |
|
815 a64KColor = TUint16(((a64KColor >> K16bppFastFadeShift) & ~K16bppFastFadeMask) + K16bppFastFadeOffset); |
|
816 #else |
|
817 TRgb fadeColor = TRgb::_Color64K(a64KColor); |
|
818 fadeColor.SetAlpha(0xFF); |
|
819 a64KColor = FadeRgb(fadeColor)._Color64K(); |
|
820 #endif |
|
821 } |
|
822 if (iShadowMode & EShadow) |
|
823 { |
|
824 a64KColor = ShadowIndex(a64KColor); |
|
825 } |
|
826 } |
|
827 |
|
828 TUint16 CDrawSixteenBppBitmap::ShadowIndex(TUint16 aColor64KIndex) |
|
829 { |
|
830 TInt red = (aColor64KIndex & 0xf800) >> 11; |
|
831 TInt green = (aColor64KIndex & 0x07e0) >> 5; |
|
832 TInt blue = aColor64KIndex & 0x001f; |
|
833 |
|
834 red = Max(0,red-8); |
|
835 green = Max(0,green-16); |
|
836 blue = Max(0,blue-8); |
|
837 |
|
838 return TUint16((red << 11) | (green << 5) | blue); |
|
839 } |
|
840 |
|
841 /** |
|
842 The overloaded function for ShadowIndex(TUint16) which works directly with |
|
843 the Red, Green and Blue colour components to increase the performance. |
|
844 @param aRed Red component of colour. |
|
845 @param aGreen Green component of colour. |
|
846 @param aBlue Blue component of colour. |
|
847 */ |
|
848 FORCEINLINE void CDrawSixteenBppBitmap::ShadowIndex(TInt& aRed, TInt& aGreen, TInt& aBlue) |
|
849 { |
|
850 aRed = Max(0,aRed-8); |
|
851 aGreen = Max(0,aGreen-16); |
|
852 aBlue = Max(0,aBlue-8); |
|
853 } |
|
854 |
|
855 TUint16 CDrawSixteenBppBitmap::FadeIndex(TUint16 aColor64KIndex) |
|
856 { |
|
857 #if defined(SYMBIAN_USE_FAST_FADING) |
|
858 return TUint16(((aColor64KIndex >> K16bppFastFadeShift) & ~K16bppFastFadeMask) + K16bppFastFadeOffset); |
|
859 #else |
|
860 return TUint16(FadeRgb(TRgb::_Color64K(aColor64KIndex))._Color64K()); |
|
861 #endif |
|
862 } |
|
863 |
|
864 TRgb CDrawSixteenBppBitmap::ReadRgbNormal(TInt aX,TInt aY) const |
|
865 { |
|
866 return TRgb::_Color64K(*PixelAddress(aX,aY)); |
|
867 } |
|
868 |
|
869 void CDrawSixteenBppBitmap::WriteRgb(TInt aX,TInt aY,TRgb aColor) |
|
870 { |
|
871 register TUint16* pixelAddr = PixelAddress(aX, aY); |
|
872 register TUint16 aPixel = TUint16(aColor._Color64K()); |
|
873 |
|
874 const TInt sourceAlpha = aColor.Alpha(); |
|
875 |
|
876 if (sourceAlpha==0) |
|
877 return; |
|
878 |
|
879 if (sourceAlpha<0xff) |
|
880 { |
|
881 const TUint32 srcInternal=aColor.Internal(); |
|
882 const TUint32 srcRB=srcInternal & 0x00FF00FF; |
|
883 const TUint32 srcG=(srcInternal & 0xFF00) >> 8; |
|
884 aPixel = BlendTo16(srcRB, srcG, sourceAlpha, *pixelAddr); |
|
885 } |
|
886 |
|
887 if (iScalingOff) |
|
888 { |
|
889 *pixelAddr = aPixel; |
|
890 } |
|
891 else |
|
892 { |
|
893 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
894 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
895 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
896 SetPixels(pixelAddr, aPixel, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
897 } |
|
898 } |
|
899 |
|
900 void CDrawSixteenBppBitmap::WriteBinary(TInt aX,TInt aY,TUint32* aData,TInt aLength,TInt aHeight,TRgb aColor) |
|
901 { |
|
902 const TInt sourceAlpha = aColor.Alpha(); |
|
903 if (sourceAlpha==255) |
|
904 { |
|
905 CDrawSixteenBppBitmapCommon::WriteBinary(aX,aY,aData,aLength,aHeight,(TUint16)aColor._Color64K()); |
|
906 return; |
|
907 } |
|
908 if (sourceAlpha==0) |
|
909 return; |
|
910 |
|
911 DeOrientate(aX,aY); |
|
912 |
|
913 TInt pixelInc; |
|
914 TInt rowInc; |
|
915 |
|
916 switch(iOrientation) |
|
917 { |
|
918 case EOrientationNormal: |
|
919 { |
|
920 pixelInc = 1; |
|
921 rowInc = iLongWidth; |
|
922 break; |
|
923 } |
|
924 case EOrientationRotated90: |
|
925 { |
|
926 pixelInc = iLongWidth; |
|
927 rowInc = -1; |
|
928 break; |
|
929 } |
|
930 case EOrientationRotated180: |
|
931 { |
|
932 pixelInc = -1; |
|
933 rowInc = -iLongWidth; |
|
934 break; |
|
935 } |
|
936 default: // EOrientationRotated270 |
|
937 { |
|
938 pixelInc = -iLongWidth; |
|
939 rowInc = 1; |
|
940 } |
|
941 } |
|
942 |
|
943 const TUint32* dataLimit = aData + aHeight; |
|
944 const TUint32 dataMaskLimit = (aLength < 32) ? 1 << aLength : 0; |
|
945 |
|
946 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
947 |
|
948 const TUint32 srcInternal=aColor.Internal(); |
|
949 const TUint32 srcRB=srcInternal & 0x00FF00FF; |
|
950 const TUint32 srcG=(srcInternal & 0xFF00) >> 8; |
|
951 while (aData < dataLimit) |
|
952 { |
|
953 TUint32 dataWord = *aData++; |
|
954 TUint32 dataMask = 1; |
|
955 TUint16* tempPixelPtr = pixelPtr; |
|
956 |
|
957 while (dataMask != dataMaskLimit) |
|
958 { |
|
959 if(dataWord & dataMask) |
|
960 { |
|
961 *tempPixelPtr = BlendTo16(srcRB, srcG, sourceAlpha, *tempPixelPtr); |
|
962 } |
|
963 |
|
964 tempPixelPtr += pixelInc; |
|
965 dataMask <<= 1; |
|
966 } |
|
967 |
|
968 pixelPtr += rowInc; |
|
969 } |
|
970 } |
|
971 |
|
972 void CDrawSixteenBppBitmap::WriteBinaryOp(TInt aX,TInt aY,TUint32* aData,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) |
|
973 { |
|
974 CDrawSixteenBppBitmapCommon::WriteBinaryOp(aX,aY,aData,aLength,aHeight,(TUint16)aColor._Color64K(),aDrawMode); |
|
975 } |
|
976 |
|
977 void CDrawSixteenBppBitmap::WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aData,TInt aHeight,TRgb aColor,TBool aUp) |
|
978 { |
|
979 const TInt sourceAlpha = aColor.Alpha(); |
|
980 if (sourceAlpha==255) |
|
981 { |
|
982 CDrawSixteenBppBitmapCommon::WriteBinaryLineVertical(aX,aY,aData,aHeight,(TUint16)aColor._Color64K(),aUp); |
|
983 return; |
|
984 } |
|
985 if (sourceAlpha==0) |
|
986 return; |
|
987 |
|
988 DeOrientate(aX,aY); |
|
989 |
|
990 TInt scanlineByteLength; |
|
991 |
|
992 switch(iOrientation) |
|
993 { |
|
994 case EOrientationNormal: |
|
995 scanlineByteLength = iLongWidth; |
|
996 break; |
|
997 case EOrientationRotated90: |
|
998 scanlineByteLength = -1; |
|
999 break; |
|
1000 case EOrientationRotated180: |
|
1001 scanlineByteLength = -iLongWidth; |
|
1002 break; |
|
1003 default:// EOrientationRotated270 |
|
1004 scanlineByteLength = 1; |
|
1005 } |
|
1006 |
|
1007 if (aUp) |
|
1008 scanlineByteLength = -scanlineByteLength; |
|
1009 |
|
1010 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
1011 const TUint16* pixelPtrLimit = pixelPtr + (aHeight * scanlineByteLength); |
|
1012 TUint32 dataWord = *aData; |
|
1013 TUint32 dataMask = 1; |
|
1014 |
|
1015 const TUint32 srcInternal=aColor.Internal(); |
|
1016 const TUint32 srcRB=srcInternal & 0x00FF00FF; |
|
1017 const TUint32 srcG=(srcInternal & 0xFF00) >> 8; |
|
1018 while(pixelPtr != pixelPtrLimit) |
|
1019 { |
|
1020 if(!dataMask) |
|
1021 { |
|
1022 dataMask = 1; |
|
1023 aData++; |
|
1024 dataWord = *aData; |
|
1025 } |
|
1026 |
|
1027 if(dataWord & dataMask) |
|
1028 { |
|
1029 *pixelPtr = BlendTo16(srcRB, srcG, sourceAlpha, *pixelPtr); |
|
1030 } |
|
1031 dataMask <<= 1; |
|
1032 pixelPtr += scanlineByteLength; |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 /** |
|
1037 MAlphaBlend::WriteRgbAlphaLine2() implementation. |
|
1038 @see MAlphaBlend::WriteRgbAlphaLine2() |
|
1039 */ |
|
1040 void CDrawSixteenBppBitmap::WriteRgbAlphaLine(TInt aX, TInt aY, TInt aLength, |
|
1041 const TUint8* aRgbBuffer, |
|
1042 const TUint8* aMaskBuffer, |
|
1043 MAlphaBlend::TShadowing aShadowing, |
|
1044 CGraphicsContext::TDrawMode /*aDrawMode*/) |
|
1045 { |
|
1046 DeOrientate(aX,aY); |
|
1047 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
1048 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
1049 const TUint8* maskBufferPtrLimit = aMaskBuffer + aLength; |
|
1050 TUint16 pixelColor; |
|
1051 |
|
1052 __ASSERT_DEBUG( (((((TUint)pixelPtr)&1)==0) && ((((TUint)aRgbBuffer)&3)==0)), Panic(EScreenDriverPanicInvalidParameter)); |
|
1053 |
|
1054 if (iScalingOff) |
|
1055 { |
|
1056 if (!(iShadowMode & (EFade | EShadow)) && iUserDispMode == ENone) |
|
1057 { |
|
1058 TUint32* rgbBuffer32 = (TUint32*)aRgbBuffer; |
|
1059 while (aMaskBuffer < maskBufferPtrLimit) |
|
1060 { |
|
1061 pixelPtr[0] = Blend32To16(rgbBuffer32[0], aMaskBuffer[0], pixelPtr[0]); |
|
1062 pixelPtr += pixelPtrInc; |
|
1063 rgbBuffer32 ++; |
|
1064 aMaskBuffer++; |
|
1065 } |
|
1066 } |
|
1067 else |
|
1068 { |
|
1069 while (aMaskBuffer < maskBufferPtrLimit) |
|
1070 { |
|
1071 TInt blue = aRgbBuffer[0]; |
|
1072 TInt green = aRgbBuffer[1]; |
|
1073 TInt red = aRgbBuffer[2]; |
|
1074 if(aShadowing == MAlphaBlend::EShdwBefore) |
|
1075 { |
|
1076 Shadow(red,green,blue); |
|
1077 } |
|
1078 pixelColor = ::AlphaBlend(red,green,blue, pixelPtr[0],aMaskBuffer[0]); |
|
1079 if(aShadowing == MAlphaBlend::EShdwAfter) |
|
1080 { |
|
1081 Shadow(pixelColor); |
|
1082 } |
|
1083 MapColorToUserDisplayMode(pixelColor); |
|
1084 pixelPtr[0] = pixelColor; |
|
1085 |
|
1086 pixelPtr += pixelPtrInc; |
|
1087 aRgbBuffer += 4; |
|
1088 aMaskBuffer++; |
|
1089 } |
|
1090 } |
|
1091 } |
|
1092 else |
|
1093 { |
|
1094 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
1095 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
1096 while (aMaskBuffer < maskBufferPtrLimit) |
|
1097 { |
|
1098 TInt blue = aRgbBuffer[0]; |
|
1099 TInt green = aRgbBuffer[1]; |
|
1100 TInt red = aRgbBuffer[2]; |
|
1101 if(aShadowing == MAlphaBlend::EShdwBefore) |
|
1102 { |
|
1103 Shadow(red,green,blue); |
|
1104 } |
|
1105 pixelColor = ::AlphaBlend(red,green,blue,pixelPtr[0],aMaskBuffer[0]); |
|
1106 if(aShadowing == MAlphaBlend::EShdwAfter) |
|
1107 { |
|
1108 Shadow(pixelColor); |
|
1109 } |
|
1110 MapColorToUserDisplayMode(pixelColor); |
|
1111 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
1112 SetPixels(pixelPtr, pixelColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
1113 pixelPtr += pixelPtrInc; |
|
1114 aRgbBuffer += 4; |
|
1115 aMaskBuffer++; |
|
1116 IncScaledY(aY); |
|
1117 } |
|
1118 } |
|
1119 } |
|
1120 |
|
1121 void CDrawSixteenBppBitmap::WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor) |
|
1122 { |
|
1123 CDrawSixteenBppBitmapCommon::WriteRgbMulti(aX,aY,aLength,aHeight,(TUint16)aColor._Color64K()); |
|
1124 } |
|
1125 |
|
1126 void CDrawSixteenBppBitmap::BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor) |
|
1127 { |
|
1128 const TInt sourceAlpha = aColor.Alpha(); |
|
1129 if (sourceAlpha==255)// opaque |
|
1130 { |
|
1131 CDrawSixteenBppBitmapCommon::WriteRgbMulti(aX,aY,aLength,aHeight,(TUint16)aColor._Color64K()); |
|
1132 return; |
|
1133 } |
|
1134 if (sourceAlpha==0)// transparent |
|
1135 return; |
|
1136 |
|
1137 const TInt sourceRed = aColor.Red(); |
|
1138 const TInt sourceGreen = aColor.Green(); |
|
1139 const TInt sourceBlue = aColor.Blue(); |
|
1140 |
|
1141 const TInt longWidth = iLongWidth; |
|
1142 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
1143 TUint16* pixelPtrLimit = pixelPtr + aLength; |
|
1144 const TUint16* pixelRowPtrLimit = pixelPtr + (aHeight * longWidth); |
|
1145 const TInt mask=aColor.Alpha(); |
|
1146 const TUint32 srcInternal=aColor.Internal(); |
|
1147 const TUint32 srcRB=srcInternal & 0x00FF00FF; |
|
1148 const TUint32 srcG=(srcInternal & 0xFF00) >> 8; |
|
1149 while (pixelPtr < pixelRowPtrLimit) |
|
1150 { |
|
1151 for (TUint16* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
1152 { |
|
1153 *tempPixelPtr = BlendTo16(srcRB, srcG, mask, *tempPixelPtr); |
|
1154 } |
|
1155 pixelPtr += longWidth; |
|
1156 pixelPtrLimit += longWidth; |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 void CDrawSixteenBppBitmap::WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor) |
|
1161 { |
|
1162 CDrawSixteenBppBitmapCommon::WriteRgbMultiXOR(aX,aY,aLength,aHeight,(TUint16)aColor._Color64K()); |
|
1163 } |
|
1164 |
|
1165 void CDrawSixteenBppBitmap::WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor) |
|
1166 { |
|
1167 CDrawSixteenBppBitmapCommon::WriteRgbMultiAND(aX,aY,aLength,aHeight,(TUint16)aColor._Color64K()); |
|
1168 } |
|
1169 |
|
1170 void CDrawSixteenBppBitmap::WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor) |
|
1171 { |
|
1172 CDrawSixteenBppBitmapCommon::WriteRgbMultiOR(aX,aY,aLength,aHeight,(TUint16)aColor._Color64K()); |
|
1173 } |
|
1174 |
|
1175 void CDrawSixteenBppBitmap::WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer) |
|
1176 { |
|
1177 const TInt alpha = aColor.Alpha(); |
|
1178 if (alpha==0 || aLength<=0) |
|
1179 return; |
|
1180 DeOrientate(aX,aY); |
|
1181 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
1182 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
1183 const TUint8* maskBufferPtrLimit = aMaskBuffer + aLength; |
|
1184 |
|
1185 if (iShadowMode) |
|
1186 { |
|
1187 Shadow(aColor); |
|
1188 } |
|
1189 |
|
1190 if (iScalingOff) |
|
1191 { |
|
1192 const TUint32 color16bpp=aColor.Color64K(); |
|
1193 const TUint32 srcInternal=aColor.Internal(); |
|
1194 const TUint32 srcRB=srcInternal & 0x00FF00FF; |
|
1195 const TUint32 srcG=(srcInternal & 0xFF00) >> 8; |
|
1196 if (alpha == 0xff) |
|
1197 { |
|
1198 while (aMaskBuffer < maskBufferPtrLimit) |
|
1199 { |
|
1200 const TUint32 mask=*aMaskBuffer++; |
|
1201 if (mask) |
|
1202 { |
|
1203 if (mask==0xFF) |
|
1204 *pixelPtr = color16bpp; |
|
1205 else |
|
1206 *pixelPtr = BlendTo16(srcRB, srcG, mask, *pixelPtr); |
|
1207 } |
|
1208 pixelPtr += pixelPtrInc; |
|
1209 } |
|
1210 } |
|
1211 else |
|
1212 { // pen is semi-transparent, so we must blend using both the mask and pen alpha |
|
1213 while (aMaskBuffer < maskBufferPtrLimit) |
|
1214 { |
|
1215 TUint blendAlpha = alpha; |
|
1216 TUint maskAlpha = *aMaskBuffer++; |
|
1217 if (maskAlpha) |
|
1218 { |
|
1219 if (maskAlpha!=0xFF) |
|
1220 blendAlpha=((maskAlpha+1) * alpha)>>8; |
|
1221 *pixelPtr = BlendTo16(srcRB, srcG, blendAlpha, *pixelPtr); |
|
1222 } |
|
1223 pixelPtr += pixelPtrInc; |
|
1224 } |
|
1225 } |
|
1226 } |
|
1227 else |
|
1228 { |
|
1229 const TInt red = aColor.Red(); |
|
1230 const TInt green = aColor.Green(); |
|
1231 const TInt blue = aColor.Blue(); |
|
1232 if (alpha == 0xff) |
|
1233 { |
|
1234 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
1235 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
1236 while(aMaskBuffer < maskBufferPtrLimit) |
|
1237 { |
|
1238 TUint16 pixelColor = AlphaBlend(red,green,blue, *pixelPtr, *aMaskBuffer); |
|
1239 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
1240 SetPixels(pixelPtr, pixelColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
1241 pixelPtr += pixelPtrInc; |
|
1242 aMaskBuffer++; |
|
1243 IncScaledY(aY); |
|
1244 } |
|
1245 } |
|
1246 else |
|
1247 { // require special handling for different alpha values |
|
1248 const TUint16* bitsStart = reinterpret_cast <const TUint16*> (iBits); |
|
1249 const TUint16* bitsEnd = bitsStart + iLongWidth * iSize.iHeight; |
|
1250 while(aMaskBuffer < maskBufferPtrLimit) |
|
1251 { |
|
1252 const TInt maskAlpha = *aMaskBuffer; |
|
1253 const TInt sourceAlpha = alpha * maskAlpha; |
|
1254 const TInt inverseAlpha = 255*255 - sourceAlpha; |
|
1255 |
|
1256 TInt pixelRed; |
|
1257 TInt pixelGreen; |
|
1258 TInt pixelBlue; |
|
1259 UnpackColor64K(*pixelPtr, pixelRed, pixelGreen, pixelBlue); |
|
1260 TInt blueAfter = TUint8(((blue * sourceAlpha) + (pixelBlue * inverseAlpha)) / (255*255)); |
|
1261 TInt greenAfter = TUint8(((green * sourceAlpha) + (pixelGreen * inverseAlpha)) / (255*255)); |
|
1262 TInt redAfter = TUint8(((red * sourceAlpha) + (pixelRed * inverseAlpha)) / (255*255)); |
|
1263 TUint16 pixelColor = PackColor64K(redAfter, greenAfter, blueAfter); |
|
1264 |
|
1265 const TUint16* pixelRowPtrLimit = bitsStart + (aY + 1) * iLongWidth; |
|
1266 SetPixels(pixelPtr, pixelColor, pixelRowPtrLimit, bitsStart, bitsEnd); |
|
1267 pixelPtr += pixelPtrInc; |
|
1268 aMaskBuffer++; |
|
1269 IncScaledY(aY); |
|
1270 } |
|
1271 } |
|
1272 } |
|
1273 } |
|
1274 |
|
1275 void CDrawSixteenBppBitmap::MapColorToUserDisplayMode(TRgb& aColor) |
|
1276 { |
|
1277 switch (iUserDispMode) |
|
1278 { |
|
1279 case EGray2: |
|
1280 aColor = TRgb::_Gray2(aColor._Gray2()); |
|
1281 break; |
|
1282 case EGray4: |
|
1283 aColor = TRgb::_Gray4(aColor._Gray4()); |
|
1284 break; |
|
1285 case EGray16: |
|
1286 aColor = TRgb::_Gray16(aColor._Gray16()); |
|
1287 break; |
|
1288 case EGray256: |
|
1289 aColor = TRgb::_Gray256(aColor._Gray256()); |
|
1290 break; |
|
1291 case EColor16: |
|
1292 aColor = TRgb::Color16(aColor.Color16()); |
|
1293 break; |
|
1294 case EColor256: |
|
1295 aColor = TRgb::Color256(aColor.Color256()); |
|
1296 break; |
|
1297 case EColor4K: |
|
1298 aColor = TRgb::_Color4K(aColor._Color4K()); |
|
1299 break; |
|
1300 default: |
|
1301 break; |
|
1302 } |
|
1303 } |
|
1304 |
|
1305 /** |
|
1306 The overloaded function for MapColorToUserDisplayMode(TRgb) which works directly with |
|
1307 16 bit colour instead of TRgb to increase the performance. |
|
1308 @param a64KColor The 16 bit colour value. |
|
1309 */ |
|
1310 void CDrawSixteenBppBitmap::MapColorToUserDisplayMode(TUint16& aColor64K) |
|
1311 { |
|
1312 TRgb color = TRgb::_Color64K(aColor64K); |
|
1313 |
|
1314 switch (iUserDispMode) |
|
1315 { |
|
1316 case EGray2: |
|
1317 { |
|
1318 color = TRgb::_Gray2(color._Gray2()); |
|
1319 } |
|
1320 break; |
|
1321 case EGray4: |
|
1322 { |
|
1323 color = TRgb::_Gray4(color._Gray4()); |
|
1324 } |
|
1325 break; |
|
1326 case EGray16: |
|
1327 { |
|
1328 color = TRgb::_Gray16(color._Gray16()); |
|
1329 } |
|
1330 break; |
|
1331 case EGray256: |
|
1332 { |
|
1333 color = TRgb::_Gray256(color._Gray256()); |
|
1334 } |
|
1335 break; |
|
1336 case EColor16: |
|
1337 { |
|
1338 color = TRgb::Color16(color.Color16()); |
|
1339 } |
|
1340 break; |
|
1341 case EColor256: |
|
1342 { |
|
1343 color = TRgb::Color256(color.Color256()); |
|
1344 } |
|
1345 break; |
|
1346 case EColor4K: |
|
1347 { |
|
1348 color = TRgb::_Color4K(color._Color4K()); |
|
1349 } |
|
1350 break; |
|
1351 default: |
|
1352 break; |
|
1353 } |
|
1354 aColor64K = color._Color64K(); |
|
1355 } |
|
1356 |
|
1357 void CDrawSixteenBppBitmap::MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer) |
|
1358 { |
|
1359 TUint16* bufferPtr = (TUint16*)aBuffer; |
|
1360 const TUint16* bufferLimit = bufferPtr + aLength; |
|
1361 TRgb color; |
|
1362 |
|
1363 switch (iUserDispMode) |
|
1364 { |
|
1365 case EGray2: |
|
1366 while (bufferPtr < bufferLimit) |
|
1367 { |
|
1368 color = TRgb::_Color64K(*bufferPtr); |
|
1369 color = TRgb::_Gray2(color._Gray2()); |
|
1370 *bufferPtr++ = TUint16(color._Color64K()); |
|
1371 } |
|
1372 break; |
|
1373 case EGray4: |
|
1374 while (bufferPtr < bufferLimit) |
|
1375 { |
|
1376 color = TRgb::_Color64K(*bufferPtr); |
|
1377 color = TRgb::_Gray4(color._Gray4()); |
|
1378 *bufferPtr++ = TUint16(color._Color64K()); |
|
1379 } |
|
1380 break; |
|
1381 case EGray16: |
|
1382 while (bufferPtr < bufferLimit) |
|
1383 { |
|
1384 color = TRgb::_Color64K(*bufferPtr); |
|
1385 color = TRgb::_Gray16(color._Gray16()); |
|
1386 *bufferPtr++ = TUint16(color._Color64K()); |
|
1387 } |
|
1388 break; |
|
1389 case EGray256: |
|
1390 while (bufferPtr < bufferLimit) |
|
1391 { |
|
1392 color = TRgb::_Color64K(*bufferPtr); |
|
1393 color = TRgb::_Gray256(color._Gray256()); |
|
1394 *bufferPtr++ = TUint16(color._Color64K()); |
|
1395 } |
|
1396 break; |
|
1397 case EColor16: |
|
1398 while (bufferPtr < bufferLimit) |
|
1399 { |
|
1400 color = TRgb::_Color64K(*bufferPtr); |
|
1401 color = TRgb::Color16(color.Color16()); |
|
1402 *bufferPtr++ = TUint16(color._Color64K()); |
|
1403 } |
|
1404 break; |
|
1405 case EColor256: |
|
1406 while (bufferPtr < bufferLimit) |
|
1407 { |
|
1408 color = TRgb::_Color64K(*bufferPtr); |
|
1409 color = TRgb::Color256(color.Color256()); |
|
1410 *bufferPtr++ = TUint16(color._Color64K()); |
|
1411 } |
|
1412 break; |
|
1413 case EColor4K: |
|
1414 while (bufferPtr < bufferLimit) |
|
1415 { |
|
1416 color = TRgb::_Color64K(*bufferPtr); |
|
1417 color = TRgb::_Color4K(color._Color4K()); |
|
1418 *bufferPtr++ = TUint16(color._Color64K()); |
|
1419 } |
|
1420 break; |
|
1421 default: |
|
1422 break; |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 TInt CDrawSixteenBppBitmap::WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, |
|
1427 TUint32 aOutlinePenColor, TUint32 aShadowColor, |
|
1428 TUint32 aFillColor, const TUint8* aDataBuffer) |
|
1429 { |
|
1430 const TInt alpha = aOutlinePenColor >> 24; |
|
1431 if (alpha==0 || aLength<=0) |
|
1432 return(KErrNone); |
|
1433 DeOrientate(aX,aY); |
|
1434 TUint16* pixelPtr = PixelAddress(aX,aY); |
|
1435 const TInt pixelPtrInc = LogicalPixelAddressIncrement(); |
|
1436 const TUint8* dataBufferPtrLimit = aDataBuffer + aLength; |
|
1437 TInt blendedRedColor; |
|
1438 TInt blendedGreenColor; |
|
1439 TInt blendedBlueColor; |
|
1440 TUint32 finalColor; |
|
1441 |
|
1442 //Get red color. Equivalent to TRgb::Red() |
|
1443 const TInt redOutlinePenColor = (aOutlinePenColor & 0xff0000) >> 16; |
|
1444 const TInt redShadowColor = (aShadowColor & 0xff0000) >> 16; |
|
1445 const TInt redFillColor = (aFillColor & 0xff0000) >> 16; |
|
1446 |
|
1447 //Get green color. Equivalent to TRgb::Green() |
|
1448 const TInt greenOutlinePenColor = (aOutlinePenColor & 0xff00) >> 8; |
|
1449 const TInt greenShadowColor = (aShadowColor & 0xff00) >> 8; |
|
1450 const TInt greenFillColor = (aFillColor & 0xff00) >> 8; |
|
1451 |
|
1452 //Get blue color. Equivalent to TRgb::Blue() |
|
1453 const TInt blueOutlinePenColor = aOutlinePenColor & 0xff; |
|
1454 const TInt blueShadowColor = aShadowColor & 0xff; |
|
1455 const TInt blueFillColor = aFillColor & 0xff; |
|
1456 |
|
1457 while (aDataBuffer < dataBufferPtrLimit) |
|
1458 { |
|
1459 TUint8 index = *aDataBuffer++; |
|
1460 |
|
1461 if (255 == FourColorBlendLookup[index][KBackgroundColorIndex]) |
|
1462 { |
|
1463 //background colour |
|
1464 //No drawing required so move on to next pixel. |
|
1465 pixelPtr += pixelPtrInc; |
|
1466 continue; |
|
1467 } |
|
1468 else if (255 == FourColorBlendLookup[index][KFillColorIndex]) |
|
1469 { |
|
1470 //Use fill colour to draw |
|
1471 finalColor = aFillColor; |
|
1472 } |
|
1473 else if (255 == FourColorBlendLookup[index][KShadowColorIndex]) |
|
1474 { |
|
1475 //Use shadow colour to draw |
|
1476 finalColor = aShadowColor; |
|
1477 } |
|
1478 else if (255 == FourColorBlendLookup[index][KOutlineColorIndex]) |
|
1479 { |
|
1480 //Use outline colour to draw |
|
1481 finalColor = aOutlinePenColor; |
|
1482 } |
|
1483 else |
|
1484 { |
|
1485 //Get the background pixel colour. Using the lookup table to convert 16 to 32 bit colour |
|
1486 blendedRedColor = redOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
|
1487 redShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
|
1488 redFillColor * FourColorBlendLookup[index][KFillColorIndex]; |
|
1489 |
|
1490 blendedGreenColor = greenOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
|
1491 greenShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
|
1492 greenFillColor * FourColorBlendLookup[index][KFillColorIndex]; |
|
1493 |
|
1494 blendedBlueColor = blueOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
|
1495 blueShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
|
1496 blueFillColor * FourColorBlendLookup[index][KFillColorIndex]; |
|
1497 |
|
1498 TInt backGroundAlpha=FourColorBlendLookup[index][KBackgroundColorIndex]; |
|
1499 if (backGroundAlpha) |
|
1500 { |
|
1501 const TUint8* pixelPtr8 = reinterpret_cast<TUint8*>(pixelPtr); |
|
1502 const TUint8 low = *pixelPtr8++; |
|
1503 const TUint8 high = *pixelPtr8++; |
|
1504 TUint32 backgroundColor = (*(Convert16to32bppHigh() + high)) | (*(Convert16to32bppLow() + low)); |
|
1505 blendedRedColor += ((backgroundColor & 0xff0000) >> 16) * backGroundAlpha; |
|
1506 blendedGreenColor += ((backgroundColor & 0xff00) >> 8) * backGroundAlpha; |
|
1507 blendedBlueColor += (backgroundColor & 0xff) * backGroundAlpha; |
|
1508 } |
|
1509 //Equivalent to TRgb::TRgb(TUint32) |
|
1510 finalColor = ((blendedRedColor&0xFF00)<<8) | (blendedGreenColor&0xFF00) | (blendedBlueColor>>8); |
|
1511 } |
|
1512 |
|
1513 if (alpha == 0xff) |
|
1514 { |
|
1515 *pixelPtr = Conv32To16(finalColor); |
|
1516 } |
|
1517 else |
|
1518 { |
|
1519 *pixelPtr = Blend32To16NoChecks(finalColor, alpha, *pixelPtr); |
|
1520 } |
|
1521 pixelPtr += pixelPtrInc; |
|
1522 } |
|
1523 return KErrNone; |
|
1524 } |