1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsutils/commongraphicsheaders/inc/displayconfiguration.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,238 @@
1.4 +// Copyright (c) 2008-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 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @publishedPartner
1.22 + @prototype
1.23 +*/
1.24 +
1.25 +#ifndef _DISPLAYCONFIGURATION_INL__INCLUDED_
1.26 +#define _DISPLAYCONFIGURATION_INL__INCLUDED_
1.27 +
1.28 +//
1.29 +//
1.30 +// Complete implementation of Base class
1.31 +//
1.32 +//
1.33 +inline TInt TDisplayConfigurationBase::Version() const
1.34 + {
1.35 + return iVersion;
1.36 + }
1.37 +
1.38 +inline void TDisplayConfigurationBase::Clear(TAttribute aAttribute)
1.39 + {
1.40 + iDefined.Clear(+aAttribute);
1.41 + }
1.42 +
1.43 +inline void TDisplayConfigurationBase::ClearAll()
1.44 + {
1.45 + iDefined.ClearAll();
1.46 + }
1.47 +
1.48 +inline void TDisplayConfigurationBase::Panic(TInt aPanicCode)
1.49 + {
1.50 + _LIT(KCategory,"DISPLAYCONFIG");
1.51 + User::Panic(KCategory,aPanicCode);
1.52 + }
1.53 +
1.54 +inline TBool TDisplayConfigurationBase::IsDefined(TAttribute aAttribute) const
1.55 + {
1.56 + //If we have more than 32 attributes then this code may need a rewrite.
1.57 + __ASSERT_COMPILE(EAttributeMax<=32);
1.58 + return iDefined.IsSet(+aAttribute);
1.59 + }
1.60 +
1.61 +inline TDisplayConfigurationBase::TDisplayConfigurationBase(TInt aVersion)
1.62 + {
1.63 + if (aVersion < sizeof(*this))
1.64 + {
1.65 + Panic(EPanicConfigInvalid);
1.66 + }
1.67 + iVersion=aVersion;
1.68 + //default constructor for iDefined sets all-zero.
1.69 + //Members do not need zapping to zero because they are disabled in iDefined
1.70 + }
1.71 +
1.72 +
1.73 +inline TBool TDisplayConfigurationBase::operator == (const TDisplayConfigurationBase& aRhs) const
1.74 + {
1.75 + return (aRhs.Version()== Version()) && (const_cast<TBitFlags32&>(aRhs.iDefined) == iDefined );
1.76 + }
1.77 +//
1.78 +//
1.79 +// Complete implementation of V1 class
1.80 +//
1.81 +//
1.82 +inline TDisplayConfiguration1::TDisplayConfiguration1():TDisplayConfigurationBase(sizeof(*this))
1.83 + ,iResolution(TSize::EUninitialized)
1.84 + {}
1.85 +
1.86 +inline TDisplayConfiguration1::TDisplayConfiguration1(TInt aVersion):TDisplayConfigurationBase(aVersion)
1.87 + ,iResolution(TSize::EUninitialized)
1.88 + {
1.89 + if (aVersion > sizeof(TDisplayConfigurationBase) &&
1.90 + aVersion < sizeof(*this))
1.91 + {
1.92 + Panic(EPanicConfigInvalid);
1.93 + }
1.94 + }
1.95 +
1.96 +inline void TDisplayConfiguration1::SetResolution(const TSize& aSize)
1.97 + {
1.98 + if (MemberAccessible(iResolution))
1.99 + {
1.100 + if (aSize.iWidth<0 || aSize.iHeight<0)
1.101 + {
1.102 + Panic(EPanicNegResolution);
1.103 + }
1.104 + if ((aSize.iWidth>0 && aSize.iHeight==0)||
1.105 + (aSize.iWidth==0 && aSize.iHeight>0))
1.106 + {
1.107 + Panic(EPanicSemiZeroResolution);
1.108 + }
1.109 + iDefined.Set(+EResolution);
1.110 + iResolution=aSize;
1.111 + }
1.112 + }
1.113 +
1.114 +inline TBool TDisplayConfiguration1::GetResolution(TSize& aSize) const
1.115 + {
1.116 + if (MemberAccessible(iResolution) && IsDefined(EResolution))
1.117 + {
1.118 + aSize=iResolution;
1.119 + return ETrue;
1.120 + }
1.121 + return EFalse;
1.122 + }
1.123 +
1.124 +//Accessor for rotation member (index)
1.125 +inline void TDisplayConfiguration1::SetRotation(TRotation aOrientation)
1.126 + {
1.127 + if (MemberAccessible(iRotation))
1.128 + {
1.129 + if ((TUint)aOrientation>=(TUint)ERotationIllegal)
1.130 + {
1.131 + Panic(EPanicIllegalRotation);
1.132 + }
1.133 + iDefined.Set(+ERotation);
1.134 + iRotation=aOrientation;
1.135 + }
1.136 +
1.137 + }
1.138 +//Accessor for rotation member (index)
1.139 +inline TBool TDisplayConfiguration1::GetRotation(TRotation& aOrientation)const
1.140 + {
1.141 + if (MemberAccessible(iRotation) && IsDefined(ERotation))
1.142 + {
1.143 + aOrientation=static_cast<TRotation>(iRotation);
1.144 + return ETrue;
1.145 + }
1.146 + return EFalse;
1.147 + }
1.148 +//Accessor for resolution value
1.149 +inline void TDisplayConfiguration1::SetResolutionTwips(const TSize& aSize)
1.150 + {
1.151 + if (MemberAccessible(iTwipsSize))
1.152 + {
1.153 + if (aSize.iWidth<0 || aSize.iHeight<0)
1.154 + {
1.155 + Panic(EPanicNegTwips);
1.156 + }
1.157 + if ((aSize.iWidth>0 && aSize.iHeight==0)||
1.158 + (aSize.iWidth==0 && aSize.iHeight>0))
1.159 + {
1.160 + Panic(EPanicSemiZeroTwips);
1.161 + }
1.162 + iDefined.Set(+EResolutionTwips);
1.163 + iTwipsSize=aSize;
1.164 + }
1.165 + }
1.166 +//Accessor for resolution value
1.167 +inline TBool TDisplayConfiguration1::GetResolutionTwips(TSize& aSize) const
1.168 + {
1.169 + if (MemberAccessible(iTwipsSize) && IsDefined(EResolutionTwips))
1.170 + {
1.171 + aSize=iTwipsSize;
1.172 + return ETrue;
1.173 + }
1.174 + return EFalse;
1.175 + }
1.176 +
1.177 +inline TBool TDisplayConfiguration1::operator == (const TDisplayConfiguration1& aRhs)const
1.178 + {
1.179 + if (!TDisplayConfigurationBase::operator ==(aRhs))
1.180 + return EFalse; //Check for earlier version compatability
1.181 + if (Version()<sizeof(*this))
1.182 + return ETrue; //If the objects are smaller than this then the check is complete
1.183 +
1.184 + TBool isAttrEqual = ETrue;
1.185 + if(IsDefined(EResolution))
1.186 + {
1.187 + isAttrEqual = isAttrEqual&(aRhs.iResolution == iResolution);
1.188 + }
1.189 + if(IsDefined(ERotation))
1.190 + {
1.191 + isAttrEqual = isAttrEqual&(aRhs.iRotation == iRotation);
1.192 + }
1.193 + if(IsDefined(EResolutionTwips))
1.194 + {
1.195 + isAttrEqual = isAttrEqual&(aRhs.iTwipsSize == iTwipsSize);
1.196 + }
1.197 +
1.198 + return isAttrEqual;
1.199 + }
1.200 +
1.201 +//
1.202 +//
1.203 +// Complete implementation of v2 class (goes here)
1.204 +//
1.205 +//
1.206 +
1.207 +
1.208 +//
1.209 +//
1.210 +// Complete implementation of Wrapper class
1.211 +//
1.212 +//
1.213 +inline TDisplayConfiguration::TDisplayConfiguration(const TDisplayConfiguration& aDisplayConfiguration):
1.214 + TDisplayConfigurationTop(TDisplayConfiguration().Version())
1.215 + {
1.216 + TInt tempSize = aDisplayConfiguration.Version();
1.217 + if (tempSize > TDisplayConfiguration().Version())
1.218 + {
1.219 + tempSize = TDisplayConfiguration().Version();
1.220 + }
1.221 + Mem::Copy(this, &aDisplayConfiguration, tempSize);
1.222 + //This has copied size for higher version features...
1.223 + iVersion = tempSize;
1.224 + //This has copied set flags for higher version features...
1.225 + TInt flags=iDefined.Value();
1.226 + //If we have more than 32 attributes then this code will need a rewrite.
1.227 + __ASSERT_COMPILE(EAttributeMax<=32);
1.228 + flags&=(1<<EAttributeMax)-1;
1.229 + iDefined.SetValue(flags);
1.230 + }
1.231 +
1.232 +inline TDisplayConfiguration::TDisplayConfiguration(TInt aVersion):
1.233 + TDisplayConfigurationTop(aVersion)
1.234 + {
1.235 + if (TDisplayConfiguration().Version() > aVersion)
1.236 + {
1.237 + iVersion = aVersion;
1.238 + }
1.239 + }
1.240 +
1.241 +#endif // _DISPLAYCONFIGURATION__INCLUDED_