sl@0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <graphics/lookuptable.h>
|
sl@0
|
17 |
#include <graphics/blendingalgorithms.h>
|
sl@0
|
18 |
#include "BMDRAW.H"
|
sl@0
|
19 |
#include "BitDrawInterfaceId.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
FORCEINLINE void BlendFromRBandG(TUint32 *aPixelPtr, TUint32 aSrcRB, TUint32 aSrcG, TUint32 aSrcAlpha, TUint32 aMaskX2)
|
sl@0
|
22 |
{
|
sl@0
|
23 |
const TUint32 d = *aPixelPtr;
|
sl@0
|
24 |
const TUint32 d_rb = d & 0x00FF00FF;
|
sl@0
|
25 |
const TUint32 rb = ((((aSrcAlpha * ((0x01000100 + aSrcRB) - d_rb)) >> 8) + d_rb) - aMaskX2) & 0x00FF00FF;
|
sl@0
|
26 |
|
sl@0
|
27 |
const TInt d_g = (d & 0xFF00) >> 8;
|
sl@0
|
28 |
const TInt g = ((aSrcAlpha * (aSrcG - d_g)) >> 8) + d_g;
|
sl@0
|
29 |
|
sl@0
|
30 |
*aPixelPtr = rb | (g<<8) | 0xff000000;
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
/**Initializes iSize, iDrawRect, iLongWidth, iScanLineBytes, iScanlineWords data members.
|
sl@0
|
34 |
It should be called every time when iSize is going to be changed - from Construct().
|
sl@0
|
35 |
|
sl@0
|
36 |
@param aSize Physical screen size in pixels.
|
sl@0
|
37 |
@panic EScreenDriverPanicInvalidSize - Invalid aSize parameter. This might happen if the
|
sl@0
|
38 |
device is scaled and the scaling origin goes outside physical drawing rectangle. */
|
sl@0
|
39 |
void CDrawThirtyTwoBppBitmapCommon::SetSize(const TSize& aSize)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CDrawBitmap::SetSize(aSize);
|
sl@0
|
42 |
__ASSERT_DEBUG(iSize == aSize, User::Invariant());
|
sl@0
|
43 |
iLongWidth = iSize.iWidth;
|
sl@0
|
44 |
iScanLineWords = iSize.iWidth;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
TInt CDrawThirtyTwoBppBitmapCommon::Construct(TSize aSize, TInt aStride)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
iBits = NULL;
|
sl@0
|
50 |
CDrawBitmap::SetSize(aSize);
|
sl@0
|
51 |
__ASSERT_DEBUG(iSize == aSize, User::Invariant());
|
sl@0
|
52 |
if (aStride & 3)
|
sl@0
|
53 |
return KErrArgument;
|
sl@0
|
54 |
iLongWidth = aStride >> 2;
|
sl@0
|
55 |
if (iLongWidth < aSize.iWidth)
|
sl@0
|
56 |
return KErrArgument;
|
sl@0
|
57 |
iScanLineWords = iLongWidth;
|
sl@0
|
58 |
TInt size = Max(aSize.iWidth,aSize.iHeight) << 2;
|
sl@0
|
59 |
if(size < 0)
|
sl@0
|
60 |
return KErrArgument;
|
sl@0
|
61 |
iScanLineBuffer = (TUint32*)(User::Heap().Alloc(size));
|
sl@0
|
62 |
if (iScanLineBuffer == NULL)
|
sl@0
|
63 |
return KErrNoMemory;
|
sl@0
|
64 |
return KErrNone;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
void CDrawThirtyTwoBppBitmapCommon::Shadow(TRgb& aColor)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
TUint32 value = aColor.Internal();
|
sl@0
|
70 |
const TInt alpha = value >> 24;
|
sl@0
|
71 |
|
sl@0
|
72 |
if (iShadowMode & EFade)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
#if defined(SYMBIAN_USE_FAST_FADING)
|
sl@0
|
75 |
value = ((value >> 1) & ~0x00808080) + (SYMBIAN_USE_FAST_FADING);
|
sl@0
|
76 |
#else
|
sl@0
|
77 |
const TInt wordFadeMapOffset = ((iFadeMapOffset & 0xff) << 16) | (iFadeMapOffset & 0xff);
|
sl@0
|
78 |
const TInt rb = ((((value & 0x00ff00ff) * iFadeMapFactor) >> 8) + wordFadeMapOffset) & 0x00ff00ff;
|
sl@0
|
79 |
const TInt g = ((((value & 0x0000ff00) * iFadeMapFactor) >> 16) + iFadeMapOffset) << 8;
|
sl@0
|
80 |
value = rb | g;
|
sl@0
|
81 |
#endif
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
if (iShadowMode & EShadow)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
const TInt r = (value & 0x00c00000) ? ((value & 0x00ff0000)-0x00400000) : 0;
|
sl@0
|
87 |
const TInt g = (value & 0x0000c000) ? ((value & 0x0000ff00)-0x00004000) : 0;
|
sl@0
|
88 |
const TInt b = (value & 0x000000c0) ? ((value & 0x000000ff)-0x00000040) : 0;
|
sl@0
|
89 |
value = r | g | b;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
aColor = TRgb(value,alpha);
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
void CDrawThirtyTwoBppBitmapCommon::Shadow(TUint32& aColor)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
// aColor is in the format indicated by ScanLineDisplayMode(), which we
|
sl@0
|
98 |
// assume is EColor16MAP here. If not, this function must be overridden.
|
sl@0
|
99 |
const TInt alpha = (aColor >> 24) + 1;
|
sl@0
|
100 |
TUint32 value = aColor & 0x00ffffff;
|
sl@0
|
101 |
if (iShadowMode & EFade)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
#if defined(SYMBIAN_USE_FAST_FADING)
|
sl@0
|
104 |
const TUint32 fast_fade_offset = NonPMA2PMAPixel((aColor & 0xff000000) | SYMBIAN_USE_FAST_FADING) & 0x00ffffff;
|
sl@0
|
105 |
value = ((value >> 1) & ~0x00808080) + (fast_fade_offset);
|
sl@0
|
106 |
#else
|
sl@0
|
107 |
const TInt fadeMapOffset = ((alpha * iFadeMapOffset) >> 8) & 0xff;
|
sl@0
|
108 |
const TInt wordFadeMapOffset = ((fadeMapOffset) << 16) | (fadeMapOffset);
|
sl@0
|
109 |
const TInt rb = ((((value & 0x00ff00ff) * iFadeMapFactor) >> 8) + wordFadeMapOffset) & 0x00ff00ff;
|
sl@0
|
110 |
const TInt g = ((((value & 0x0000ff00) * iFadeMapFactor) >> 16) + fadeMapOffset) << 8;
|
sl@0
|
111 |
value = rb | g;
|
sl@0
|
112 |
#endif
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
if (iShadowMode & EShadow)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
const TInt uLimit = ((0x40) * alpha) >> 8;
|
sl@0
|
118 |
TInt r = (value >> 16) & 0xff;
|
sl@0
|
119 |
r = (r > uLimit) ? (r-uLimit) : 0;
|
sl@0
|
120 |
TInt g = (value >> 8) & 0xff;
|
sl@0
|
121 |
g = (g > uLimit) ? (g - uLimit) : 0;
|
sl@0
|
122 |
TInt b = value & 0xff;
|
sl@0
|
123 |
b = (b > uLimit) ? (b - uLimit) : 0;
|
sl@0
|
124 |
value = (r << 16) | (g << 8) | b;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
// alpha is unchanged.
|
sl@0
|
127 |
aColor = (aColor & 0xff000000) | value;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
TUint8 CDrawThirtyTwoBppBitmapCommon::ShadowAndFade(TInt aComponent)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
if (iShadowMode & EFade)
|
sl@0
|
133 |
aComponent = FadeGray(aComponent);
|
sl@0
|
134 |
|
sl@0
|
135 |
if (iShadowMode & EShadow)
|
sl@0
|
136 |
aComponent = ShadowComponent(aComponent);
|
sl@0
|
137 |
|
sl@0
|
138 |
return TUint8(aComponent);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
TUint8 CDrawThirtyTwoBppBitmapCommon::ShadowComponent(TInt aRgbComponent)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
return TUint8(Max(0,aRgbComponent-0x40));
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
void CDrawThirtyTwoBppBitmapCommon::InvertBuffer(TInt aLength,TUint32* aBuffer)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
__ASSERT_DEBUG(aLength>0,Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
149 |
__ASSERT_DEBUG(aBuffer,Panic(EScreenDriverPanicNullPointer));
|
sl@0
|
150 |
|
sl@0
|
151 |
TUint32* limit = aBuffer + aLength;
|
sl@0
|
152 |
|
sl@0
|
153 |
while (aBuffer < limit)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
*aBuffer++ ^= 0x00ffffff;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
void CDrawThirtyTwoBppBitmapCommon::ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const
|
sl@0
|
160 |
{
|
sl@0
|
161 |
const TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
162 |
|
sl@0
|
163 |
if (iOrientation == EOrientationNormal)
|
sl@0
|
164 |
Mem::Copy(aBuffer,pixelPtr,aLength << 2);
|
sl@0
|
165 |
else
|
sl@0
|
166 |
{
|
sl@0
|
167 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
168 |
|
sl@0
|
169 |
TUint32* bufferPtr = static_cast <TUint32*> (aBuffer);
|
sl@0
|
170 |
const TUint32* bufferPtrLimit = bufferPtr + aLength;
|
sl@0
|
171 |
|
sl@0
|
172 |
while (bufferPtr < bufferPtrLimit)
|
sl@0
|
173 |
{
|
sl@0
|
174 |
*bufferPtr++ = *pixelPtr;
|
sl@0
|
175 |
pixelPtr += pixelPtrInc;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
}
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
TRgb CDrawThirtyTwoBppBitmapCommon::ReadRgbNormal(TInt aX,TInt aY) const
|
sl@0
|
181 |
{
|
sl@0
|
182 |
return RgbColor(*PixelAddress(aX,aY));
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
void CDrawThirtyTwoBppBitmapCommon::ShadowArea(const TRect& aRect)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
const TRect rect(DeOrientate(aRect));
|
sl@0
|
188 |
|
sl@0
|
189 |
__ASSERT_DEBUG(rect.iTl.iX>=0 && rect.iBr.iX<=iSize.iWidth,Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
190 |
__ASSERT_DEBUG(rect.iTl.iY>=0 && rect.iBr.iY<=iSize.iHeight,Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
191 |
|
sl@0
|
192 |
TUint32* pixelPtr = PixelAddress(rect.iTl.iX,rect.iTl.iY);
|
sl@0
|
193 |
TUint32* pixelRowPtrLimit = pixelPtr + (rect.Height() * iScanLineWords);
|
sl@0
|
194 |
|
sl@0
|
195 |
TUint32* pixelRowPtr = pixelPtr;
|
sl@0
|
196 |
TUint32* pixelPtrLimit = pixelPtr + rect.Width();
|
sl@0
|
197 |
|
sl@0
|
198 |
if (iShadowMode & EFade)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
#if !defined(SYMBIAN_USE_FAST_FADING)
|
sl@0
|
201 |
const TInt wordFadeMapOffset = ((iFadeMapOffset & 0xff) << 16) | (iFadeMapOffset & 0xff);
|
sl@0
|
202 |
#endif
|
sl@0
|
203 |
while (pixelRowPtr < pixelRowPtrLimit)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
TUint32* tempPixelPtr = pixelRowPtr;
|
sl@0
|
206 |
|
sl@0
|
207 |
while (tempPixelPtr < pixelPtrLimit)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
#if defined(SYMBIAN_USE_FAST_FADING)
|
sl@0
|
210 |
*tempPixelPtr++ = 0xff000000 | ((((*tempPixelPtr) >> 1) & ~0x00808080) + (SYMBIAN_USE_FAST_FADING));
|
sl@0
|
211 |
#else
|
sl@0
|
212 |
const TUint32 color = *tempPixelPtr;
|
sl@0
|
213 |
const TInt rb = ((((color & 0x00ff00ff) * iFadeMapFactor) >> 8) + wordFadeMapOffset) & 0x00ff00ff;
|
sl@0
|
214 |
const TInt g = ((((color & 0x0000ff00) * iFadeMapFactor) >> 16) + iFadeMapOffset) << 8;
|
sl@0
|
215 |
*tempPixelPtr++ = 0xff000000 | rb | g;
|
sl@0
|
216 |
#endif
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
pixelRowPtr += iScanLineWords;
|
sl@0
|
220 |
pixelPtrLimit += iScanLineWords;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
}
|
sl@0
|
223 |
|
sl@0
|
224 |
if (iShadowMode & EShadow)
|
sl@0
|
225 |
{
|
sl@0
|
226 |
pixelRowPtr = pixelPtr;
|
sl@0
|
227 |
pixelPtrLimit = pixelPtr + rect.Width();
|
sl@0
|
228 |
while (pixelRowPtr < pixelRowPtrLimit)
|
sl@0
|
229 |
{
|
sl@0
|
230 |
TUint32* tempPixelPtr = pixelRowPtr;
|
sl@0
|
231 |
|
sl@0
|
232 |
while (tempPixelPtr < pixelPtrLimit)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
const TUint32 color = *tempPixelPtr;
|
sl@0
|
235 |
const TInt r = (color & 0x00c00000) ? ((color & 0x00ff0000)-0x00400000) : 0;
|
sl@0
|
236 |
const TInt g = (color & 0x0000c000) ? ((color & 0x0000ff00)-0x00004000) : 0;
|
sl@0
|
237 |
const TInt b = (color & 0x000000c0) ? ((color & 0x000000ff)-0x00000040) : 0;
|
sl@0
|
238 |
*tempPixelPtr++ = 0xff000000 | r | g | b;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
pixelRowPtr += iScanLineWords;
|
sl@0
|
242 |
pixelPtrLimit += iScanLineWords;
|
sl@0
|
243 |
}
|
sl@0
|
244 |
}
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
void CDrawThirtyTwoBppBitmapCommon::ShadowBuffer(TInt aLength,TUint32* aBuffer)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
__ASSERT_DEBUG(aLength>0,Panic(EScreenDriverPanicZeroLength));
|
sl@0
|
250 |
__ASSERT_DEBUG(aBuffer,Panic(EScreenDriverPanicNullPointer));
|
sl@0
|
251 |
|
sl@0
|
252 |
TUint32* limit = aBuffer + aLength;
|
sl@0
|
253 |
|
sl@0
|
254 |
while (aBuffer < limit)
|
sl@0
|
255 |
Shadow(*aBuffer++);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgb(TInt aX,TInt aY,TRgb aColor)
|
sl@0
|
259 |
{
|
sl@0
|
260 |
TUint8* componentPtr = reinterpret_cast <TUint8*> (PixelAddress(aX,aY));
|
sl@0
|
261 |
const TInt sourceAlpha = aColor.Alpha();
|
sl@0
|
262 |
|
sl@0
|
263 |
if (sourceAlpha==0)
|
sl@0
|
264 |
return;
|
sl@0
|
265 |
if(sourceAlpha != 0xff)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
aColor = AlphaBlend(aColor.Red(), aColor.Green(), aColor.Blue(), TRgb(componentPtr[2], componentPtr[1], componentPtr[0]), sourceAlpha);
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
componentPtr[0] = TUint8(aColor.Blue());
|
sl@0
|
271 |
componentPtr[1] = TUint8(aColor.Green());
|
sl@0
|
272 |
componentPtr[2] = TUint8(aColor.Red());
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
void CDrawThirtyTwoBppBitmapCommon::WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor)
|
sl@0
|
276 |
{
|
sl@0
|
277 |
const TInt sourceAlpha = aColor.Alpha();
|
sl@0
|
278 |
if(sourceAlpha == 0)
|
sl@0
|
279 |
return;
|
sl@0
|
280 |
DeOrientate(aX,aY);
|
sl@0
|
281 |
|
sl@0
|
282 |
TInt pixelInc;
|
sl@0
|
283 |
TInt rowInc;
|
sl@0
|
284 |
|
sl@0
|
285 |
switch(iOrientation)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
case EOrientationNormal:
|
sl@0
|
288 |
{
|
sl@0
|
289 |
pixelInc = 1;
|
sl@0
|
290 |
rowInc = iScanLineWords;
|
sl@0
|
291 |
break;
|
sl@0
|
292 |
}
|
sl@0
|
293 |
case EOrientationRotated90:
|
sl@0
|
294 |
{
|
sl@0
|
295 |
pixelInc = iScanLineWords;
|
sl@0
|
296 |
rowInc = -1;
|
sl@0
|
297 |
break;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
case EOrientationRotated180:
|
sl@0
|
300 |
{
|
sl@0
|
301 |
pixelInc = -1;
|
sl@0
|
302 |
rowInc = -iScanLineWords;
|
sl@0
|
303 |
break;
|
sl@0
|
304 |
}
|
sl@0
|
305 |
default: // EOrientationRotated270
|
sl@0
|
306 |
{
|
sl@0
|
307 |
pixelInc = -iScanLineWords;
|
sl@0
|
308 |
rowInc = 1;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
const TUint32* dataLimit = aBuffer + aHeight;
|
sl@0
|
313 |
const TUint32 dataMaskLimit = (aLength < 32) ? 1 << aLength : 0;
|
sl@0
|
314 |
|
sl@0
|
315 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
316 |
|
sl@0
|
317 |
if(sourceAlpha == 255) //we split code on two parts because of performance reasons
|
sl@0
|
318 |
{
|
sl@0
|
319 |
TInt color = Color(aColor);
|
sl@0
|
320 |
while (aBuffer < dataLimit)
|
sl@0
|
321 |
{
|
sl@0
|
322 |
TUint32 dataWord = *aBuffer++;
|
sl@0
|
323 |
TUint32 dataMask = 1;
|
sl@0
|
324 |
TUint32* tempPixelPtr = pixelPtr;
|
sl@0
|
325 |
|
sl@0
|
326 |
while (dataMask != dataMaskLimit)
|
sl@0
|
327 |
{
|
sl@0
|
328 |
if(dataWord & dataMask)
|
sl@0
|
329 |
{
|
sl@0
|
330 |
*tempPixelPtr = color;
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
tempPixelPtr += pixelInc;
|
sl@0
|
334 |
dataMask <<= 1;
|
sl@0
|
335 |
}
|
sl@0
|
336 |
|
sl@0
|
337 |
pixelPtr += rowInc;
|
sl@0
|
338 |
}
|
sl@0
|
339 |
}
|
sl@0
|
340 |
else //sourceAlpha != 255
|
sl@0
|
341 |
{
|
sl@0
|
342 |
const TUint32 sourceInternal=aColor.Internal();
|
sl@0
|
343 |
const TUint32 s_rb = sourceInternal & 0x00FF00FF;
|
sl@0
|
344 |
const TUint32 s_g = (sourceInternal & 0xFF00) >> 8;
|
sl@0
|
345 |
const TUint32 mask2 = sourceAlpha | (sourceAlpha << 16);
|
sl@0
|
346 |
while (aBuffer < dataLimit)
|
sl@0
|
347 |
{
|
sl@0
|
348 |
TUint32 dataWord = *aBuffer++;
|
sl@0
|
349 |
TUint32 dataMask = 1;
|
sl@0
|
350 |
TUint32* tempPixelPtr = pixelPtr;
|
sl@0
|
351 |
|
sl@0
|
352 |
while (dataMask != dataMaskLimit)
|
sl@0
|
353 |
{
|
sl@0
|
354 |
if (dataWord & dataMask)
|
sl@0
|
355 |
{
|
sl@0
|
356 |
BlendFromRBandG(tempPixelPtr,s_rb,s_g,sourceAlpha,mask2);
|
sl@0
|
357 |
}
|
sl@0
|
358 |
|
sl@0
|
359 |
tempPixelPtr += pixelInc;
|
sl@0
|
360 |
dataMask <<= 1;
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
pixelPtr += rowInc;
|
sl@0
|
364 |
}
|
sl@0
|
365 |
}
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
void CDrawThirtyTwoBppBitmapCommon::WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode)
|
sl@0
|
369 |
{
|
sl@0
|
370 |
if (aLength <= 0)
|
sl@0
|
371 |
return;
|
sl@0
|
372 |
|
sl@0
|
373 |
DeOrientate(aX,aY);
|
sl@0
|
374 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
375 |
|
sl@0
|
376 |
const TUint32* dataPtrLimit = aBuffer + aHeight;
|
sl@0
|
377 |
const TUint32 dataMaskLimit = (aLength < 32) ? 1 << aLength : 0;
|
sl@0
|
378 |
|
sl@0
|
379 |
TInt pixelInc;
|
sl@0
|
380 |
TInt rowInc;
|
sl@0
|
381 |
|
sl@0
|
382 |
if (iOrientation == EOrientationNormal)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
pixelInc = 1;
|
sl@0
|
385 |
rowInc = iScanLineWords;
|
sl@0
|
386 |
}
|
sl@0
|
387 |
else if (iOrientation == EOrientationRotated90)
|
sl@0
|
388 |
{
|
sl@0
|
389 |
pixelInc = iScanLineWords;
|
sl@0
|
390 |
rowInc = -1;
|
sl@0
|
391 |
}
|
sl@0
|
392 |
else if (iOrientation == EOrientationRotated180)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
pixelInc = -1;
|
sl@0
|
395 |
rowInc = -iScanLineWords;
|
sl@0
|
396 |
}
|
sl@0
|
397 |
else // EOrientationRotated270
|
sl@0
|
398 |
{
|
sl@0
|
399 |
pixelInc = -iScanLineWords;
|
sl@0
|
400 |
rowInc = 1;
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
TInt color = Color(aColor);// & 0x00FFFFFF;
|
sl@0
|
404 |
|
sl@0
|
405 |
if (color != 0)
|
sl@0
|
406 |
{
|
sl@0
|
407 |
while (aBuffer < dataPtrLimit)
|
sl@0
|
408 |
{
|
sl@0
|
409 |
TUint32 dataWord = *aBuffer++;
|
sl@0
|
410 |
TUint32 dataMask = 1;
|
sl@0
|
411 |
TUint32* tempPixelPtr = pixelPtr;
|
sl@0
|
412 |
|
sl@0
|
413 |
while (dataMask != dataMaskLimit)
|
sl@0
|
414 |
{
|
sl@0
|
415 |
if(dataWord & dataMask)
|
sl@0
|
416 |
{
|
sl@0
|
417 |
if(aDrawMode==CGraphicsContext::EDrawModeXOR)
|
sl@0
|
418 |
{
|
sl@0
|
419 |
*tempPixelPtr ^= color;
|
sl@0
|
420 |
}
|
sl@0
|
421 |
else if(aDrawMode==CGraphicsContext::EDrawModeAND)
|
sl@0
|
422 |
{
|
sl@0
|
423 |
*tempPixelPtr &= color;
|
sl@0
|
424 |
}
|
sl@0
|
425 |
else if(aDrawMode==CGraphicsContext::EDrawModeOR)
|
sl@0
|
426 |
{
|
sl@0
|
427 |
*tempPixelPtr |= color;
|
sl@0
|
428 |
}
|
sl@0
|
429 |
}
|
sl@0
|
430 |
|
sl@0
|
431 |
tempPixelPtr += pixelInc;
|
sl@0
|
432 |
dataMask <<= 1;
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
pixelPtr += rowInc;
|
sl@0
|
436 |
}
|
sl@0
|
437 |
}
|
sl@0
|
438 |
else if (aDrawMode == CGraphicsContext::EDrawModeAND)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
while (aBuffer < dataPtrLimit)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
TUint32 dataWord = *aBuffer++;
|
sl@0
|
443 |
TUint32 dataMask = 1;
|
sl@0
|
444 |
TUint32* tempPixelPtr = pixelPtr;
|
sl@0
|
445 |
|
sl@0
|
446 |
while (dataMask != dataMaskLimit)
|
sl@0
|
447 |
{
|
sl@0
|
448 |
if(dataWord & dataMask)
|
sl@0
|
449 |
{
|
sl@0
|
450 |
*tempPixelPtr = 0;
|
sl@0
|
451 |
}
|
sl@0
|
452 |
|
sl@0
|
453 |
tempPixelPtr += pixelInc;
|
sl@0
|
454 |
dataMask <<= 1;
|
sl@0
|
455 |
}
|
sl@0
|
456 |
|
sl@0
|
457 |
pixelPtr += rowInc;
|
sl@0
|
458 |
}
|
sl@0
|
459 |
}
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
void CDrawThirtyTwoBppBitmapCommon::WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aHeight,TRgb aColor,TBool aUp)
|
sl@0
|
463 |
{
|
sl@0
|
464 |
const TInt sourceAlpha = aColor.Alpha();
|
sl@0
|
465 |
if(sourceAlpha == 0)
|
sl@0
|
466 |
return;
|
sl@0
|
467 |
DeOrientate(aX,aY);
|
sl@0
|
468 |
|
sl@0
|
469 |
TInt scanlineWordLength;
|
sl@0
|
470 |
|
sl@0
|
471 |
if (iOrientation == EOrientationNormal)
|
sl@0
|
472 |
scanlineWordLength = iScanLineWords;
|
sl@0
|
473 |
else if (iOrientation == EOrientationRotated90)
|
sl@0
|
474 |
scanlineWordLength = -1;
|
sl@0
|
475 |
else if (iOrientation == EOrientationRotated180)
|
sl@0
|
476 |
scanlineWordLength = -iScanLineWords;
|
sl@0
|
477 |
else // EOrientationRotated270
|
sl@0
|
478 |
scanlineWordLength = 1;
|
sl@0
|
479 |
|
sl@0
|
480 |
if (aUp)
|
sl@0
|
481 |
scanlineWordLength = -scanlineWordLength;
|
sl@0
|
482 |
|
sl@0
|
483 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
484 |
const TUint32* pixelPtrLimit = pixelPtr + (aHeight * scanlineWordLength);
|
sl@0
|
485 |
TUint32 dataWord = *aBuffer;
|
sl@0
|
486 |
TUint32 dataMask = 1;
|
sl@0
|
487 |
|
sl@0
|
488 |
if(sourceAlpha == 255) //we split code on two parts because of performance reasons
|
sl@0
|
489 |
{
|
sl@0
|
490 |
TInt color = Color(aColor);
|
sl@0
|
491 |
while(pixelPtr != pixelPtrLimit)
|
sl@0
|
492 |
{
|
sl@0
|
493 |
if(!dataMask)
|
sl@0
|
494 |
{
|
sl@0
|
495 |
dataMask = 1;
|
sl@0
|
496 |
aBuffer++;
|
sl@0
|
497 |
dataWord = *aBuffer;
|
sl@0
|
498 |
}
|
sl@0
|
499 |
|
sl@0
|
500 |
if(dataWord & dataMask)
|
sl@0
|
501 |
{
|
sl@0
|
502 |
*pixelPtr = color;
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
dataMask <<= 1;
|
sl@0
|
506 |
pixelPtr += scanlineWordLength;
|
sl@0
|
507 |
}
|
sl@0
|
508 |
}
|
sl@0
|
509 |
else //sourceAlpha != 255
|
sl@0
|
510 |
{
|
sl@0
|
511 |
const TUint32 sourceInternal=aColor.Internal();
|
sl@0
|
512 |
const TUint32 s_rb = sourceInternal & 0x00FF00FF;
|
sl@0
|
513 |
const TUint32 s_g = (sourceInternal & 0xFF00) >> 8;
|
sl@0
|
514 |
const TUint32 mask2 = sourceAlpha | (sourceAlpha << 16);
|
sl@0
|
515 |
while(pixelPtr != pixelPtrLimit)
|
sl@0
|
516 |
{
|
sl@0
|
517 |
if(!dataMask)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
dataMask = 1;
|
sl@0
|
520 |
aBuffer++;
|
sl@0
|
521 |
dataWord = *aBuffer;
|
sl@0
|
522 |
}
|
sl@0
|
523 |
|
sl@0
|
524 |
if(dataWord & dataMask)
|
sl@0
|
525 |
{
|
sl@0
|
526 |
BlendFromRBandG(pixelPtr, s_rb, s_g, sourceAlpha, mask2);
|
sl@0
|
527 |
}
|
sl@0
|
528 |
|
sl@0
|
529 |
dataMask <<= 1;
|
sl@0
|
530 |
pixelPtr += scanlineWordLength;
|
sl@0
|
531 |
}
|
sl@0
|
532 |
}
|
sl@0
|
533 |
}
|
sl@0
|
534 |
|
sl@0
|
535 |
void CDrawThirtyTwoBppBitmapCommon::WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer)
|
sl@0
|
536 |
{
|
sl@0
|
537 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
538 |
|
sl@0
|
539 |
if (iOrientation == EOrientationNormal)
|
sl@0
|
540 |
Mem::Copy(pixelPtr,aBuffer,aLength << 2);
|
sl@0
|
541 |
else
|
sl@0
|
542 |
{
|
sl@0
|
543 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
544 |
|
sl@0
|
545 |
TUint32* bufferPtrLimit = aBuffer + aLength;
|
sl@0
|
546 |
|
sl@0
|
547 |
while (aBuffer < bufferPtrLimit)
|
sl@0
|
548 |
{
|
sl@0
|
549 |
*pixelPtr = *aBuffer++;
|
sl@0
|
550 |
pixelPtr += pixelPtrInc;
|
sl@0
|
551 |
}
|
sl@0
|
552 |
}
|
sl@0
|
553 |
}
|
sl@0
|
554 |
|
sl@0
|
555 |
void CDrawThirtyTwoBppBitmapCommon::WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer)
|
sl@0
|
556 |
{
|
sl@0
|
557 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
558 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
559 |
|
sl@0
|
560 |
TUint32* bufferPtrLimit = aBuffer + aLength;
|
sl@0
|
561 |
|
sl@0
|
562 |
while (aBuffer < bufferPtrLimit)
|
sl@0
|
563 |
{
|
sl@0
|
564 |
*pixelPtr ^= *aBuffer++;
|
sl@0
|
565 |
pixelPtr += pixelPtrInc;
|
sl@0
|
566 |
}
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
void CDrawThirtyTwoBppBitmapCommon::WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer)
|
sl@0
|
570 |
{
|
sl@0
|
571 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
572 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
573 |
|
sl@0
|
574 |
TUint32* bufferPtrLimit = aBuffer + aLength;
|
sl@0
|
575 |
|
sl@0
|
576 |
while (aBuffer < bufferPtrLimit)
|
sl@0
|
577 |
{
|
sl@0
|
578 |
*pixelPtr &= *aBuffer++;
|
sl@0
|
579 |
pixelPtr += pixelPtrInc;
|
sl@0
|
580 |
}
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
void CDrawThirtyTwoBppBitmapCommon::WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer)
|
sl@0
|
584 |
{
|
sl@0
|
585 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
586 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
587 |
|
sl@0
|
588 |
TUint32* bufferPtrLimit = aBuffer + aLength;
|
sl@0
|
589 |
|
sl@0
|
590 |
while (aBuffer < bufferPtrLimit)
|
sl@0
|
591 |
{
|
sl@0
|
592 |
*pixelPtr |= *aBuffer++;
|
sl@0
|
593 |
pixelPtr += pixelPtrInc;
|
sl@0
|
594 |
}
|
sl@0
|
595 |
}
|
sl@0
|
596 |
|
sl@0
|
597 |
/**
|
sl@0
|
598 |
MAlphaBlend::WriteRgbAlphaLine() implementation.
|
sl@0
|
599 |
@see MAlphaBlend::WriteRgbAlphaLine()
|
sl@0
|
600 |
*/
|
sl@0
|
601 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgbAlphaLine(TInt aX, TInt aY, TInt aLength,
|
sl@0
|
602 |
const TUint8* aRgbBuffer,
|
sl@0
|
603 |
const TUint8* aMaskBuffer,
|
sl@0
|
604 |
MAlphaBlend::TShadowing aShadowing,
|
sl@0
|
605 |
CGraphicsContext::TDrawMode /*aDrawMode*/)
|
sl@0
|
606 |
{
|
sl@0
|
607 |
DeOrientate(aX,aY);
|
sl@0
|
608 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
609 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
610 |
const TUint8* maskBufferPtrLimit = aMaskBuffer + aLength;
|
sl@0
|
611 |
|
sl@0
|
612 |
while (aMaskBuffer < maskBufferPtrLimit)
|
sl@0
|
613 |
{
|
sl@0
|
614 |
TRgb srcColor(aRgbBuffer[2],aRgbBuffer[1],aRgbBuffer[0]);// !! we don't have any alpha information for the source, so assume opaque
|
sl@0
|
615 |
if(aMaskBuffer[0])
|
sl@0
|
616 |
{
|
sl@0
|
617 |
if(aShadowing == MAlphaBlend::EShdwBefore)
|
sl@0
|
618 |
{
|
sl@0
|
619 |
Shadow(srcColor);
|
sl@0
|
620 |
}
|
sl@0
|
621 |
TUint8* componentPtr = reinterpret_cast <TUint8*> (pixelPtr);
|
sl@0
|
622 |
if(aMaskBuffer[0] != 0xff)
|
sl@0
|
623 |
{
|
sl@0
|
624 |
srcColor = AlphaBlend(srcColor.Red(), srcColor.Green(), srcColor.Blue(), TRgb(componentPtr[2], componentPtr[1], componentPtr[0]), aMaskBuffer[0]);
|
sl@0
|
625 |
}
|
sl@0
|
626 |
if(aShadowing == MAlphaBlend::EShdwAfter)
|
sl@0
|
627 |
{
|
sl@0
|
628 |
Shadow(srcColor);
|
sl@0
|
629 |
}
|
sl@0
|
630 |
MapColorToUserDisplayMode(srcColor);
|
sl@0
|
631 |
componentPtr[0] = TUint8(srcColor.Blue());
|
sl@0
|
632 |
componentPtr[1] = TUint8(srcColor.Green());
|
sl@0
|
633 |
componentPtr[2] = TUint8(srcColor.Red());
|
sl@0
|
634 |
}
|
sl@0
|
635 |
pixelPtr += pixelPtrInc;
|
sl@0
|
636 |
aRgbBuffer += 4;
|
sl@0
|
637 |
aMaskBuffer++;
|
sl@0
|
638 |
}
|
sl@0
|
639 |
}
|
sl@0
|
640 |
|
sl@0
|
641 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor)
|
sl@0
|
642 |
{
|
sl@0
|
643 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
644 |
TUint32* pixelRowPtrLimit = pixelPtr + (aHeight * iScanLineWords);
|
sl@0
|
645 |
|
sl@0
|
646 |
TInt color = Color(aColor);
|
sl@0
|
647 |
|
sl@0
|
648 |
while (pixelPtr < pixelRowPtrLimit)
|
sl@0
|
649 |
{
|
sl@0
|
650 |
MemFillTUint32(pixelPtr, aLength, color);
|
sl@0
|
651 |
pixelPtr += iScanLineWords;
|
sl@0
|
652 |
}
|
sl@0
|
653 |
}
|
sl@0
|
654 |
|
sl@0
|
655 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor)
|
sl@0
|
656 |
{
|
sl@0
|
657 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
658 |
TUint32* pixelPtrLimit = pixelPtr + aLength;
|
sl@0
|
659 |
TUint32* pixelRowPtrLimit = pixelPtr + (aHeight * iScanLineWords);
|
sl@0
|
660 |
TInt color = Color(aColor);
|
sl@0
|
661 |
|
sl@0
|
662 |
while (pixelPtr < pixelRowPtrLimit)
|
sl@0
|
663 |
{
|
sl@0
|
664 |
for (TUint32* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++)
|
sl@0
|
665 |
{
|
sl@0
|
666 |
*tempPixelPtr ^= color;
|
sl@0
|
667 |
}
|
sl@0
|
668 |
|
sl@0
|
669 |
pixelPtr += iScanLineWords;
|
sl@0
|
670 |
pixelPtrLimit += iScanLineWords;
|
sl@0
|
671 |
}
|
sl@0
|
672 |
}
|
sl@0
|
673 |
|
sl@0
|
674 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor)
|
sl@0
|
675 |
{
|
sl@0
|
676 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
677 |
TUint32* pixelPtrLimit = pixelPtr + aLength;
|
sl@0
|
678 |
TUint32* pixelRowPtrLimit = pixelPtr + (aHeight * iScanLineWords);
|
sl@0
|
679 |
TInt color = Color(aColor);
|
sl@0
|
680 |
|
sl@0
|
681 |
while (pixelPtr < pixelRowPtrLimit)
|
sl@0
|
682 |
{
|
sl@0
|
683 |
for (TUint32* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++)
|
sl@0
|
684 |
{
|
sl@0
|
685 |
*tempPixelPtr &= color;
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
pixelPtr += iScanLineWords;
|
sl@0
|
689 |
pixelPtrLimit += iScanLineWords;
|
sl@0
|
690 |
}
|
sl@0
|
691 |
}
|
sl@0
|
692 |
|
sl@0
|
693 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor)
|
sl@0
|
694 |
{
|
sl@0
|
695 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
696 |
TUint32* pixelPtrLimit = pixelPtr + aLength;
|
sl@0
|
697 |
TUint32* pixelRowPtrLimit = pixelPtr + (aHeight * iScanLineWords);
|
sl@0
|
698 |
TInt color = Color(aColor);
|
sl@0
|
699 |
|
sl@0
|
700 |
while (pixelPtr < pixelRowPtrLimit)
|
sl@0
|
701 |
{
|
sl@0
|
702 |
for (TUint32* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++)
|
sl@0
|
703 |
{
|
sl@0
|
704 |
*tempPixelPtr |= color;
|
sl@0
|
705 |
}
|
sl@0
|
706 |
|
sl@0
|
707 |
pixelPtr += iScanLineWords;
|
sl@0
|
708 |
pixelPtrLimit += iScanLineWords;
|
sl@0
|
709 |
}
|
sl@0
|
710 |
}
|
sl@0
|
711 |
|
sl@0
|
712 |
inline TUint32 OptimizedBlend32(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue,TUint32 aSecondary,TUint8 aAlphaValue)
|
sl@0
|
713 |
{
|
sl@0
|
714 |
__ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8),
|
sl@0
|
715 |
Panic(EScreenDriverPanicAlphaBlendInvariant));
|
sl@0
|
716 |
|
sl@0
|
717 |
if(aAlphaValue == 0xff)
|
sl@0
|
718 |
{
|
sl@0
|
719 |
return (aPrimaryBlue + (aPrimaryGreen<<8) + (aPrimaryRed<<16)) | 0xff000000;
|
sl@0
|
720 |
}
|
sl@0
|
721 |
else
|
sl@0
|
722 |
{
|
sl@0
|
723 |
const TUint32 alphaValue = (aAlphaValue << 8) + aAlphaValue;
|
sl@0
|
724 |
|
sl@0
|
725 |
const TInt r2 = (aSecondary & 0x00ff0000) >> 16;
|
sl@0
|
726 |
const TInt g2 = (aSecondary & 0x0000ff00) >> 8;
|
sl@0
|
727 |
const TInt b2 = aSecondary & 0x000000ff;
|
sl@0
|
728 |
|
sl@0
|
729 |
const TInt r3 = ((alphaValue * (aPrimaryRed - r2)) >> 16) + r2;
|
sl@0
|
730 |
const TInt g3 = ((alphaValue * (aPrimaryGreen - g2)) >> 16) + g2;
|
sl@0
|
731 |
const TInt b3 = ((alphaValue * (aPrimaryBlue - b2)) >> 16) + b2;
|
sl@0
|
732 |
|
sl@0
|
733 |
return (b3 & 0xFF) | ((g3<<8) & 0xFF00) | ((r3<<16) & 0xFF0000) | 0xFF000000;
|
sl@0
|
734 |
}
|
sl@0
|
735 |
}
|
sl@0
|
736 |
|
sl@0
|
737 |
void CDrawThirtyTwoBppBitmapCommon::WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer)
|
sl@0
|
738 |
{
|
sl@0
|
739 |
const TUint32 sourceAlpha = aColor.Alpha();
|
sl@0
|
740 |
if (sourceAlpha==0 || aLength<=0)
|
sl@0
|
741 |
return;
|
sl@0
|
742 |
DeOrientate(aX,aY);
|
sl@0
|
743 |
TUint32* pixelPtr = PixelAddress(aX,aY);
|
sl@0
|
744 |
const TInt pixelPtrInc = PixelAddressIncrement();
|
sl@0
|
745 |
const TUint8* maskBufferPtrLimit = aMaskBuffer + aLength;
|
sl@0
|
746 |
|
sl@0
|
747 |
if (iShadowMode)
|
sl@0
|
748 |
Shadow(aColor);
|
sl@0
|
749 |
|
sl@0
|
750 |
const TUint32 sourceInternal=aColor.Internal();
|
sl@0
|
751 |
const TUint32 s_rb = sourceInternal & 0x00FF00FF;
|
sl@0
|
752 |
const TUint32 s_g = (sourceInternal & 0xFF00) >> 8;
|
sl@0
|
753 |
if (sourceAlpha==0xFF)
|
sl@0
|
754 |
{
|
sl@0
|
755 |
while (aMaskBuffer < maskBufferPtrLimit)
|
sl@0
|
756 |
{
|
sl@0
|
757 |
const TUint32 maskAlpha=*aMaskBuffer;
|
sl@0
|
758 |
if (maskAlpha)
|
sl@0
|
759 |
{
|
sl@0
|
760 |
if (maskAlpha==0xFF)
|
sl@0
|
761 |
*pixelPtr = sourceInternal;
|
sl@0
|
762 |
else
|
sl@0
|
763 |
BlendFromRBandG(pixelPtr,s_rb,s_g,maskAlpha,maskAlpha|(maskAlpha<<16));
|
sl@0
|
764 |
}
|
sl@0
|
765 |
pixelPtr += pixelPtrInc;
|
sl@0
|
766 |
aMaskBuffer++;
|
sl@0
|
767 |
}
|
sl@0
|
768 |
}
|
sl@0
|
769 |
else
|
sl@0
|
770 |
{
|
sl@0
|
771 |
while (aMaskBuffer < maskBufferPtrLimit)
|
sl@0
|
772 |
{
|
sl@0
|
773 |
const TUint32 maskAlpha=*aMaskBuffer;
|
sl@0
|
774 |
if (maskAlpha)
|
sl@0
|
775 |
{
|
sl@0
|
776 |
TUint blendAlpha = sourceAlpha;
|
sl@0
|
777 |
if (maskAlpha!=0xFF)
|
sl@0
|
778 |
blendAlpha=((maskAlpha+1) * sourceAlpha)>>8;
|
sl@0
|
779 |
BlendFromRBandG(pixelPtr,s_rb,s_g,blendAlpha,blendAlpha|(blendAlpha<<16));
|
sl@0
|
780 |
}
|
sl@0
|
781 |
pixelPtr += pixelPtrInc;
|
sl@0
|
782 |
aMaskBuffer++;
|
sl@0
|
783 |
}
|
sl@0
|
784 |
}
|
sl@0
|
785 |
}
|
sl@0
|
786 |
|
sl@0
|
787 |
void CDrawThirtyTwoBppBitmapCommon::MapColorToUserDisplayMode(TRgb& aColor)
|
sl@0
|
788 |
{
|
sl@0
|
789 |
const TInt alpha = aColor.Alpha();
|
sl@0
|
790 |
switch (iUserDispMode)
|
sl@0
|
791 |
{
|
sl@0
|
792 |
case EGray2:
|
sl@0
|
793 |
aColor = TRgb::_Gray2(aColor._Gray2());
|
sl@0
|
794 |
break;
|
sl@0
|
795 |
case EGray4:
|
sl@0
|
796 |
aColor = TRgb::_Gray4(aColor._Gray4());
|
sl@0
|
797 |
break;
|
sl@0
|
798 |
case EGray16:
|
sl@0
|
799 |
aColor = TRgb::_Gray16(aColor._Gray16());
|
sl@0
|
800 |
break;
|
sl@0
|
801 |
case EGray256:
|
sl@0
|
802 |
aColor = TRgb::_Gray256(aColor._Gray256());
|
sl@0
|
803 |
break;
|
sl@0
|
804 |
case EColor16:
|
sl@0
|
805 |
aColor = TRgb::Color16(aColor.Color16());
|
sl@0
|
806 |
break;
|
sl@0
|
807 |
case EColor256:
|
sl@0
|
808 |
aColor = TRgb::Color256(aColor.Color256());
|
sl@0
|
809 |
break;
|
sl@0
|
810 |
case EColor4K:
|
sl@0
|
811 |
aColor = TRgb::_Color4K(aColor._Color4K());
|
sl@0
|
812 |
break;
|
sl@0
|
813 |
case EColor64K:
|
sl@0
|
814 |
aColor = TRgb::_Color64K(aColor._Color64K());
|
sl@0
|
815 |
break;
|
sl@0
|
816 |
default:
|
sl@0
|
817 |
break;
|
sl@0
|
818 |
}
|
sl@0
|
819 |
aColor.SetAlpha(alpha);
|
sl@0
|
820 |
}
|
sl@0
|
821 |
|
sl@0
|
822 |
void CDrawThirtyTwoBppBitmapCommon::MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer)
|
sl@0
|
823 |
{
|
sl@0
|
824 |
const TUint32* bufferLimit = aBuffer + aLength;
|
sl@0
|
825 |
const TUint16* nTable = PtrTo16BitNormalisationTable();
|
sl@0
|
826 |
TRgb color;
|
sl@0
|
827 |
|
sl@0
|
828 |
switch (iUserDispMode)
|
sl@0
|
829 |
{
|
sl@0
|
830 |
case EGray2:
|
sl@0
|
831 |
while (aBuffer < bufferLimit)
|
sl@0
|
832 |
{
|
sl@0
|
833 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
834 |
color = TRgb::_Gray2(color._Gray2());
|
sl@0
|
835 |
*aBuffer++ = color.Internal();
|
sl@0
|
836 |
}
|
sl@0
|
837 |
break;
|
sl@0
|
838 |
case EGray4:
|
sl@0
|
839 |
while (aBuffer < bufferLimit)
|
sl@0
|
840 |
{
|
sl@0
|
841 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
842 |
color = TRgb::_Gray4(color._Gray4());
|
sl@0
|
843 |
*aBuffer++ = color.Internal();
|
sl@0
|
844 |
}
|
sl@0
|
845 |
break;
|
sl@0
|
846 |
case EGray16:
|
sl@0
|
847 |
while (aBuffer < bufferLimit)
|
sl@0
|
848 |
{
|
sl@0
|
849 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
850 |
color = TRgb::_Gray16(color._Gray16());
|
sl@0
|
851 |
*aBuffer++ = color.Internal();
|
sl@0
|
852 |
}
|
sl@0
|
853 |
break;
|
sl@0
|
854 |
case EGray256:
|
sl@0
|
855 |
while (aBuffer < bufferLimit)
|
sl@0
|
856 |
{
|
sl@0
|
857 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
858 |
color = TRgb::_Gray256(color._Gray256());
|
sl@0
|
859 |
*aBuffer++ = color.Internal();
|
sl@0
|
860 |
}
|
sl@0
|
861 |
break;
|
sl@0
|
862 |
case EColor16:
|
sl@0
|
863 |
while (aBuffer < bufferLimit)
|
sl@0
|
864 |
{
|
sl@0
|
865 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
866 |
color = TRgb::Color16(color.Color16());
|
sl@0
|
867 |
*aBuffer++ = color.Internal();
|
sl@0
|
868 |
}
|
sl@0
|
869 |
break;
|
sl@0
|
870 |
case EColor256:
|
sl@0
|
871 |
while (aBuffer < bufferLimit)
|
sl@0
|
872 |
{
|
sl@0
|
873 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
874 |
color = TRgb::Color256(color.Color256());
|
sl@0
|
875 |
*aBuffer++ = color.Internal();
|
sl@0
|
876 |
}
|
sl@0
|
877 |
break;
|
sl@0
|
878 |
case EColor4K:
|
sl@0
|
879 |
while (aBuffer < bufferLimit)
|
sl@0
|
880 |
{
|
sl@0
|
881 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
882 |
color = TRgb::_Color4K(color._Color4K());
|
sl@0
|
883 |
*aBuffer++ = color.Internal();
|
sl@0
|
884 |
}
|
sl@0
|
885 |
break;
|
sl@0
|
886 |
case EColor64K:
|
sl@0
|
887 |
while (aBuffer < bufferLimit)
|
sl@0
|
888 |
{
|
sl@0
|
889 |
color.SetInternal(PMA2NonPMAPixel(*aBuffer, nTable));
|
sl@0
|
890 |
color = TRgb::_Color64K(color._Color64K());
|
sl@0
|
891 |
*aBuffer++ = color.Internal();
|
sl@0
|
892 |
}
|
sl@0
|
893 |
break;
|
sl@0
|
894 |
default:
|
sl@0
|
895 |
break;
|
sl@0
|
896 |
}
|
sl@0
|
897 |
}
|
sl@0
|
898 |
|
sl@0
|
899 |
/**
|
sl@0
|
900 |
Implementation for CFbsDrawDevice::GetInterface().
|
sl@0
|
901 |
Retrieves a pointer to a specified interface of CFbsDrawDevice implementation.
|
sl@0
|
902 |
@param aInterfaceId Interface identifier of the interface to be retrieved.
|
sl@0
|
903 |
@param aInterface Address of variable that retrieves the specified interface.
|
sl@0
|
904 |
@return KErrNone If the interface is supported, KErrNotSupported otherwise.
|
sl@0
|
905 |
*/
|
sl@0
|
906 |
TInt CDrawThirtyTwoBppBitmapCommon::GetInterface(TInt aInterfaceId, TAny*& aInterface)
|
sl@0
|
907 |
{
|
sl@0
|
908 |
aInterface = NULL;
|
sl@0
|
909 |
TInt ret = KErrNotSupported;
|
sl@0
|
910 |
|
sl@0
|
911 |
if (aInterfaceId == KFastBlit2InterfaceID)
|
sl@0
|
912 |
{
|
sl@0
|
913 |
aInterface = static_cast<MFastBlit2*>(this);
|
sl@0
|
914 |
ret = KErrNone;
|
sl@0
|
915 |
}
|
sl@0
|
916 |
else
|
sl@0
|
917 |
return CDrawBitmap::GetInterface(aInterfaceId, aInterface);
|
sl@0
|
918 |
|
sl@0
|
919 |
return ret;
|
sl@0
|
920 |
}
|
sl@0
|
921 |
|
sl@0
|
922 |
/**
|
sl@0
|
923 |
CDrawThirtyTwoBppBitmapCommon::WriteBitmapBlock() implementation.
|
sl@0
|
924 |
@internalTechnology
|
sl@0
|
925 |
@see MFastBlit2::WriteBitmapBlock()
|
sl@0
|
926 |
*/
|
sl@0
|
927 |
TInt CDrawThirtyTwoBppBitmapCommon::WriteBitmapBlock(const TPoint& aDest,
|
sl@0
|
928 |
CFbsDrawDevice* aSrcDrawDevice,
|
sl@0
|
929 |
const TRect& aSrcRect)
|
sl@0
|
930 |
{
|
sl@0
|
931 |
__ASSERT_DEBUG(aSrcDrawDevice && ((aSrcDrawDevice->DisplayMode()==EColor16MU) || (aSrcDrawDevice->DisplayMode()==EColor16MA) ||(aSrcDrawDevice->DisplayMode()==EColor16MAP)), Panic(EScreenDriverPanicInvalidParameter));
|
sl@0
|
932 |
|
sl@0
|
933 |
TAny* interface=NULL;
|
sl@0
|
934 |
TInt ret = aSrcDrawDevice->GetInterface(KFastBlit2InterfaceID, interface);
|
sl@0
|
935 |
if (ret != KErrNone)
|
sl@0
|
936 |
{
|
sl@0
|
937 |
return KErrNotSupported;
|
sl@0
|
938 |
}
|
sl@0
|
939 |
|
sl@0
|
940 |
TAny* interface1=NULL;
|
sl@0
|
941 |
ret = aSrcDrawDevice->GetInterface(KScalingSettingsInterfaceID, interface1);
|
sl@0
|
942 |
if(ret != KErrNone || (interface1 && !reinterpret_cast<MScalingSettings*>(interface1)->IsScalingOff()))
|
sl@0
|
943 |
{
|
sl@0
|
944 |
return KErrNotSupported;
|
sl@0
|
945 |
}
|
sl@0
|
946 |
|
sl@0
|
947 |
ret = aSrcDrawDevice->GetInterface(KOrientationInterfaceID, interface1);
|
sl@0
|
948 |
if(ret != KErrNone || (interface1 && reinterpret_cast<MDrawDeviceOrientation*>(interface1)->Orientation() != 0))
|
sl@0
|
949 |
{
|
sl@0
|
950 |
return KErrNotSupported;
|
sl@0
|
951 |
}
|
sl@0
|
952 |
|
sl@0
|
953 |
ret = aSrcDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID, interface1);
|
sl@0
|
954 |
if(ret != KErrNone)
|
sl@0
|
955 |
{
|
sl@0
|
956 |
return KErrNotSupported;
|
sl@0
|
957 |
}
|
sl@0
|
958 |
|
sl@0
|
959 |
if(interface1)
|
sl@0
|
960 |
{
|
sl@0
|
961 |
TPoint pt;
|
sl@0
|
962 |
reinterpret_cast<MDrawDeviceOrigin*>(interface1)->Get(pt);
|
sl@0
|
963 |
if(pt.iX != 0 || pt.iY != 0)
|
sl@0
|
964 |
{
|
sl@0
|
965 |
return KErrNotSupported;
|
sl@0
|
966 |
}
|
sl@0
|
967 |
}
|
sl@0
|
968 |
|
sl@0
|
969 |
const TUint32* srcBase = reinterpret_cast<MFastBlit2*>(interface)->Bits();
|
sl@0
|
970 |
__ASSERT_DEBUG(srcBase!=NULL, Panic(EScreenDriverPanicInvalidParameter));
|
sl@0
|
971 |
TInt srcStride = aSrcDrawDevice->ScanLineBytes();
|
sl@0
|
972 |
__ASSERT_DEBUG((srcStride&3)==0, Panic(EScreenDriverPanicInvalidParameter)); // stride is assumed to be a multiple of 4
|
sl@0
|
973 |
TSize srcSize = aSrcDrawDevice->SizeInPixels();
|
sl@0
|
974 |
|
sl@0
|
975 |
return WriteBitmapBlock(aDest, srcBase, srcStride, srcSize, aSrcRect);
|
sl@0
|
976 |
}
|
sl@0
|
977 |
|
sl@0
|
978 |
/**
|
sl@0
|
979 |
CDrawThirtyTwoBppBitmapCommon::WriteBitmapBlock() implementation.
|
sl@0
|
980 |
@internalTechnology
|
sl@0
|
981 |
@see MFastBlit2::WriteBitmapBlock()
|
sl@0
|
982 |
*/
|
sl@0
|
983 |
TInt CDrawThirtyTwoBppBitmapCommon::WriteBitmapBlock(const TPoint& aDest,
|
sl@0
|
984 |
const TUint32* aSrcBase,
|
sl@0
|
985 |
TInt aSrcStride,
|
sl@0
|
986 |
const TSize& aSrcSize,
|
sl@0
|
987 |
const TRect& aSrcRect)
|
sl@0
|
988 |
{
|
sl@0
|
989 |
__ASSERT_DEBUG(aSrcBase, Panic(EScreenDriverPanicInvalidParameter));
|
sl@0
|
990 |
__ASSERT_DEBUG((aSrcStride&3)==0, Panic(EScreenDriverPanicInvalidParameter));
|
sl@0
|
991 |
__ASSERT_DEBUG(iBits, Panic(EScreenDriverPanicInvalidPointer));
|
sl@0
|
992 |
|
sl@0
|
993 |
if (iShadowMode!=NULL ||
|
sl@0
|
994 |
(iUserDispMode!=NULL && iUserDispMode!=iDispMode) ||
|
sl@0
|
995 |
iOrientation!=EOrientationNormal ||
|
sl@0
|
996 |
!IsScalingOff() ||
|
sl@0
|
997 |
!iOriginIsZero)
|
sl@0
|
998 |
{
|
sl@0
|
999 |
return KErrNotSupported;
|
sl@0
|
1000 |
}
|
sl@0
|
1001 |
|
sl@0
|
1002 |
__ASSERT_DEBUG(aSrcRect.iTl.iX >= 0, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1003 |
__ASSERT_DEBUG(aSrcRect.iTl.iY >= 0, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1004 |
__ASSERT_DEBUG(aSrcRect.iBr.iX <= aSrcSize.iWidth, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1005 |
__ASSERT_DEBUG(aSrcRect.iBr.iY <= aSrcSize.iHeight, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1006 |
__ASSERT_DEBUG(aDest.iX >= 0, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1007 |
__ASSERT_DEBUG(aDest.iY >= 0, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1008 |
__ASSERT_DEBUG((aDest.iX + aSrcRect.Width()) <= SizeInPixels().iWidth, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1009 |
__ASSERT_DEBUG((aDest.iY + aSrcRect.Height()) <= SizeInPixels().iHeight, Panic(EScreenDriverPanicOutOfBounds));
|
sl@0
|
1010 |
|
sl@0
|
1011 |
const TInt srcStrideWords=aSrcStride >> 2;
|
sl@0
|
1012 |
const TInt dstStrideWords=iScanLineWords;
|
sl@0
|
1013 |
|
sl@0
|
1014 |
if (aSrcSize.iWidth == aSrcRect.Width() &&
|
sl@0
|
1015 |
aSrcSize.iWidth == SizeInPixels().iWidth &&
|
sl@0
|
1016 |
srcStrideWords == dstStrideWords)
|
sl@0
|
1017 |
{
|
sl@0
|
1018 |
// Optimum case - one memcpy
|
sl@0
|
1019 |
__ASSERT_DEBUG(aSrcRect.iTl.iX==0 && aDest.iX==0, Panic(EScreenDriverPanicInvalidParameter)); // this is implied by the above conditions
|
sl@0
|
1020 |
const TUint32* srcPtr = aSrcBase + (iScanLineWords * aSrcRect.iTl.iY);
|
sl@0
|
1021 |
TUint32* dstPtr = iBits + (iScanLineWords * aDest.iY);
|
sl@0
|
1022 |
const TInt length = aSrcStride * aSrcRect.Height();
|
sl@0
|
1023 |
Mem::Move(dstPtr, srcPtr, length);
|
sl@0
|
1024 |
return KErrNone;
|
sl@0
|
1025 |
}
|
sl@0
|
1026 |
|
sl@0
|
1027 |
// Sub-optimal case - one memcpy per line
|
sl@0
|
1028 |
const TUint32* srcPtr = aSrcBase + (srcStrideWords * aSrcRect.iTl.iY) + aSrcRect.iTl.iX;
|
sl@0
|
1029 |
TUint32* dstPtr = iBits + (dstStrideWords * aDest.iY ) + aDest.iX;
|
sl@0
|
1030 |
const TInt length = aSrcRect.Width() << 2;
|
sl@0
|
1031 |
TInt lines = aSrcRect.Height();
|
sl@0
|
1032 |
while (lines--)
|
sl@0
|
1033 |
{
|
sl@0
|
1034 |
Mem::Move(dstPtr, srcPtr, length);
|
sl@0
|
1035 |
srcPtr+=srcStrideWords;
|
sl@0
|
1036 |
dstPtr+=dstStrideWords;
|
sl@0
|
1037 |
}
|
sl@0
|
1038 |
return KErrNone;
|
sl@0
|
1039 |
}
|
sl@0
|
1040 |
|
sl@0
|
1041 |
/**
|
sl@0
|
1042 |
CDrawThirtyTwoBppBitmapCommon::Bits() implementation.
|
sl@0
|
1043 |
@internalTechnology
|
sl@0
|
1044 |
@see MFastBlit2::Bits()
|
sl@0
|
1045 |
*/
|
sl@0
|
1046 |
const TUint32* CDrawThirtyTwoBppBitmapCommon::Bits() const
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
return iBits;
|
sl@0
|
1049 |
}
|