graphicsutils/commongraphicsheaders/inc/displaycontrolbase.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @prototype
       
    20 */
       
    21 
       
    22 #ifndef DISPLAYCONTROLBASE__INCLUDED_
       
    23 #define DISPLAYCONTROLBASE__INCLUDED_
       
    24 #include <graphics/displayconfiguration.h>
       
    25 /** Common base interface for display control facilities.
       
    26 
       
    27 */
       
    28 class MDisplayControlBase
       
    29 	{
       
    30 public:
       
    31 	enum	
       
    32 		{
       
    33 		KUidDisplayControlBase =  0x10286496,
       
    34 		ETypeId=	 KUidDisplayControlBase 
       
    35 		};
       
    36 	
       
    37 	class TResolution
       
    38 		{	//Kernel mode makes use of agregate constructors
       
    39 	public:
       
    40 		enum
       
    41 			{
       
    42 			ERotationNormalSupported = 0,
       
    43 			ERotation90Supported = 1,
       
    44 			ERotation180Supported = 2,
       
    45 			ERotation270Supported = 3,
       
    46 			EIsVirtual = 4,
       
    47 			};
       
    48 		inline TResolution(TSize aPixelSize, TSize aTwipsSize, TBitFlags32 aFlags = ERotationNormalSupported);
       
    49 //		inline TResolution(const TResolution& aSrc);
       
    50 
       
    51 	public:
       
    52 		/** The physical display size in pixels with no rotation (i.e. ERotationNormal).
       
    53 		    See SetConfiguration().
       
    54 		*/
       
    55 		TSize iPixelSize;
       
    56 		/** The physical display size in twips with no rotation (i.e. ERotationNormal).
       
    57 		    See SetConfiguration().
       
    58 		*/
       
    59 		TSize iTwipsSize;
       
    60 		/** A bitwise combination of TDisplayConfiguration1::TGraphicsOrientation values.
       
    61 		*/
       
    62 		TBitFlags32 iFlags;
       
    63 
       
    64 	private:
       
    65 		/** Reserved for extension and alignment.
       
    66 		*/
       
    67 		TUint32 iReservedAlignmentSpare_0;
       
    68 		};
       
    69 public:
       
    70 	/** Returns the number of discrete resolutions that can be retrieved using
       
    71 		GetResolutions().
       
    72 		
       
    73 		If the display is disconnected, the return value shall be KErrDisconnected. Implicitly, 
       
    74 		there are no resolutions available. When initially connected, the number of resolutions 
       
    75 		may be limited, possibly zero, only increasing when the display has reported 
       
    76 		which resolutions it supports.
       
    77 		
       
    78 		@return Number of resolutions available, or KErrDisconnected.
       
    79 	*/
       
    80 	virtual TInt NumberOfResolutions()const =0;
       
    81 	/** Retrieves the set of available display resolutions and supported rotations per resolution.
       
    82 		
       
    83 		If a display can be disabled, the list shall include a resolution with the size (0,0). If the 
       
    84 		display is connected but disabled, the list may also include other supported resolutions. 
       
    85 		If a display cannot be disabled, the list shall not include (0,0).
       
    86 
       
    87 		The flags field in each entry shall contain the set of rotations supported for the given 
       
    88 		resolution. The size fields shall always give the resolution with no rotation applied (ERotationNormal), 
       
    89 		whether or not that rotation is supported.
       
    90 
       
    91 		If the EIsVirtual flags is set, the resolution will be simulated by scaling the output. Scaling 
       
    92 		quality varies between platfoms, and in general the best quality will be achieved using a 
       
    93 		physical resolution, where the EIsVirtual flag is not set.
       
    94 
       
    95 		The size in twips may be an estimate for some displays, but can be used to determine the pixel aspect 
       
    96 		ratio in combination with the size in pixels.
       
    97 
       
    98 		The array shall be reset and the contents replaced by the available resolutions. If an error is returned, 
       
    99 		the contents of the array shall be undefined.
       
   100 
       
   101 		If no display is connected, the return value shall be KErrDisconnected. When initially connected, the 
       
   102 		set of resolutions available may be limited, possibly zero, increasing when the display has reported 
       
   103 		which resolutions it supports.
       
   104 
       
   105 		If the array is not large enough to retrieve the set of resolutions initially, it will be expanded once, 
       
   106 		or fail with KErrNoMemory. If the number of resolutions increases again after this expansion, the 
       
   107 		function will fail with KErrOverflow. The caller may re-try the operation.
       
   108 
       
   109 		@see TResolutionFlags
       
   110 		
       
   111 		@param aResolutions Buffer to receive resolutions.
       
   112 		
       
   113 		@return KErrNone on success, KErrDisconnected if no display is connected, KErrNoMemory if a memory allocation 
       
   114 		failure occurs or KErrOverflow if the number of elements increased.
       
   115 	*/	
       
   116 	virtual TInt GetResolutions(RArray<TResolution>& aResolutions)const =0;
       
   117 	/** Gets the current display configuration.
       
   118 
       
   119 		Note that some entries in the configuration may be undefined if they are unknown, so their validity should 
       
   120 		either be checked using the accessor return code, or using the IsDefined() function before reading them.
       
   121 
       
   122 		If the display is not connected, the resolution shall be set as undefined. If the display is connected, but 
       
   123 		disabled, the resolution shall be (0,0). Other attributes may or may not be defined in these states.
       
   124 
       
   125 		@see TDisplayConfiguration::IsDefined
       
   126 		@see SetConfiguration
       
   127 
       
   128 		@param aConfig Receives the display configuration.
       
   129 	*/	
       
   130 	virtual void GetConfiguration(TDisplayConfiguration& aConfig)const =0;
       
   131 	/** Sets the new display configuration.
       
   132 
       
   133 		It is valid to leave settings undefined to let the implementer determine the optimal combination. If a defined 
       
   134 		setting cannot be achieved, the function shall fail with KErrArgument.
       
   135 	
       
   136 		Note that the new configuration will be in use when the function returns, but the change may not appear on screen 
       
   137 		immediately. It may be deferred due to rendering, composition and display synchronization taking place, but will 
       
   138 		generally become apparent in the next frame update.
       
   139 	
       
   140 		Whether a given configuration is valid or not shall be platform dependent, and may depend on the current screen 
       
   141 		size mode. Some platforms may restrict resolutions to those listed in the resolution list, while others may be 
       
   142 		more flexible. Where the resolution does not match a physical resolution from the list, display quality may be
       
   143 		reduced.
       
   144 	
       
   145 		Setting a resolution of (0,0), if allowed, shall disable display output. Otherwise the pixel resolution shall 
       
   146 		define the maximum number of pixels that can be rendered using CWindowGc, and this area shall fill the display. 
       
   147 		Alternative means of rendering may be displayed at the physical resolution, irrespective of the current 
       
   148 		configuration.
       
   149 	
       
   150 		@see CWsScreenDevice::SetScreenMode
       
   151 		@see CWindowGc
       
   152 
       
   153 		@param aConfig Display configuration to set, and receive the complete configuration that will be used.
       
   154 
       
   155 		@capability WriteDeviceData
       
   156 
       
   157 		@return A system-wide error code.
       
   158 	*/	
       
   159 	virtual TInt SetConfiguration(const TDisplayConfiguration& aConfig) =0;
       
   160 	/** Returns the preferred version of the TDisplayConfiguration object.
       
   161 
       
   162 		GetConfiguration() and SetConfiguration() may be passed any version of the TDisplayConfiguration class, as returned 
       
   163 		by TDisplayConfiguration::Version(). If an earlier version is presented, the implementation will treat later 
       
   164 		attributes as undefined. If a later structure is presented, then the additional attributes will be ignored.
       
   165 
       
   166 		This method may be used to fine-tune use of the interface, by avoiding the generation of attribute data that will not 
       
   167 		be used, or by reducing the options presented to users.
       
   168 
       
   169 		@return The optimum version of TDisplayConfiguration to pass to SetConfiguration() and GetConfiguration().
       
   170 	*/	
       
   171 	virtual TInt PreferredDisplayVersion()const =0;
       
   172 	};
       
   173 
       
   174 inline MDisplayControlBase::TResolution::TResolution(TSize aPixelSize, TSize aTwipsSize, TBitFlags32 aFlags)
       
   175 	:	iPixelSize(aPixelSize),iTwipsSize(aTwipsSize),iFlags(aFlags),iReservedAlignmentSpare_0(0)
       
   176 	{	}
       
   177 //inline MDisplayControlBase::TResolution::TResolution(const TResolution& aSrc)
       
   178 //:	iSize(aSrc.iSize),iRotations(aSrc.iRotations),iReservedAlignmentSpare_0(0)
       
   179 //	{	}
       
   180 
       
   181 #endif // DISPLAYCONTROLBASE__INCLUDED_