os/graphics/windowing/windowserver/test/tdynamicres/inc/wsgcedebugsession.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 WSGCEDEBUGSESSION_H_
    17 #define WSGCEDEBUGSESSION_H_
    18 
    19 #include <w32std.h>
    20 #include <w32debug.h>
    21 struct TWsDebugWindowId;
    22 
    23 class RWsDebugSession:public RWsSession
    24 	{
    25 public:
    26 	RWsDebugSession(TInt aScreenNo = -1);
    27 	~ RWsDebugSession();
    28 	using RWsSession::DebugInfo;		//exposes the following two functions:
    29 //	TInt	DebugInfo(TInt aFunction, TInt aParam=0) const;
    30 //	TInt	DebugInfo(TInt aFunction, TDes8& aReturnBuf, TInt aParam=0) const;
    31 	
    32 	/**	Returns an array of debug data about the specified object. 
    33 	 *  The data is placed in the aHostBuffer 
    34 	 * 	If data is returned, aReturnedObject points to the start of the returned data, and the return value is the number of DataType objects.
    35 	 * 	If no data is returned, aReturnedObject is NULL.
    36 	 *  If so the return code indicates an error code, or the required number of objects.
    37 	 * 	The object index is specified using the masks and shifts in TWsDebugClassArgMask
    38 	 *  Various error codes may be returned from the server, some of which may simply explain why no data is available.
    39 	 * 	The client may return 
    40 	 * 		KErrCancel to indicate that there is zero length of data
    41 	 * 		KErrCorrupt if the size of the returned data is not an exact multiple of DataType.
    42 	 * 	No other type checking is performed.  
    43 	 **/
    44 	template <class DataType>	// DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion)
    45 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const
    46 	{
    47 	return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType));
    48 	}
    49 	/**	Fills the region object with the specified debug information.
    50 	 * 	If required the region is resized to fit the data, which may fail with KErrNoMemory
    51 	 * 	The region will be forced to error state if an error code is returned.
    52 	 * 	Other details: see overloads
    53 	 **/
    54 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TRegion& aPreAllocatedReturnedRegion)const;
    55 	
    56 	/** Indicates the start of a "consistancy-critical-read" section and fetches the window list.
    57 	 * 	Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation.
    58 	 **/
    59 	TInt	ResetUpdatedAndGetSurfaceWindowList (const TWsDebugWindowId*&);
    60 	/** Indicates the start or end of a "consistancy-critical-read" section
    61 	 * 	Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation.
    62 	 * 	If this method returns ETrue then the data fetched since the start may be inconsistant, and should be refetched.
    63 	 * 	This method may also be used as a dirty way of waiting for a deferred update to occur.
    64 	 **/
    65 	TBool	ResetUpdated();
    66 	/**	Returns the screen number assigned when the stub was created. 
    67 	 **/
    68 	TInt DebugScreenNo()	{	return iScreenNo;	}
    69 	/** Helper method to correctly format the aObjectIndex parameter.
    70 	 **/
    71 	inline TInt ObjInd(TInt aWin=0,TInt aLayer=0,TInt aExtra=0)
    72 		{	return ObjIndScr(iScreenNo,aWin,aLayer,aExtra);	}
    73 	/** Helper method to correctly format the aObjectIndex parameter.
    74 	 **/
    75 	inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0);
    76 	
    77 	inline	TInt Finish(TBool aAndFlush=ETrue)
    78 		{
    79 		if (aAndFlush)
    80 			Flush();
    81 		return RWsSession::Finish();
    82 		}
    83 protected:
    84 	// Resolves the template parameter to a size. See overload docs for more info.
    85 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const void*&aReturnedObject,TInt aSize)const;
    86 	TInt	iScreenNo;
    87 	TInt	iSurfaceUpdateSerial;
    88 	RBuf8	iSurfaceListBuffer;
    89 	};
    90 inline TInt RWsDebugSession::ObjIndScr(TInt aScreen,TInt aWin,TInt aLayer,TInt aExtra)
    91 	{
    92 	return 	(aScreen<<EWsDebugArgScreenShift)
    93 		|	(aWin<<EWsDebugArgWindowShift)
    94 		|	(aLayer<<EWsDebugArgLayerShift)
    95 		|	(aExtra<<EWsDebugArgExtraShift);
    96 	}
    97 
    98 #endif /*WSGCEDEBUGSESSION_H_*/