os/graphics/egl/egltest/inc/egltestcommonstep.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 //
    15 
    16 /**
    17  @file
    18  @test
    19 */
    20 
    21 #ifndef EGLTESTCOMMONSTEP_H
    22 #define EGLTESTCOMMONSTEP_H
    23 
    24 #include <e32msgqueue.h>
    25 #include <EGL/egl.h>
    26 #include <VG/openvg.h>
    27 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    28 #include <sgresource/sgresource.h>
    29 #else
    30 #include <graphics/sgresource.h>
    31 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    32 #include <test/testexecuteserverbase.h>
    33 #include <test/ttmsgraphicsstep.h>
    34 #include <test/egltestcommonutils.h>
    35 #include <test/egltestcommonsession.h>
    36 
    37 const TInt KDefaultWindowGroupId = 200;
    38 const TInt KMaxProcessNumber = 32;
    39 const TInt KMaxThreadNumber = 100;
    40 const TInt KNumSemaphore = 2;
    41 
    42 class RWindow;
    43 
    44 struct TEglStepMessageBuffer
    45     {
    46     TInt iBuf[64];
    47     };
    48 
    49 /**
    50 Abstract base class for Egl test steps
    51 */
    52 class CEglTestStep : public CTTMSGraphicsStep
    53 	{
    54 	friend class EglTestCommonProcess;
    55 
    56 public:
    57 	struct TThreadInfo
    58 		{
    59 		CEglTestStep*			 iSelf;
    60 		TInt 					 iIdx; // << index for example used to identify the thread to semaphores
    61 		} iThreadInfos[KMaxThreadNumber];
    62 
    63 	struct TThreadStatus
    64 		{
    65 		TThreadStatus();
    66 		enum TStatusId{ERendezvous, ELogin, ESize};
    67 		RThread			iThread;
    68 		TRequestStatus	iStatus[ESize];
    69 		};
    70 
    71 	struct TProcessStatus
    72 		{
    73 		RProcess		iProcess;
    74 		TRequestStatus	iStatus;
    75 		} iProcessStatus[KMaxProcessNumber];
    76 
    77 	// from CTestStep
    78 	IMPORT_C TVerdict doTestStepPreambleL();
    79 	IMPORT_C TVerdict doTestStepPostambleL();
    80 	IMPORT_C virtual ~CEglTestStep();
    81     
    82 	IMPORT_C void PartialInitialiseL(const TDesC& aStepName);
    83 	IMPORT_C void CleanAll();
    84 	IMPORT_C void CreateEglSessionL(TInt aIdx=0);
    85 	inline CTestEglSession* GetEglSess() {return iEglSess;};
    86 	
    87 protected:
    88 	IMPORT_C  CEglTestStep();
    89  
    90 	// Initialisation
    91 	void SetLoggerForProcessWrapperL();
    92 	
    93 	// Utility Methods
    94 	void HandleMark();
    95 	void HandleMarkEnd();
    96 	IMPORT_C void OpenWsSessionL(TInt aGroupId);
    97 	IMPORT_C void CloseWsSession();
    98 	IMPORT_C void ConstructWindowL(RWindow& aWindow, const TRect& aRect);
    99     IMPORT_C void PrintUsedPixelConfiguration();
   100     IMPORT_C void PrintPixelFormat(TUidPixelFormat aFormat);
   101     IMPORT_C void PrintVGImageFormat(VGImageFormat aAttr);
   102 
   103 	// Multi process test utils
   104 	IMPORT_C void Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName);
   105 	IMPORT_C void Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName, const TSgDrawableId& aSgId);
   106 	IMPORT_C void Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName, const RArray<TSgDrawableId>& aSgIdList);
   107 	void CheckProcessStatusL(TInt aIndex, const TRequestStatus& aStatus, const RProcess& aProcess);
   108 	inline TInt ImageIndexFromProcessId(TInt aProcess, TInt aImageCount) {return (aProcess % aImageCount);}
   109 	
   110 	// Multi threaded test utils
   111 	IMPORT_C void Test_MultiThreadL(TInt aThreadCount, TBool aWaitForCompletion);
   112 	IMPORT_C void Test_MultiThread_WaitL(TBool aCloseThreads, TThreadStatus::TStatusId aStatusId);
   113 	void CheckThreadStatusL(TInt aIndex, const TRequestStatus& aStatus, const RThread& aThread);
   114 	static TInt ThreadFunction(TAny* aSelf);
   115 	void ThreadFunctionL(TThreadInfo& aInfo);
   116 
   117 	IMPORT_C virtual void doThreadFunctionL(TInt aIdx);
   118 	IMPORT_C virtual void doThreadFunctionL(TInt aIdx,const TSgDrawableId& aSgId);
   119 	IMPORT_C void Rendezvous(TInt aIdx);
   120 	IMPORT_C virtual void doProcessFunctionL(TInt aIdx);
   121 	IMPORT_C virtual void doProcessFunctionL(TInt aIdx,const TSgDrawableId& aSgId);
   122 
   123 	// EGL helpers
   124 	IMPORT_C TBool CheckForExtensionL(TInt aExtensions, const TDesC& aExtensionName = KNullDesC);
   125 	IMPORT_C void GetDisplayL();
   126 	IMPORT_C void TerminateDisplayL();	
   127 
   128 	virtual void ReceiveMessageFromClient(RMsgQueue<TEglStepMessageBuffer>& /*aMessageQueueClientProcParam*/) {}
   129 protected:
   130 	// Session object as required for most tests
   131 	CTestEglSession* 	iEglSess;
   132 
   133 	// Whether to output verbose logging
   134 	TBool iVerboseLogging;
   135 	 
   136 	// Whether the test step needs to wait for thread completion during postamble 
   137 	TInt  iThreadCount;
   138 	TBool iWaitForCompletionOnPostamble;
   139 	
   140 	// The display is shared between threads.
   141 	EGLDisplay	iDisplay;
   142 
   143 	RSemaphore	iSemaphore[KNumSemaphore];
   144 	RArray<TThreadStatus> iThreadStatus;
   145 	
   146 	// pixel formats the test is run
   147 	TUidPixelFormat iSourceFormat;
   148 	VGImageFormat iSurfaceFormat;
   149 
   150 	TInt iProcHandleMark;
   151 	TInt iThreadHandleMark;
   152 	TInt iProcHandleMarkEnd;
   153 	TInt iThreadHandleMarkEnd;
   154 
   155 	RWsSession iWsSession;
   156 	RWindowGroup iWindowGroup;
   157 	};
   158 	
   159 #endif // EGLTESTCOMMONSTEP_H