First public contribution.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This module implements the functions that create the screen class depending
15 // on the screen type.
23 /********************************************************************/
27 #include "ScreenInfo.h"
28 #include <graphics/gdi/gdiconsts.h>
31 Creates an instance of CFbsDrawDevice class.
32 @param aScreenNo Screen number
33 @param aDispMode Display mode
34 @param aScreenInfo Screen parameters: video memory address and screen size
35 @return A pointer to the created CFbsDrawDevice object
36 @leave System-wide error code including KErrNoMemory
39 static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
40 TDisplayMode aDispMode,
41 const TScreenInfo& aScreenInfo)
43 CFbsDrawDevice* drawDevice = NULL;
46 if(HAL::Get(aScreenNo, HALData::EDisplayMode, bpp) != KErrNone)
48 User::Leave(KErrNotSupported);
50 if(HAL::Get(aScreenNo, HALData::EDisplayBitsPerPixel, bpp) != KErrNone)
52 User::Leave(KErrNotSupported);
55 //Switch the display mode, call the construtor of the class defined
56 //in the ScmonXX.cpp or SccolXX.cpp file.
59 case EColor256: // 8 Bpp color mode
62 drawDevice = new (ELeave) CDrawEightBppScreenBitmapColor;
63 CleanupStack::PushL(drawDevice) ;
64 User::LeaveIfError(((CDrawEightBppScreenBitmapColor*)drawDevice)->ConstructScreenL(
71 User::Leave(KErrNotSupported);
75 case EColor64K: // 16 Bpp color mode
78 drawDevice = new (ELeave) CDrawSixteenBppScreenBitmap;
79 CleanupStack::PushL(drawDevice);
80 User::LeaveIfError(((CDrawSixteenBppScreenBitmap*)drawDevice)->ConstructScreenL(
87 User::Leave(KErrNotSupported);
91 case EColor16MU: // 24 unpacked Bpp color mode
92 if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes...
93 //They are both byte per color component, and both actually have 32 bits per pixel memory use.
95 drawDevice = new (ELeave) CDrawUTwentyFourBppScreenBitmap;
96 CleanupStack::PushL(drawDevice);
97 User::LeaveIfError(((CDrawUTwentyFourBppScreenBitmap*)drawDevice)->ConstructScreenL(
104 User::Leave(KErrNotSupported);
108 case EColor16MA: // 32 Bpp color mode
109 if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes...
110 //They are both byte per color component, and both actually have 32 bits per pixel memory use.
112 drawDevice = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlpha;
113 CleanupStack::PushL(drawDevice);
114 User::LeaveIfError(((CDrawThirtyTwoBppScreenBitmapAlpha*)drawDevice)->ConstructScreenL(
116 aScreenInfo.iAddress,
121 User::Leave(KErrNotSupported);
125 case EColor16MAP: // 32 Bpp color mode
126 if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes...
127 //They are both byte per color component, and both actually have 32 bits per pixel memory use.
129 drawDevice = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM;
130 CleanupStack::PushL(drawDevice);
131 User::LeaveIfError(((CDrawThirtyTwoBppScreenBitmapAlphaPM*)drawDevice)->ConstructScreenL(
133 aScreenInfo.iAddress,
138 User::Leave(KErrNotSupported);
143 User::Leave(KErrNotSupported);
146 CleanupStack::Pop(drawDevice);
151 /********************************************************************/
152 /* Implementation of CFbsDrawDevice class */
153 /********************************************************************/
156 This function calls the correct constructor in function of the display mode.
157 @param aInfo, Structure of the LCD info
158 @param aDispMode, display mode
159 @return A pointer to just created screen device, which implements CFbsDrawDevice interface
160 @deprecated Use CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
162 EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo, TDisplayMode aDispMode)
164 __ASSERT_ALWAYS(aInfo.iScreenAddressValid, Panic(EScreenDriverPanicInvalidWindowHandle));
165 TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
166 return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
170 Creates a new screen device instance, which implements CFbsDrawDevice interface.
171 The method has to be implemented for each type of supported video hardware.
172 @param aScreenNo Screen number
173 @param aDispMode Requested display mode
174 @return A pointer to just created screen device, which implements CFbsDrawDevice interface
175 @leave KErrNoMemory Not enough memory
176 KErrNotSupported The requested screen device type is not supported
178 EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
179 TDisplayMode aDispMode)
181 TInt address = 0, width = 0, height = 0;
182 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address));
183 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
184 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
185 __ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue));
186 TScreenInfo screenInfo(reinterpret_cast <TAny*> (address), TSize(width, height));
187 return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
191 Depending on the current graphics hardware this
192 will return one of the 16M video modes defined in
193 TDisplayMode, or ENone if a 16M video mode is not supported.
195 @return a 16M display mode or ENone.
197 EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()