windowing/windowserver/tcsc/cwsgcecscbase.h
changeset 116 171fae344dd4
parent 103 2717213c588a
equal deleted inserted replaced
103:2717213c588a 116:171fae344dd4
     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 #ifndef TCWGCECSCBASE_H_
       
    17 #define TCWGCECSCBASE_H_
       
    18 
       
    19 #include <test/tefunit.h>
       
    20 #include <w32debug.h>
       
    21 #include "surfaceutility.h"
       
    22 #include <e32property.h>
       
    23 
       
    24 class TPerfProperties
       
    25 {
       
    26 public:
       
    27 	TBool GetValue(TUint aKey);
       
    28 	void PrintAllL(CTestFixture& aLogger);
       
    29 	TBool ResetValue(TUint aKey);
       
    30 	void UpdateAll();
       
    31 	void ResetAll();
       
    32 private:
       
    33 #ifdef GCE_BACKEND_PROFILING
       
    34 	TInt iValue[EPerfLastKey];
       
    35 	TInt iPrevValue[EPerfLastKey];
       
    36 	const static TBuf<100> propertyKeysTxt[EPerfLastKey];
       
    37 #endif
       
    38 };
       
    39 
       
    40 class CWsGceCscBase: public CTestFixture
       
    41 {
       
    42 
       
    43 public:
       
    44 	template <class Referee,class LoggerOwner>
       
    45 	class	SafePointer
       
    46 		{
       
    47 	public:
       
    48 		SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
       
    49 			iOwner(aOwner),	iReferee(aReferee)
       
    50 			{}
       
    51 		Referee*	operator=(Referee* aReferee)
       
    52 			{
       
    53 			return iReferee=aReferee;
       
    54 			}
       
    55 		Referee*&	operator()()
       
    56 			{
       
    57 			return iReferee;
       
    58 			}
       
    59 		Referee*	operator->()
       
    60 			{
       
    61 			if (iReferee==NULL)
       
    62 				{
       
    63 				iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
       
    64 				User::Panic(_L("null pointer"),__LINE__);
       
    65 				}
       
    66 			return iReferee;
       
    67 			}
       
    68 	private:
       
    69 		LoggerOwner* iOwner;
       
    70 		Referee* iReferee;
       
    71 		};
       
    72 	
       
    73 public:
       
    74 	CWsGceCscBase();
       
    75 	virtual ~CWsGceCscBase();
       
    76 	virtual void SetupL();
       
    77 	virtual void TearDownL();
       
    78 	virtual void TearDownFromDeleteL();
       
    79 
       
    80 protected:
       
    81 	typedef TBuf<KMaxTestName> TTestName;
       
    82 	
       
    83 	class TPostTestCleanup
       
    84 		{
       
    85 		protected:
       
    86 		TPostTestCleanup()	{}
       
    87 		public:
       
    88 		CSurfaceUtility*	iSharedUtility;
       
    89 		TBool				iCleanedUpOnExit;
       
    90 		};
       
    91 
       
    92 
       
    93 	typedef enum TOptimizationLevel
       
    94 		{
       
    95 		EDisable,
       
    96 		EDetectFrontmostFullScreenOpaqueLayer,
       
    97 		EMaximum,
       
    98 		} TOptimizationLevel;
       
    99 
       
   100 		
       
   101 protected:
       
   102 	void SetCompositionMode(RWindow& aWindow, TDisplayMode aMode);
       
   103 	
       
   104 	TBool Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2);
       
   105 
       
   106 	void ConstructOpaqueWindowLC(RWindow& aWindow, 
       
   107 			                     const TRgb& aColor,
       
   108 			                     TInt aPos,
       
   109 			                     const TPoint& aPoint,
       
   110 			                     const TSize& aSize);
       
   111 	
       
   112 	void ConstructOpaqueWindowL(RWindow& aWindow, 
       
   113 			                    const TRgb& aColor,
       
   114 			                    TInt aPos,
       
   115 			                    const TPoint& aPoint,
       
   116 			                    const TSize& aSize);
       
   117 	
       
   118 	void SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor);
       
   119 	
       
   120 	void ConstructOpaqueSurfacedWindowLC(RWindow& aWindow,
       
   121 		                                 const TRgb& aColor,
       
   122 		                                 TInt aPos,
       
   123 		                                 const TPoint& aPoint,
       
   124 		                                 const TSize& aSize,
       
   125 		                                 TSurfaceId& aSurfaceID);
       
   126 	void ConstructOpaqueSurfacedWindowL(RWindow& aWindow,
       
   127 		                                const TRgb& aColor,
       
   128 		                                TInt aPos,
       
   129 		                                const TPoint& aPoint,
       
   130 		                                const TSize& aSize,
       
   131 		                                const TSurfaceId& aSurfaceID);
       
   132 	
       
   133 protected:
       
   134 	inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0);
       
   135 	template <class DataType>	// DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion)
       
   136 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const
       
   137 	{
       
   138 	return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType));
       
   139 	}
       
   140 	TInt DebugInfo(TWsDebugInfoFunc aFunction, 
       
   141 			       TInt aParam, 
       
   142 			       TDes8& aHostBuffer,
       
   143 			       const void*&aReturnedObject,
       
   144 			       TInt aObjectSize)const;
       
   145 	void TefUnitFailLeaveL();
       
   146 	static void Pause(TInt aMilliseconds=200);
       
   147 	TBool GCEIsSupported() const;
       
   148 	static TBool GCEIsSupportedStatic();
       
   149 	static TPostTestCleanup& PostTestCleanupInstance();
       
   150 	
       
   151 protected:
       
   152 	TBool	iDoTearDown;
       
   153 	RWsSession iSession;
       
   154 	RWindowGroup iGroup;
       
   155 	CWsScreenDevice* iScreenDevice;
       
   156 	CWindowGc* iGc;
       
   157 	TInt iWindowHandle;
       
   158 	TBool	iTransparencyEnabled;
       
   159 	TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite;
       
   160 	TDisplayMode iDisplayMode;
       
   161 	SafePointer<CSurfaceUtility,CWsGceCscBase> iUtility;
       
   162 	static const TInt KMaxInfoLines=5;
       
   163 	TTestName iTestInfo[KMaxInfoLines];
       
   164 	TTestName iTestName;
       
   165 	static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
       
   166 	static const TInt KBytesPerPixel = 4;	// Four bytes per pixel for the format above.
       
   167 	TPerfProperties iProperties;
       
   168 };
       
   169 
       
   170 inline TInt CWsGceCscBase::ObjIndScr(TInt aScreen,
       
   171 		                                     TInt aWin,
       
   172 		                                     TInt aLayer,
       
   173 		                                     TInt aExtra)
       
   174 	{
       
   175 	return 	(aScreen<<EWsDebugArgScreenShift)
       
   176 		|	(aWin<<EWsDebugArgWindowShift)
       
   177 		|	(aLayer<<EWsDebugArgLayerShift)
       
   178 		|	(aExtra<<EWsDebugArgExtraShift);
       
   179 	}
       
   180 
       
   181 #endif /*TCWGCECSCBASE_H_*/