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