sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This module implements the functions that create the screen class depending sl@0: // on the screen type. sl@0: // Include files sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: /********************************************************************/ sl@0: #include sl@0: #include "scdraw.h" sl@0: #include sl@0: #include "ScreenInfo.h" sl@0: #include sl@0: sl@0: /** sl@0: Creates an instance of CFbsDrawDevice class. sl@0: @param aScreenNo Screen number sl@0: @param aDispMode Display mode sl@0: @param aScreenInfo Screen parameters: video memory address and screen size sl@0: @return A pointer to the created CFbsDrawDevice object sl@0: @leave System-wide error code including KErrNoMemory sl@0: @internalComponent sl@0: */ sl@0: static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo, sl@0: TDisplayMode aDispMode, sl@0: const TScreenInfo& aScreenInfo) sl@0: { sl@0: CFbsDrawDevice* drawDevice = NULL; sl@0: sl@0: TInt bpp; sl@0: if(HAL::Get(aScreenNo, HALData::EDisplayMode, bpp) != KErrNone) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: if(HAL::Get(aScreenNo, HALData::EDisplayBitsPerPixel, bpp) != KErrNone) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: //Switch the display mode, call the construtor of the class defined sl@0: //in the ScmonXX.cpp or SccolXX.cpp file. sl@0: switch(aDispMode) sl@0: { sl@0: case EColor256: // 8 Bpp color mode sl@0: if(bpp == 8) sl@0: { sl@0: drawDevice = new (ELeave) CDrawEightBppScreenBitmapColor; sl@0: CleanupStack::PushL(drawDevice) ; sl@0: User::LeaveIfError(((CDrawEightBppScreenBitmapColor*)drawDevice)->ConstructScreenL( sl@0: aScreenNo, sl@0: aScreenInfo.iAddress, sl@0: aScreenInfo.iSize)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: break; sl@0: sl@0: case EColor64K: // 16 Bpp color mode sl@0: if(bpp == 16) sl@0: { sl@0: drawDevice = new (ELeave) CDrawSixteenBppScreenBitmap; sl@0: CleanupStack::PushL(drawDevice); sl@0: User::LeaveIfError(((CDrawSixteenBppScreenBitmap*)drawDevice)->ConstructScreenL( sl@0: aScreenNo, sl@0: aScreenInfo.iAddress, sl@0: aScreenInfo.iSize)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: break; sl@0: sl@0: case EColor16MU: // 24 unpacked Bpp color mode sl@0: if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes... sl@0: //They are both byte per color component, and both actually have 32 bits per pixel memory use. sl@0: { sl@0: drawDevice = new (ELeave) CDrawUTwentyFourBppScreenBitmap; sl@0: CleanupStack::PushL(drawDevice); sl@0: User::LeaveIfError(((CDrawUTwentyFourBppScreenBitmap*)drawDevice)->ConstructScreenL( sl@0: aScreenNo, sl@0: aScreenInfo.iAddress, sl@0: aScreenInfo.iSize)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: break; sl@0: sl@0: case EColor16MA: // 32 Bpp color mode sl@0: if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes... sl@0: //They are both byte per color component, and both actually have 32 bits per pixel memory use. sl@0: { sl@0: drawDevice = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlpha; sl@0: CleanupStack::PushL(drawDevice); sl@0: User::LeaveIfError(((CDrawThirtyTwoBppScreenBitmapAlpha*)drawDevice)->ConstructScreenL( sl@0: aScreenNo, sl@0: aScreenInfo.iAddress, sl@0: aScreenInfo.iSize)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: break; sl@0: sl@0: case EColor16MAP: // 32 Bpp color mode sl@0: if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes... sl@0: //They are both byte per color component, and both actually have 32 bits per pixel memory use. sl@0: { sl@0: drawDevice = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM; sl@0: CleanupStack::PushL(drawDevice); sl@0: User::LeaveIfError(((CDrawThirtyTwoBppScreenBitmapAlphaPM*)drawDevice)->ConstructScreenL( sl@0: aScreenNo, sl@0: aScreenInfo.iAddress, sl@0: aScreenInfo.iSize)); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: CleanupStack::Pop(drawDevice); sl@0: return drawDevice; sl@0: } sl@0: sl@0: sl@0: /********************************************************************/ sl@0: /* Implementation of CFbsDrawDevice class */ sl@0: /********************************************************************/ sl@0: sl@0: /** sl@0: This function calls the correct constructor in function of the display mode. sl@0: @param aInfo, Structure of the LCD info sl@0: @param aDispMode, display mode sl@0: @return A pointer to just created screen device, which implements CFbsDrawDevice interface sl@0: @deprecated Use CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode) sl@0: */ sl@0: EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo, TDisplayMode aDispMode) sl@0: { sl@0: __ASSERT_ALWAYS(aInfo.iScreenAddressValid, Panic(EScreenDriverPanicInvalidWindowHandle)); sl@0: TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize); sl@0: return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo); sl@0: } sl@0: sl@0: /** sl@0: Creates a new screen device instance, which implements CFbsDrawDevice interface. sl@0: The method has to be implemented for each type of supported video hardware. sl@0: @param aScreenNo Screen number sl@0: @param aDispMode Requested display mode sl@0: @return A pointer to just created screen device, which implements CFbsDrawDevice interface sl@0: @leave KErrNoMemory Not enough memory sl@0: KErrNotSupported The requested screen device type is not supported sl@0: */ sl@0: EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo, sl@0: TDisplayMode aDispMode) sl@0: { sl@0: TInt address = 0, width = 0, height = 0; sl@0: User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address)); sl@0: User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width)); sl@0: User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height)); sl@0: __ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue)); sl@0: TScreenInfo screenInfo(reinterpret_cast (address), TSize(width, height)); sl@0: return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo); sl@0: } sl@0: sl@0: /** sl@0: Depending on the current graphics hardware this sl@0: will return one of the 16M video modes defined in sl@0: TDisplayMode, or ENone if a 16M video mode is not supported. sl@0: @see TDisplayMode sl@0: @return a 16M display mode or ENone. sl@0: */ sl@0: EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M() sl@0: { sl@0: // return ENone; sl@0: return EColor16MA; sl@0: }