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 CDrawEightBppScreenBitmapColor::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 |
window->iPalette = iPalette;
|
sl@0
|
28 |
|
sl@0
|
29 |
return KErrNone;
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
const TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette);
|
sl@0
|
35 |
|
sl@0
|
36 |
if(::WindowHandler(iScreenNo)->iDisplayMode==DisplayMode())
|
sl@0
|
37 |
::WindowHandler(iScreenNo)->iPalette = iPalette;
|
sl@0
|
38 |
|
sl@0
|
39 |
if (ret == KErrNone)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CFbsDrawDevice* thisPtr = this;
|
sl@0
|
42 |
TRegionFix<1> rgnSize(iSize);
|
sl@0
|
43 |
thisPtr->Update(rgnSize); // Can't access Update directly because the most-derived implementation is private.
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
return ret;
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
if (aOrientation == iEmulatorOrientation)
|
sl@0
|
52 |
return ETrue;
|
sl@0
|
53 |
|
sl@0
|
54 |
SetScreenOrientation(aOrientation);
|
sl@0
|
55 |
iEmulatorOrientation = aOrientation;
|
sl@0
|
56 |
iOrientation = aOrientation ;
|
sl@0
|
57 |
return ETrue;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
void CDrawEightBppScreenBitmapColor::UpdateRect(const TRect& aRect) const
|
sl@0
|
61 |
{
|
sl@0
|
62 |
ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
|
sl@0
|
63 |
#if defined(_DEBUG)
|
sl@0
|
64 |
if (iOrientation&1)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
ASSERT(aRect.iBr.iX <= iSize.iHeight);
|
sl@0
|
67 |
ASSERT(aRect.iBr.iY <= iSize.iWidth);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
else
|
sl@0
|
70 |
{
|
sl@0
|
71 |
ASSERT(aRect.iBr.iX <= iSize.iWidth);
|
sl@0
|
72 |
ASSERT(aRect.iBr.iY <= iSize.iHeight);
|
sl@0
|
73 |
}
|
sl@0
|
74 |
#endif
|
sl@0
|
75 |
TInt scanLineLen=iLongWidth;
|
sl@0
|
76 |
TInt srcPixelStep=1;
|
sl@0
|
77 |
TPoint srcStart(aRect.iTl);
|
sl@0
|
78 |
switch(iOrientation)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
case CFbsDrawDevice::EOrientationRotated90:
|
sl@0
|
81 |
srcPixelStep=scanLineLen;
|
sl@0
|
82 |
scanLineLen=-1;
|
sl@0
|
83 |
srcStart.iX=iSize.iWidth-1-aRect.iTl.iY;
|
sl@0
|
84 |
srcStart.iY=aRect.iTl.iX;
|
sl@0
|
85 |
break;
|
sl@0
|
86 |
case CFbsDrawDevice::EOrientationRotated180:
|
sl@0
|
87 |
srcPixelStep=-1;
|
sl@0
|
88 |
scanLineLen=-scanLineLen;
|
sl@0
|
89 |
srcStart.iX=iSize.iWidth-1-aRect.iTl.iX;
|
sl@0
|
90 |
srcStart.iY=iSize.iHeight-1-aRect.iTl.iY;
|
sl@0
|
91 |
break;
|
sl@0
|
92 |
case CFbsDrawDevice::EOrientationRotated270:
|
sl@0
|
93 |
srcPixelStep=-scanLineLen;
|
sl@0
|
94 |
scanLineLen=1;
|
sl@0
|
95 |
srcStart.iX=aRect.iTl.iY;
|
sl@0
|
96 |
srcStart.iY=iSize.iHeight-1-aRect.iTl.iX;
|
sl@0
|
97 |
break;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
TUint8* srcePtr = PixelAddress(srcStart.iX,srcStart.iY);
|
sl@0
|
100 |
TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep;
|
sl@0
|
101 |
TInt rowMax = aRect.iTl.iY+aRect.Height();
|
sl@0
|
102 |
for(TInt row = aRect.iTl.iY; row < rowMax; row++)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
TUint8* tempSrcePtr = srcePtr;
|
sl@0
|
105 |
TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row);
|
sl@0
|
106 |
|
sl@0
|
107 |
while (tempSrcePtr != srcePtrLimit)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TRgb pixelColor = IndexToColor(*tempSrcePtr);
|
sl@0
|
110 |
destPixel[0] = TUint8(pixelColor.Blue());
|
sl@0
|
111 |
destPixel[1] = TUint8(pixelColor.Green());
|
sl@0
|
112 |
destPixel[2] = TUint8(pixelColor.Red());
|
sl@0
|
113 |
|
sl@0
|
114 |
tempSrcePtr+=srcPixelStep;
|
sl@0
|
115 |
destPixel += 3;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
srcePtr += scanLineLen;
|
sl@0
|
119 |
srcePtrLimit += scanLineLen;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|