sl@0
|
1 |
// Copyright (c) 1997-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 "SCDRAW.H"
|
sl@0
|
17 |
#include "_WININC.H"
|
sl@0
|
18 |
|
sl@0
|
19 |
TInt CDrawEightBppScreenBitmapGray::InitScreen()
|
sl@0
|
20 |
{
|
sl@0
|
21 |
TRect drawRect;
|
sl@0
|
22 |
GetDrawRect(drawRect);
|
sl@0
|
23 |
RWindows* window = ::WindowHandler(iScreenNo);
|
sl@0
|
24 |
window->iDisplayMode = DisplayMode();
|
sl@0
|
25 |
window->iEpocBitmapSize = drawRect.Size();
|
sl@0
|
26 |
window->iEpocBitmapLinePitch = (iScanLineWords*4);
|
sl@0
|
27 |
|
sl@0
|
28 |
return KErrNone;
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
TBool CDrawEightBppScreenBitmapGray::SetOrientation(TOrientation aOrientation)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
if (aOrientation == iEmulatorOrientation)
|
sl@0
|
34 |
return ETrue;
|
sl@0
|
35 |
|
sl@0
|
36 |
SetScreenOrientation(aOrientation);
|
sl@0
|
37 |
iEmulatorOrientation = aOrientation;
|
sl@0
|
38 |
iOrientation = aOrientation ;
|
sl@0
|
39 |
return ETrue;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
void CDrawEightBppScreenBitmapGray::UpdateRect(const TRect& aRect) const
|
sl@0
|
43 |
{
|
sl@0
|
44 |
ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
|
sl@0
|
45 |
#if defined(_DEBUG)
|
sl@0
|
46 |
if (iOrientation&1)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
ASSERT(aRect.iBr.iX <= iSize.iHeight);
|
sl@0
|
49 |
ASSERT(aRect.iBr.iY <= iSize.iWidth);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
else
|
sl@0
|
52 |
{
|
sl@0
|
53 |
ASSERT(aRect.iBr.iX <= iSize.iWidth);
|
sl@0
|
54 |
ASSERT(aRect.iBr.iY <= iSize.iHeight);
|
sl@0
|
55 |
}
|
sl@0
|
56 |
#endif
|
sl@0
|
57 |
TInt scanLineLen=iLongWidth;
|
sl@0
|
58 |
TInt srcPixelStep=1;
|
sl@0
|
59 |
TPoint srcStart(aRect.iTl);
|
sl@0
|
60 |
switch(iOrientation)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
case CFbsDrawDevice::EOrientationRotated90:
|
sl@0
|
63 |
srcPixelStep=scanLineLen;
|
sl@0
|
64 |
scanLineLen=-1;
|
sl@0
|
65 |
srcStart.iX=iSize.iWidth-1-aRect.iTl.iY;
|
sl@0
|
66 |
srcStart.iY=aRect.iTl.iX;
|
sl@0
|
67 |
break;
|
sl@0
|
68 |
case CFbsDrawDevice::EOrientationRotated180:
|
sl@0
|
69 |
srcPixelStep=-1;
|
sl@0
|
70 |
scanLineLen=-scanLineLen;
|
sl@0
|
71 |
srcStart.iX=iSize.iWidth-1-aRect.iTl.iX;
|
sl@0
|
72 |
srcStart.iY=iSize.iHeight-1-aRect.iTl.iY;
|
sl@0
|
73 |
break;
|
sl@0
|
74 |
case CFbsDrawDevice::EOrientationRotated270:
|
sl@0
|
75 |
srcPixelStep=-scanLineLen;
|
sl@0
|
76 |
scanLineLen=1;
|
sl@0
|
77 |
srcStart.iX=aRect.iTl.iY;
|
sl@0
|
78 |
srcStart.iY=iSize.iHeight-1-aRect.iTl.iX;
|
sl@0
|
79 |
break;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
TUint8* srcePtr = PixelAddress(srcStart.iX,srcStart.iY);
|
sl@0
|
82 |
TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep;
|
sl@0
|
83 |
TInt rowMax = aRect.iTl.iY+aRect.Height();
|
sl@0
|
84 |
for(TInt row = aRect.iTl.iY; row < rowMax; row++)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
TUint8* tempSrcePtr = srcePtr;
|
sl@0
|
87 |
TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row);
|
sl@0
|
88 |
|
sl@0
|
89 |
while (tempSrcePtr != srcePtrLimit)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
TUint8 grayShade = *tempSrcePtr;
|
sl@0
|
92 |
destPixel[0] = grayShade ;
|
sl@0
|
93 |
destPixel[1] = grayShade ;
|
sl@0
|
94 |
destPixel[2] = grayShade ;
|
sl@0
|
95 |
|
sl@0
|
96 |
tempSrcePtr+=srcPixelStep;
|
sl@0
|
97 |
destPixel += 3;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
srcePtr += scanLineLen;
|
sl@0
|
101 |
srcePtrLimit += scanLineLen;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|