1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/swins/SCNEW.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,204 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// WINS platform
1.18 +//
1.19 +//
1.20 +
1.21 +#include <hal.h>
1.22 +#include "SCDRAW.H"
1.23 +#include "ScreenInfo.h"
1.24 +#include <graphics/gdi/gdiconsts.h>
1.25 +
1.26 +/**
1.27 +Creates an instance of CFbsDrawDevice class.
1.28 +@param aScreenNo Screen number
1.29 +@param aDispMode Display mode
1.30 +@param aScreenInfo Screen parameters: video memory address and screen size
1.31 +@return A pointer to the created CFbsDrawDevice object
1.32 +@leave System-wide error code including KErrNoMemory
1.33 +@internalComponent
1.34 +*/
1.35 +static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
1.36 + TDisplayMode aDispMode,
1.37 + const TScreenInfo& aScreenInfo)
1.38 + {
1.39 + TUint depths = 0;
1.40 + // As multiple screens are possible, the (optional) second parameter is necessary here
1.41 + // to find the color depth specific to this screen.
1.42 + EmulatorColorDepth(depths, aScreenNo);
1.43 + ASSERT(depths);
1.44 +
1.45 + CFbsDrawDevice* drawDevice = NULL;
1.46 +
1.47 + switch(aDispMode)
1.48 + {
1.49 + case EGray2:
1.50 + if (!(depths & KEmulGray2))
1.51 + User::Leave(KErrNotSupported);
1.52 + drawDevice = new(ELeave) CDrawOneBppScreenBitmap;
1.53 + CleanupStack::PushL(drawDevice);
1.54 + User::LeaveIfError((static_cast<CDrawOneBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.55 + aScreenInfo.iAddress,
1.56 + aScreenInfo.iSize));
1.57 + break;
1.58 + case EGray4:
1.59 + if (!(depths & KEmulGray4))
1.60 + User::Leave(KErrNotSupported);
1.61 + drawDevice = new(ELeave) CDrawTwoBppScreenBitmap;
1.62 + CleanupStack::PushL(drawDevice);
1.63 + User::LeaveIfError((static_cast<CDrawTwoBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.64 + aScreenInfo.iAddress,
1.65 + aScreenInfo.iSize));
1.66 + break;
1.67 + case EGray16:
1.68 + if (!(depths & KEmulGray16))
1.69 + User::Leave(KErrNotSupported);
1.70 + drawDevice = new(ELeave) CDrawFourBppScreenBitmapGray;
1.71 + CleanupStack::PushL(drawDevice);
1.72 + User::LeaveIfError((static_cast<CDrawFourBppScreenBitmapGray*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.73 + aScreenInfo.iAddress,
1.74 + aScreenInfo.iSize));
1.75 + break;
1.76 + case EGray256:
1.77 + if (!(depths & KEmulGray256))
1.78 + User::Leave(KErrNotSupported);
1.79 + drawDevice = new(ELeave) CDrawEightBppScreenBitmapGray;
1.80 + CleanupStack::PushL(drawDevice);
1.81 + User::LeaveIfError((static_cast<CDrawEightBppScreenBitmapGray*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.82 + aScreenInfo.iAddress,
1.83 + aScreenInfo.iSize));
1.84 + break;
1.85 + case EColor16:
1.86 + if (!(depths & KEmulColor16))
1.87 + User::Leave(KErrNotSupported);
1.88 + drawDevice = new(ELeave) CDrawFourBppScreenBitmapColor;
1.89 + CleanupStack::PushL(drawDevice);
1.90 + User::LeaveIfError((static_cast<CDrawFourBppScreenBitmapColor*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.91 + aScreenInfo.iAddress,
1.92 + aScreenInfo.iSize));
1.93 + break;
1.94 + case EColor256:
1.95 + if (!(depths & KEmulColor256))
1.96 + User::Leave(KErrNotSupported);
1.97 + drawDevice = new(ELeave) CDrawEightBppScreenBitmapColor;
1.98 + CleanupStack::PushL(drawDevice);
1.99 + User::LeaveIfError((static_cast<CDrawEightBppScreenBitmapColor*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.100 + aScreenInfo.iAddress,
1.101 + aScreenInfo.iSize));
1.102 + break;
1.103 + case EColor4K:
1.104 + if (!(depths & KEmulColor4K))
1.105 + User::Leave(KErrNotSupported);
1.106 + drawDevice = new(ELeave) CDrawTwelveBppScreenBitmap;
1.107 + CleanupStack::PushL(drawDevice);
1.108 + User::LeaveIfError((static_cast<CDrawTwelveBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.109 + aScreenInfo.iAddress,
1.110 + aScreenInfo.iSize));
1.111 + break;
1.112 + case EColor64K:
1.113 + if (!(depths & KEmulColor64K))
1.114 + User::Leave(KErrNotSupported);
1.115 + drawDevice = new(ELeave) CDrawSixteenBppScreenBitmap;
1.116 + CleanupStack::PushL(drawDevice);
1.117 + User::LeaveIfError((static_cast<CDrawSixteenBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.118 + aScreenInfo.iAddress,
1.119 + aScreenInfo.iSize));
1.120 + break;
1.121 + case EColor16M:
1.122 + if (!(depths & KEmulColor16M))
1.123 + User::Leave(KErrNotSupported);
1.124 + drawDevice = new(ELeave) CDrawTwentyFourBppScreenBitmap;
1.125 + CleanupStack::PushL(drawDevice);
1.126 + User::LeaveIfError((static_cast<CDrawTwentyFourBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.127 + aScreenInfo.iAddress,
1.128 + aScreenInfo.iSize));
1.129 + break;
1.130 + case EColor16MU:
1.131 + if (!(depths & KEmulColor16M))
1.132 + User::Leave(KErrNotSupported);
1.133 + drawDevice = new(ELeave) CDrawUTwentyFourBppScreenBitmap;
1.134 + CleanupStack::PushL(drawDevice);
1.135 + User::LeaveIfError((static_cast<CDrawUTwentyFourBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.136 + aScreenInfo.iAddress,
1.137 + aScreenInfo.iSize));
1.138 + break;
1.139 + case EColor16MA:
1.140 + if (!(depths & KEmulColor16M))
1.141 + User::Leave(KErrNotSupported);
1.142 + drawDevice = new(ELeave) CDrawThirtyTwoBppScreenBitmapAlpha;
1.143 + CleanupStack::PushL(drawDevice);
1.144 + User::LeaveIfError((static_cast<CDrawThirtyTwoBppScreenBitmapAlpha*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.145 + aScreenInfo.iAddress,
1.146 + aScreenInfo.iSize));
1.147 + break;
1.148 + case EColor16MAP:
1.149 + if (!(depths & KEmulColor16M))
1.150 + User::Leave(KErrNotSupported);
1.151 + drawDevice = new(ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM;
1.152 + CleanupStack::PushL(drawDevice);
1.153 + User::LeaveIfError((static_cast<CDrawThirtyTwoBppScreenBitmapAlphaPM*> (drawDevice)) ->ConstructScreen(aScreenNo,
1.154 + aScreenInfo.iAddress,
1.155 + aScreenInfo.iSize));
1.156 + break;
1.157 + default:
1.158 + User::Leave(KErrNotSupported);
1.159 + }
1.160 +
1.161 + CleanupStack::Pop(); // drawDevice
1.162 + return drawDevice;
1.163 + }
1.164 +
1.165 +/**
1.166 +@deprecated Use NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
1.167 +*/
1.168 +EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo,
1.169 + TDisplayMode aDispMode)
1.170 + {
1.171 + __ASSERT_ALWAYS(aInfo.iScreenAddressValid && aInfo.iScreenAddress, Panic(EScreenDriverPanicInvalidWindowHandle));
1.172 + TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
1.173 + return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
1.174 + }
1.175 +
1.176 +/**
1.177 +Creates a new screen device instance, which implements CFbsDrawDevice interface.
1.178 +The method has to be implemented for each type of supported video hardware.
1.179 +@param aScreenNo Screen number
1.180 +@param aDispMode Requested display mode
1.181 +@return A pointer to just created screen device, which implements CFbsDrawDevice interface
1.182 +@leave KErrNoMemory Not enough memory
1.183 + KErrNotSupported The requested screen device type is not supported
1.184 +*/
1.185 +EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
1.186 + TDisplayMode aDispMode)
1.187 + {
1.188 + TInt address = 0, width = 0, height = 0;
1.189 + User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address));
1.190 + User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
1.191 + User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
1.192 + __ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue));
1.193 + TScreenInfo screenInfo(reinterpret_cast <TAny*> (address), TSize(width, height));
1.194 + return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
1.195 + }
1.196 +
1.197 +/**
1.198 +Depending on the current graphics hardware this
1.199 +will return one of the 16M video modes defined in
1.200 +TDisplayMode, or ENone if a 16M video mode is not supported.
1.201 +@see TDisplayMode
1.202 +@return a 16M display mode or ENone.
1.203 +*/
1.204 +EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()
1.205 + {
1.206 + return EColor16MU;
1.207 + }