sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef TCWGCECSCBASE_H_ sl@0: #define TCWGCECSCBASE_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include "surfaceutility.h" sl@0: #include sl@0: sl@0: class TPerfProperties sl@0: { sl@0: public: sl@0: TBool GetValue(TUint aKey); sl@0: void PrintAllL(CTestFixture& aLogger); sl@0: TBool ResetValue(TUint aKey); sl@0: void UpdateAll(); sl@0: void ResetAll(); sl@0: private: sl@0: #ifdef GCE_BACKEND_PROFILING sl@0: TInt iValue[EPerfLastKey]; sl@0: TInt iPrevValue[EPerfLastKey]; sl@0: const static TBuf<100> propertyKeysTxt[EPerfLastKey]; sl@0: #endif sl@0: }; sl@0: sl@0: class CWsGceCscBase: public CTestFixture sl@0: { sl@0: sl@0: public: sl@0: template sl@0: class SafePointer sl@0: { sl@0: public: sl@0: SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): sl@0: iOwner(aOwner), iReferee(aReferee) sl@0: {} sl@0: Referee* operator=(Referee* aReferee) sl@0: { sl@0: return iReferee=aReferee; sl@0: } sl@0: Referee*& operator()() sl@0: { sl@0: return iReferee; sl@0: } sl@0: Referee* operator->() sl@0: { sl@0: if (iReferee==NULL) sl@0: { sl@0: iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); sl@0: User::Panic(_L("null pointer"),__LINE__); sl@0: } sl@0: return iReferee; sl@0: } sl@0: private: sl@0: LoggerOwner* iOwner; sl@0: Referee* iReferee; sl@0: }; sl@0: sl@0: public: sl@0: CWsGceCscBase(); sl@0: virtual ~CWsGceCscBase(); sl@0: virtual void SetupL(); sl@0: virtual void TearDownL(); sl@0: virtual void TearDownFromDeleteL(); sl@0: sl@0: protected: sl@0: typedef TBuf TTestName; sl@0: sl@0: class TPostTestCleanup sl@0: { sl@0: protected: sl@0: TPostTestCleanup() {} sl@0: public: sl@0: CSurfaceUtility* iSharedUtility; sl@0: TBool iCleanedUpOnExit; sl@0: }; sl@0: sl@0: sl@0: typedef enum TOptimizationLevel sl@0: { sl@0: EDisable, sl@0: EDetectFrontmostFullScreenOpaqueLayer, sl@0: EMaximum, sl@0: } TOptimizationLevel; sl@0: sl@0: sl@0: protected: sl@0: void SetCompositionMode(RWindow& aWindow, TDisplayMode aMode); sl@0: sl@0: TBool Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2); sl@0: sl@0: void ConstructOpaqueWindowLC(RWindow& aWindow, sl@0: const TRgb& aColor, sl@0: TInt aPos, sl@0: const TPoint& aPoint, sl@0: const TSize& aSize); sl@0: sl@0: void ConstructOpaqueWindowL(RWindow& aWindow, sl@0: const TRgb& aColor, sl@0: TInt aPos, sl@0: const TPoint& aPoint, sl@0: const TSize& aSize); sl@0: sl@0: void SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor); sl@0: sl@0: void ConstructOpaqueSurfacedWindowLC(RWindow& aWindow, sl@0: const TRgb& aColor, sl@0: TInt aPos, sl@0: const TPoint& aPoint, sl@0: const TSize& aSize, sl@0: TSurfaceId& aSurfaceID); sl@0: void ConstructOpaqueSurfacedWindowL(RWindow& aWindow, sl@0: const TRgb& aColor, sl@0: TInt aPos, sl@0: const TPoint& aPoint, sl@0: const TSize& aSize, sl@0: const TSurfaceId& aSurfaceID); sl@0: sl@0: protected: sl@0: inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0); sl@0: template // DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion) sl@0: TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const sl@0: { sl@0: return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType)); sl@0: } sl@0: TInt DebugInfo(TWsDebugInfoFunc aFunction, sl@0: TInt aParam, sl@0: TDes8& aHostBuffer, sl@0: const void*&aReturnedObject, sl@0: TInt aObjectSize)const; sl@0: void TefUnitFailLeaveL(); sl@0: static void Pause(TInt aMilliseconds=200); sl@0: TBool GCEIsSupported() const; sl@0: static TBool GCEIsSupportedStatic(); sl@0: static TPostTestCleanup& PostTestCleanupInstance(); sl@0: sl@0: protected: sl@0: TBool iDoTearDown; sl@0: RWsSession iSession; sl@0: RWindowGroup iGroup; sl@0: CWsScreenDevice* iScreenDevice; sl@0: CWindowGc* iGc; sl@0: TInt iWindowHandle; sl@0: TBool iTransparencyEnabled; sl@0: TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; sl@0: TDisplayMode iDisplayMode; sl@0: SafePointer iUtility; sl@0: static const TInt KMaxInfoLines=5; sl@0: TTestName iTestInfo[KMaxInfoLines]; sl@0: TTestName iTestName; sl@0: static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888; sl@0: static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above. sl@0: TPerfProperties iProperties; sl@0: }; sl@0: sl@0: inline TInt CWsGceCscBase::ObjIndScr(TInt aScreen, sl@0: TInt aWin, sl@0: TInt aLayer, sl@0: TInt aExtra) sl@0: { sl@0: return (aScreen<