graphicsutils/commongraphicsheaders/inc/displayconfiguration.inl
author William Roberts <williamr@symbian.org>
Thu, 03 Jun 2010 17:39:46 +0100
branchNewGraphicsArchitecture
changeset 87 0709f76d91e5
parent 0 5d03bc08d59c
permissions -rw-r--r--
Add MMP files to build libOpenVG_sw.lib which uses LINKAS to redirect to libOpenVG.dll (and the same for libEGL_sw.lib and libOpenVGU_sw.lib). Only the libEGL_sw.lib redirection isn't activated - this can't happen until there is a merged libEGL.dll which supports the OpenWF synchronisation and also implements the graphical support functions. The overall aim is to eliminate the *_sw.dll implementations, at least as a compile-time way of choosing a software-only implementation.The correct way to choose is to put the right set of libraries into a ROM with suitable renaming, and in the emulator to use the "switching DLL" technique to pick the right set. As the Symbian Foundation doesn't have any alternative implementations, we don't need the switching DLLs and we can build directly to the correct name.

// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

/**
 @file
 @publishedPartner
 @prototype
*/

#ifndef _DISPLAYCONFIGURATION_INL__INCLUDED_
#define _DISPLAYCONFIGURATION_INL__INCLUDED_

//
//
// Complete implementation of Base class
//
//
inline TInt TDisplayConfigurationBase::Version() const
	{
	return iVersion;
	}

inline void TDisplayConfigurationBase::Clear(TAttribute aAttribute)
	{
	iDefined.Clear(+aAttribute);
	}

inline void TDisplayConfigurationBase::ClearAll()
	{
	iDefined.ClearAll();
	}

inline void TDisplayConfigurationBase::Panic(TInt aPanicCode)
	{
	_LIT(KCategory,"DISPLAYCONFIG");
	User::Panic(KCategory,aPanicCode);
	}

inline TBool TDisplayConfigurationBase::IsDefined(TAttribute aAttribute) const
	{
	//If we have more than 32 attributes then this code may need a rewrite.
	__ASSERT_COMPILE(EAttributeMax<=32);
	return  iDefined.IsSet(+aAttribute);
	}

inline TDisplayConfigurationBase::TDisplayConfigurationBase(TInt aVersion)
	{
	if (aVersion < sizeof(*this))
		{
		Panic(EPanicConfigInvalid);
		}
	iVersion=aVersion;
	//default constructor for iDefined sets all-zero.
	//Members do not need zapping to zero because they are disabled in iDefined
	}


inline TBool TDisplayConfigurationBase::operator == (const TDisplayConfigurationBase& aRhs) const
	{
	return (aRhs.Version()== Version()) && (const_cast<TBitFlags32&>(aRhs.iDefined) == iDefined );
	}
//
//
// Complete implementation of V1 class
//
//
inline TDisplayConfiguration1::TDisplayConfiguration1():TDisplayConfigurationBase(sizeof(*this))
		,iResolution(TSize::EUninitialized)
	{}

inline TDisplayConfiguration1::TDisplayConfiguration1(TInt aVersion):TDisplayConfigurationBase(aVersion)
		,iResolution(TSize::EUninitialized)
	{
	if (aVersion > sizeof(TDisplayConfigurationBase) &&
			aVersion < sizeof(*this))
		{
		Panic(EPanicConfigInvalid);
		}
	}

inline void TDisplayConfiguration1::SetResolution(const TSize& aSize)
	{
	if (MemberAccessible(iResolution))
		{
		if (aSize.iWidth<0 || aSize.iHeight<0)
			{
			Panic(EPanicNegResolution);
			}
		if ((aSize.iWidth>0 && aSize.iHeight==0)||
				(aSize.iWidth==0 && aSize.iHeight>0))
			{
			Panic(EPanicSemiZeroResolution);
			}
		iDefined.Set(+EResolution);
		iResolution=aSize;
		}
	}

