windowing/windowserver/inc/Graphics/openwfc/surfaceconfiguration.inl
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Sets all members to default values. Initializes the size field to match the object size.
       
    15 // 
       
    16 //
       
    17 /**
       
    18 @file
       
    19 @publishedpartner 
       
    20 @released
       
    21 */
       
    22 
       
    23 inline TSurfaceConfiguration::TSurfaceConfiguration()
       
    24 	{}
       
    25 
       
    26 /**
       
    27 Copy constructor. This constructor will read the size field of the source and target 
       
    28 objects and only copy the minimum set of fields indicated. Any remaining fields in the target 
       
    29 object will be set to default values. 
       
    30 
       
    31 @param aSurfaceConfiguration Config to copy
       
    32 */
       
    33 inline TSurfaceConfiguration::TSurfaceConfiguration(const TSurfaceConfiguration& aSurfaceConfiguration):
       
    34 	TSurfaceConfiguration2(0)
       
    35 	{
       
    36 	TInt tempSize = aSurfaceConfiguration.Size();
       
    37 	if (tempSize > sizeof(*this))
       
    38 		{
       
    39 		tempSize = sizeof(*this);
       
    40 		}
       
    41 	Mem::Copy(this, &aSurfaceConfiguration, tempSize);
       
    42 	iSize = tempSize;
       
    43 	}
       
    44 
       
    45 /**
       
    46 This constructor will take any value, but it is designed to be used with
       
    47 a value returned by RWsSession::PreferredSurfaceConfigurationSize, 
       
    48 and initializes the members to represent an object compatible with that.
       
    49 
       
    50 If the aPreferredMaxSize is larger than the actual size of TSurfaceConfiguration, indicating 
       
    51 that the server supports a newer version of the interface than the caller is aware of, then 
       
    52 the actual size is used.
       
    53 
       
    54 If the aPreferredMaxSize is smaller than the actual size of TSurfaceConfiguration, indicating 
       
    55 that the server supports an earlier version of the interface, then this value is used. It must 
       
    56 match the Size() member of one of the defined hierarchy of TSurfaceConfiguration classes.
       
    57 
       
    58 @param aPreferredMaxSize User defined max size
       
    59 @see RWsSession::PreferredSurfaceConfigurationSize
       
    60 */
       
    61 inline TSurfaceConfiguration::TSurfaceConfiguration(TInt aPreferredMaxSize):
       
    62 	TSurfaceConfiguration2(sizeof(*this))
       
    63 	{
       
    64 	if (sizeof(*this) > aPreferredMaxSize)
       
    65 		{
       
    66 		iSize = aPreferredMaxSize;
       
    67 		}
       
    68 	}
       
    69 
       
    70 /** Default constructor for configuration 1
       
    71 */
       
    72 inline TSurfaceConfiguration1::TSurfaceConfiguration1():TSurfaceConfigurationSize(sizeof(*this))
       
    73 		,iExtent(TRect::EUninitialized), iViewport(TRect::EUninitialized)
       
    74 	{}
       
    75 
       
    76 /**
       
    77 Constructor for configuration 1 passing through a size already calculated
       
    78 
       
    79 @param aSize Size of the class already calculated and being passed up through the classes
       
    80 */
       
    81 inline TSurfaceConfiguration1::TSurfaceConfiguration1(TInt aSize):TSurfaceConfigurationSize(aSize)
       
    82 		,iExtent(TRect::EUninitialized), iViewport(TRect::EUninitialized)
       
    83 	{}
       
    84 
       
    85 /**
       
    86 The method sets the surface ID to be set as the background surface. 
       
    87 
       
    88 The default initial value held in this class for surface ID is the null surface ID.
       
    89 
       
    90 Note that SetBackgroundSurface() will not accept a null surface ID, so this parameter must always be set.
       
    91 
       
    92 @param aSurfaceId Surface ID to set
       
    93 @return KErrNone on success or a system-wide error code
       
    94 	- KErrNotSupported if not supported.
       
    95 @post The Surface Id values are updated in the object of this class if supported. The 
       
    96 SetBackgroundSurface API must be called passing object of this class as parameter to 
       
    97 get the desired effect.
       
    98 */
       
    99 inline TInt TSurfaceConfiguration1::SetSurfaceId (const TSurfaceId& aSurfaceId)
       
   100 	{
       
   101 	if (MemberAccessible(iSurfaceId))
       
   102 		{
       
   103 		iSurfaceId = aSurfaceId;
       
   104 		return KErrNone;
       
   105 		}	
       
   106 	return KErrNotSupported;
       
   107 	}
       
   108 
       
   109 /**
       
   110 The method gets the surface ID stored in the object of this class.
       
   111 
       
   112 @param aSurfaceId User surface id to be set
       
   113 @post The aSurface parameter is filled in.
       
   114 @post If the instance of TSurfaceConfiguration is too small, the null surface ID will be set.
       
   115 */
       
   116 inline void TSurfaceConfiguration1::GetSurfaceId (TSurfaceId& aSurfaceId) const
       
   117 	{
       
   118 	if (MemberAccessible(iSurfaceId))
       
   119 		{
       
   120 		aSurfaceId = iSurfaceId;
       
   121 		}
       
   122 	else
       
   123 		{
       
   124 		aSurfaceId.CreateNullId();
       
   125 		}
       
   126 	}
       
   127 
       
   128 /**
       
   129 The method sets the area of the surface that should be mapped to the specified window area. 
       
   130 The viewport is in surface coordinates.
       
   131 
       
   132 In SetBackgroundSurface(), if not set or if the set viewport is empty, the size of the whole surface 
       
   133 is used as the viewport. If the surface is changed then the viewport will track the size of 
       
   134 the surface. 
       
   135 
       
   136 Setting any ordinate of the viewport outside the surface size is not required specified behavior for 
       
   137 this interface. The call will not fail if any ordinates are out of range, and the internal NGA Composition 
       
   138 handling of this case will produce a representative image. This current behavior is that the NGA Composition 
       
   139 will clamp any out-of-range ordinate to the size of the surface.
       
   140 
       
   141 @param aViewport A rectangle of the area, in relative coordinates to the surface
       
   142 @return KErrNone on success or a system-wide error code
       
   143 	- KErrNotSupported if not supported.
       
   144 @post The viewport values are updated in the object of this class. This does not imply that the 
       
   145 viewport is set for the surface. The SetBackgroundSurface API must be called passing an object of 
       
   146 this class as parameter to get the desired effect.
       
   147 */
       
   148 inline TInt TSurfaceConfiguration1::SetViewport (const TRect& aViewport)
       
   149 	{
       
   150 	if (MemberAccessible(iViewport))
       
   151 		{
       
   152 		iViewport = aViewport;
       
   153 		return KErrNone;
       
   154 		}
       
   155 	return KErrNotSupported;
       
   156 	}
       
   157 
       
   158 /**
       
   159 This method gets the viewport stored in the object of this class. The viewport is in surface 
       
   160 coordinates.
       
   161 
       
   162 If viewport was not set or an empty viewport was set, the value returned is an empty viewport. This 
       
   163 is an indication that the viewport used by the server is equal to the size of the surface. The 
       
   164 actual size of the surface is not returned.
       
   165 
       
   166 @param aViewport User viewport to be set.
       
   167 @post The aViewport rectangle is filled in.
       
   168 @post If the instance of TSurfaceConfiguration is too small, the empty viewport rectangle will be returned.
       
   169 */
       
   170 inline void TSurfaceConfiguration1::GetViewport (TRect& aViewport) const
       
   171 	{
       
   172 	if (MemberAccessible(iViewport))
       
   173 		{
       
   174 		aViewport = iViewport;
       
   175 		}
       
   176 	else
       
   177 		{
       
   178 		aViewport = TRect();
       
   179 		}
       
   180 	}
       
   181 
       
   182 /**
       
   183 This method sets the relative orientation of viewport to window extent. The default value is 
       
   184 EGraphicsOrientationNormal.
       
   185 
       
   186 The rotation effect is applied to the input viewport area, around the centre-point of the viewport.
       
   187 
       
   188 @param aOrientation User orientation to be set
       
   189 @return KErrNone on success or a system-wide error code
       
   190 	- KErrNotSupported if not supported.
       
   191 	- KErrArgument if aOrientation is out of range
       
   192 @post The orientation is updated in the object of this class. This does not imply that the orientation 
       
   193 is set for the surface content. The SetBackgroundSurface API must be called passing an object of 
       
   194 this class as parameter to get the desired effect.
       
   195 */
       
   196 inline TInt TSurfaceConfiguration1::SetOrientation (CFbsBitGc::TGraphicsOrientation aOrientation)
       
   197 	{
       
   198 	if (MemberAccessible(iOrientation))
       
   199 		{
       
   200 		__ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal==0 && 
       
   201 						CFbsBitGc::EGraphicsOrientationRotated270 == 3);
       
   202 		if(aOrientation < CFbsBitGc::EGraphicsOrientationNormal || 
       
   203 				aOrientation > CFbsBitGc::EGraphicsOrientationRotated270)
       
   204 			{
       
   205 			return KErrArgument;
       
   206 			}
       
   207 		iOrientation = aOrientation;
       
   208 		return KErrNone;
       
   209 		}
       
   210 	return KErrNotSupported;
       
   211 	}
       
   212 
       
   213 /**
       
   214 The method gets the surface orientation angle stored in the object of this class. It is the 
       
   215 relative orientation of viewport to window extent. If orientation was not set, the value returned 
       
   216 will be EGraphicsOrientationNormal.
       
   217 
       
   218 @return orientation in this object
       
   219 @post If the instance of TSurfaceConfiguration is too small, the default EGraphicsOrientationNormal 
       
   220 setting will be returned.
       
   221 */
       
   222 inline CFbsBitGc::TGraphicsOrientation TSurfaceConfiguration1::Orientation() const
       
   223 	{
       
   224 	if (MemberAccessible(iOrientation))
       
   225 		{
       
   226 		return iOrientation;
       
   227 		}
       
   228 	else
       
   229 		{
       
   230 		return CFbsBitGc::EGraphicsOrientationNormal;
       
   231 		}
       
   232 	}
       
   233 
       
   234 /**
       
   235 This method sets the area of the window where the surface content is to be placed. The extent is 
       
   236 in window coordinates.
       
   237 
       
   238 If not set or if the set extent is empty, the size of the entire window is used as the default extent. 
       
   239 The default extent changes according to the change in the window size. The empty extent is an indication 
       
   240 to the server that the extent should fill the entire window without the client tracking the change in 
       
   241 the window size.
       
   242 
       
   243 In SetBackgroundSurface() it is legal to set the extent larger than the window, or the window may 
       
   244 become smaller than the extent. In these cases the output will be transformed on the basis of this 
       
   245 larger extent, but then clipped to the window outline.
       
   246 
       
   247 @param aExtent Area on the window where the surface contents specified by viewport
       
   248 should be mapped
       
   249 @return KErrNone on success or a system-wide error code
       
   250 	- KErrNotSupported if not supported.
       
   251 @post The extent values are updated in the object of this class. This does not imply that the 
       
   252 extent is set for the surface. The SetBackgroundSurface API must be called passing an object of 
       
   253 this class as parameter to get the desired effect.
       
   254 */
       
   255 inline TInt TSurfaceConfiguration1::SetExtent(const TRect& aExtent)
       
   256 	{
       
   257 	if (MemberAccessible(iExtent))
       
   258 		{
       
   259 		iExtent = aExtent;
       
   260 		return KErrNone;
       
   261 		}
       
   262 	return KErrNotSupported;
       
   263 	}
       
   264 
       
   265 /**
       
   266 The method gets the extent stored in the object of this class. The extent is in window coordinates.
       
   267 
       
   268 If extent was not set or an empty extent was set, the value returned will be an empty extent. This 
       
   269 is an indication that the extent used by the server is equal to the size of the window. The actual 
       
   270 size of the window is not returned.
       
   271 
       
   272 @param aExtent User extent to be set
       
   273 @post The aExtent parameter is filled in
       
   274 @post If the instance of TSurfaceConfiguration is too small, the empty extent rectangle will be returned.
       
   275 */
       
   276 inline void TSurfaceConfiguration1::GetExtent(TRect& aExtent) const
       
   277 	{
       
   278 	if (MemberAccessible(iExtent))
       
   279 		{
       
   280 		aExtent = iExtent;
       
   281 		}
       
   282 	else
       
   283 		{
       
   284 		aExtent = TRect();
       
   285 		}
       
   286 	}
       
   287 
       
   288 /**
       
   289 This method identifies which attributes are available to use.
       
   290 
       
   291 Generally, any version of the server will accept any version of TSurfaceConfiguration, ignoring 
       
   292 newer version attributes it does not recognize and substituting defaults for attributes not present 
       
   293 in older version.
       
   294 
       
   295 However, by using this method in conjunction with GetBackgroundSurface() the intelligent client can 
       
   296 identify which blocks of attributes are actually present and supported after a call to 
       
   297 GetBackgroundSurface, avoiding preparing complex attributes, or reducing user-interface control 
       
   298 gadgets.
       
   299 
       
   300 @return ETrue if all these attributes are available to use; otherwise EFalse
       
   301 */
       
   302 inline TBool TSurfaceConfiguration1::SupportsAllMembers()
       
   303 	{
       
   304 	if (Size() >= sizeof(*this))
       
   305 		{
       
   306 		return ETrue;
       
   307 		}
       
   308 	else
       
   309 		{
       
   310 		return EFalse;
       
   311 		}
       
   312 	}
       
   313 
       
   314 /**
       
   315 Constructs the TSurfaceConfigurationSize class, enters the size field and blanks everything else
       
   316 
       
   317 @param aSize The size to set for the configuration
       
   318 @return ETrue If all these attributes are available to use; otherwise EFalse
       
   319 */
       
   320 inline TSurfaceConfigurationSize::TSurfaceConfigurationSize(TInt aSize)
       
   321 	{
       
   322 	Mem::FillZ(this,aSize);
       
   323 	iSize = aSize;
       
   324 	}
       
   325 
       
   326 /**
       
   327 Reads the size field. The size is set automatically in the constructor, or by the 
       
   328 GetBackgroundSurface method to indicate the sender’s supported structure size, and imply a 
       
   329 compatible version identifier. The size reported after GetBackgroundSurface will match 
       
   330 the expected size of one of the hierarchy of TSurfaceConfiguration classes documented in the 
       
   331 header, and will never exceed the constructed size.
       
   332 
       
   333 @return ETrue if all these attributes are available to use; otherwise EFalse
       
   334 */
       
   335 inline TInt TSurfaceConfigurationSize::Size() const
       
   336 	{
       
   337 	return iSize;
       
   338 	}
       
   339 
       
   340 inline TBool TSurfaceConfigurationSize::operator == (const TSurfaceConfigurationSize& aRhs)const
       
   341 	{
       
   342 	return aRhs.Size()==Size();	//If the two objects are not the same version then we can't compare them!
       
   343 	}
       
   344 inline TBool TSurfaceConfiguration1::operator == (const TSurfaceConfiguration1& aRhs)const
       
   345 	{
       
   346 	if (!TSurfaceConfigurationSize::operator ==(aRhs))
       
   347 		return EFalse;	//Check for earlier version compatability
       
   348 	if (Size()<sizeof(*this))
       
   349 		return ETrue;	//If the objects are smaller than this then the check is complete
       
   350 	return 	(iSurfaceId==aRhs.iSurfaceId)
       
   351 		&&	(iOrientation==aRhs.iOrientation)
       
   352 		&&	(iExtent==aRhs.iExtent)
       
   353 		&&	(iViewport==aRhs.iViewport)
       
   354 		;
       
   355 	}
       
   356 
       
   357 /** Default constructor for configuration 2
       
   358 */
       
   359 inline TSurfaceConfiguration2::TSurfaceConfiguration2():TSurfaceConfiguration1(sizeof(*this))
       
   360         ,iFlip(EFalse)
       
   361     {}
       
   362 
       
   363 /**
       
   364 Constructor for configuration 2 passing through a size already calculated
       
   365 
       
   366 @param aSize Size of the class already calculated and being passed up through the classes
       
   367 */
       
   368 inline TSurfaceConfiguration2::TSurfaceConfiguration2(TInt aSize):TSurfaceConfiguration1(aSize)
       
   369         ,iFlip(EFalse)
       
   370     {}
       
   371 
       
   372 /**
       
   373 This method sets the flip attribute to the surface. The default value is 
       
   374 EFalse.
       
   375 
       
   376 @param aFlip When ETrue enalbes flip in the x-axis
       
   377 @post The flip attribute is updated in the object of this class. This does not imply that the flip 
       
   378 is set for the surface content. The SetBackgroundSurface API must be called passing an object of 
       
   379 this class as parameter to get the desired effect.
       
   380 @return KErrNone on success 
       
   381     - KErrNotSupported if flip is not supported. 
       
   382 */
       
   383 inline TInt TSurfaceConfiguration2::SetFlip(TBool aFlip)
       
   384     {
       
   385     if (MemberAccessible(iFlip))
       
   386         {
       
   387         iFlip = aFlip;
       
   388         return KErrNone;
       
   389         }
       
   390      return KErrNotSupported;
       
   391     }
       
   392 
       
   393 /**
       
   394 The method gets the flip attribute of the surface stored in the object of this class. If the flip was not set, the value returned 
       
   395 will be EFalse.
       
   396 
       
   397 @return ETrue if flip is enabled
       
   398 @post If the instance of TSurfaceConfiguration is too small, the default EFalse 
       
   399 setting will be returned.
       
   400 */
       
   401 inline TBool TSurfaceConfiguration2::Flip() const
       
   402     {
       
   403     if (MemberAccessible(iFlip))
       
   404         {
       
   405         return iFlip;
       
   406         }
       
   407     else
       
   408         {
       
   409         return EFalse;
       
   410         }
       
   411     }
       
   412 
       
   413 inline TBool TSurfaceConfiguration2::SupportsAllMembers()
       
   414     {
       
   415     if (Size() >= sizeof(*this))
       
   416         {
       
   417         return ETrue;
       
   418         }
       
   419     else
       
   420         {
       
   421         return EFalse;
       
   422         }
       
   423     }
       
   424 
       
   425 inline TBool TSurfaceConfiguration2::operator == (const TSurfaceConfiguration2& aRhs)const
       
   426     {
       
   427     if (!TSurfaceConfiguration1::operator ==(aRhs))
       
   428         return EFalse;  //Check for earlier version compatability
       
   429     if (Size()<sizeof(*this))
       
   430         return ETrue;   //If the objects are smaller than this then the check is complete
       
   431     return  iFlip==aRhs.iFlip;
       
   432     }