os/graphics/graphicsdeviceinterface/screendriver/smint/SCNEW.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
// MINT platform
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <hal.h>
sl@0
    19
#include "scdraw.h"
sl@0
    20
#include "ScreenInfo.h"
sl@0
    21
#include <graphics/gdi/gdiconsts.h>
sl@0
    22
sl@0
    23
/**
sl@0
    24
Creates an instance of CFbsDrawDevice class.
sl@0
    25
@param aScreenNo Screen number
sl@0
    26
@param aDispMode Display mode
sl@0
    27
@param aScreenInfo Screen parameters: video memory address and screen size
sl@0
    28
@return A pointer to the created CFbsDrawDevice object
sl@0
    29
@leave System-wide error code including KErrNoMemory
sl@0
    30
@internalComponent
sl@0
    31
*/
sl@0
    32
static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
sl@0
    33
									   TDisplayMode aDispMode,
sl@0
    34
									   const TScreenInfo& aScreenInfo)
sl@0
    35
	{
sl@0
    36
	CFbsDrawDevice* drawDevice = NULL;
sl@0
    37
sl@0
    38
	switch (aDispMode)
sl@0
    39
		{
sl@0
    40
	case SCREEN_LAYOUT_DISPLAY_MODE:
sl@0
    41
		drawDevice = new(ELeave) CDrawScreenBitmap;
sl@0
    42
		CleanupStack::PushL(drawDevice);
sl@0
    43
		User::LeaveIfError(((CDrawScreenBitmap*)drawDevice)->ConstructScreen(aScreenNo,
sl@0
    44
																aScreenInfo.iAddress,
sl@0
    45
																aScreenInfo.iSize));
sl@0
    46
		break;
sl@0
    47
	default:
sl@0
    48
		User::Leave(KErrNotSupported);
sl@0
    49
		}
sl@0
    50
sl@0
    51
	CleanupStack::Pop(); // drawDevice
sl@0
    52
	return drawDevice;
sl@0
    53
	}
sl@0
    54
sl@0
    55
/**
sl@0
    56
@deprecated Use NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
sl@0
    57
*/
sl@0
    58
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo,
sl@0
    59
														  TDisplayMode aDispMode)
sl@0
    60
	{
sl@0
    61
	TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
sl@0
    62
	return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
sl@0
    63
	}
sl@0
    64
sl@0
    65
/**
sl@0
    66
Creates a new screen device instance, which implements CFbsDrawDevice interface.
sl@0
    67
The method has to be implemented for each type of supported video hardware.
sl@0
    68
@param aScreenNo Screen number
sl@0
    69
@param aDispMode Requested display mode
sl@0
    70
@return A pointer to just created screen device, which implements CFbsDrawDevice interface
sl@0
    71
@leave KErrNoMemory Not enough memory
sl@0
    72
	   KErrNotSupported The requested screen device type is not supported
sl@0
    73
*/
sl@0
    74
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
sl@0
    75
														  TDisplayMode aDispMode)
sl@0
    76
	{
sl@0
    77
	TInt address = 0, width = 0, height = 0;
sl@0
    78
	User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address));
sl@0
    79
	User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
sl@0
    80
	User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
sl@0
    81
	__ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue));
sl@0
    82
	TScreenInfo screenInfo(reinterpret_cast <TAny*> (address), TSize(width, height));
sl@0
    83
	return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
sl@0
    84
	}
sl@0
    85
sl@0
    86
/**
sl@0
    87
Depending on the current graphics hardware this 
sl@0
    88
will return one of the 16M video modes defined in
sl@0
    89
TDisplayMode, or ENone if a 16M video mode is not supported.
sl@0
    90
@see TDisplayMode
sl@0
    91
@return	a 16M display mode or ENone.
sl@0
    92
*/
sl@0
    93
EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()
sl@0
    94
	{
sl@0
    95
	return ENone;
sl@0
    96
	}