inline TBool TDisplayConfiguration1::GetResolution(TSize& aSize) const
	{
	if (MemberAccessible(iResolution) && IsDefined(EResolution))
		{
		aSize=iResolution;
		return ETrue;
		}		
	return  EFalse;
	}

//Accessor for rotation member (index)
inline void TDisplayConfiguration1::SetRotation(TRotation aOrientation)
	{
	if (MemberAccessible(iRotation))
		{
		if ((TUint)aOrientation>=(TUint)ERotationIllegal)
			{
			Panic(EPanicIllegalRotation);
			}
		iDefined.Set(+ERotation);
		iRotation=aOrientation;
		}
	
	}
//Accessor for rotation member (index)
inline TBool TDisplayConfiguration1::GetRotation(TRotation& aOrientation)const
	{
	if (MemberAccessible(iRotation) && IsDefined(ERotation))
		{
		aOrientation=static_cast<TRotation>(iRotation);
		return ETrue;
		}
	return EFalse;
	}
//Accessor for resolution value
inline void TDisplayConfiguration1::SetResolutionTwips(const TSize& aSize)
	{
	if (MemberAccessible(iTwipsSize))
		{
		if (aSize.iWidth<0 || aSize.iHeight<0)
			{
			Panic(EPanicNegTwips);
			}
		if ((aSize.iWidth>0 && aSize.iHeight==0)||
				(aSize.iWidth==0 && aSize.iHeight>0))
			{
			Panic(EPanicSemiZeroTwips);
			}
		iDefined.Set(+EResolutionTwips);
		iTwipsSize=aSize;
		}
	}
//Accessor for resolution value
inline TBool TDisplayConfiguration1::GetResolutionTwips(TSize& aSize) const
	{
	if (MemberAccessible(iTwipsSize) && IsDefined(EResolutionTwips))
		{
		aSize=iTwipsSize;
		return ETrue;
		}
	return EFalse;
	}

inline TBool TDisplayConfiguration1::operator == (const TDisplayConfiguration1& aRhs)const
	{
	if (!TDisplayConfigurationBase::operator ==(aRhs))
		return EFalse;	//Check for earlier version compatability
	if (Version()<sizeof(*this))
		return ETrue;	//If the objects are smaller than this then the check is complete
	
	TBool isAttrEqual = ETrue;
	if(IsDefined(EResolution))
		{
		isAttrEqual = isAttrEqual&(aRhs.iResolution == iResolution);
		}
	if(IsDefined(ERotation))
		{
		isAttrEqual = isAttrEqual&(aRhs.iRotation == iRotation);
		}
	if(IsDefined(EResolutionTwips))
		{
		isAttrEqual = isAttrEqual&(aRhs.iTwipsSize == iTwipsSize);
		}
	
	return isAttrEqual;
	}

//
//
// Complete implementation of v2 class (goes here)
//
//


//
//
// Complete implementation of Wrapper class
//
//
inline TDisplayConfiguration::TDisplayConfiguration(const TDisplayConfiguration& aDisplayConfiguration):
	TDisplayConfigurationTop(TDisplayConfiguration().Version())
	{
	TInt tempSize = aDisplayConfiguration.Version();
	if (tempSize > TDisplayConfiguration().Version())
		{
		tempSize = TDisplayConfiguration().Version();
		}
	Mem::Copy(this, &aDisplayConfiguration, tempSize);
	//This has copied size for higher version features...
	iVersion = tempSize;
	//This has copied set flags for higher version features...
	TInt flags=iDefined.Value();
	//If we have more than 32 attributes then this code will need a rewrite.
	__ASSERT_COMPILE(EAttributeMax<=32);
	flags&=(1<<EAttributeMax)-1;
	iDefined.SetValue(flags);
	}

inline TDisplayConfiguration::TDisplayConfiguration(TInt aVersion):
	TDisplayConfigurationTop(aVersion)
	{
	if (TDisplayConfiguration().Version() > aVersion)
		{
		iVersion = aVersion;
		}
	}

#endif // _DISPLAYCONFIGURATION__INCLUDED_