os/graphics/graphicscomposition/surfaceupdate/tsrc/tcompositionbackend.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicscomposition/surfaceupdate/tsrc/tcompositionbackend.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,127 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code 
    1.23 +*/
    1.24 +
    1.25 +
    1.26 +#if !defined(__TCOMPOSITIONBACKEND_H__)
    1.27 +#define __TCOMPOSITIONBACKEND_H__
    1.28 +
    1.29 +#include <e32base.h>
    1.30 +#include <graphics/surface.h>
    1.31 +#include <graphics/compositionsurfaceupdate.h>
    1.32 +#include <graphics/extensioncontainer.h>
    1.33 +#include "trequestorder.h"
    1.34 +
    1.35 +/**
    1.36 +The following constants signify the delay in microseconds between two 
    1.37 +emulations of composition. During the emulation mock receiver will 
    1.38 +process a number of outstanding requests and issues the signal 
    1.39 +back to the SUS. Content update receiver with highest priority will process the 
    1.40 +requests at highest rate.
    1.41 +*/
    1.42 +const TInt KCompositionInterval = 1000000 / 20; // for composition threads with normal priority
    1.43 +const TInt KCompositionIntervalLong = KCompositionInterval * 2; // for composition threads with lower priority
    1.44 +const TInt KCompositionIntervalShort = KCompositionInterval / 2; // for composition threads with higher priority
    1.45 +
    1.46 +enum RequestType
    1.47 +	{
    1.48 +	EReqEmpty = 0,
    1.49 +	EReqAvailable,
    1.50 +	EReqDisplayed,
    1.51 +	EReqDisplayedXTimes,	
    1.52 +	};
    1.53 +	
    1.54 +class RequestObject
    1.55 +	{
    1.56 +public:
    1.57 +	RequestType iType;
    1.58 +	TRequestStatus* iStatus;
    1.59 +	TUint32* iTimeStamp;
    1.60 +	TInt iDisplayedXTimes;
    1.61 +	};
    1.62 +
    1.63 +NONSHARABLE_CLASS(CTContentUpdateReceiver) : 
    1.64 +public CExtensionContainer,
    1.65 +public MCompositionSurfaceUpdate
    1.66 +	{
    1.67 +public:
    1.68 +	static CTContentUpdateReceiver* NewL(TInt aScreen);
    1.69 +	~CTContentUpdateReceiver();
    1.70 +	static TInt ThreadFunction(TAny* aAny);
    1.71 +	TInt Screen() {return iScreen;}
    1.72 +	void Stop();
    1.73 +	void SetCompositionOrder(CRequestOrder* aOrder) { iCompositionOrder = aOrder;}
    1.74 +	IMPORT_C void SetVisible(TBool aVisible);
    1.75 +	IMPORT_C TInt SetInternalPriority(TThreadPriority aInternalPriority);
    1.76 +	inline TBool OutstandingRequest(); //returns ETrue if there are any oustanding requests need to be processed by the mock receiver
    1.77 +
    1.78 +	/**	
    1.79 +	Mark the surface as dirty and request for composition.
    1.80 +	The function doesn't take onwership of aRegion
    1.81 +	*/	
    1.82 +	virtual void ContentUpdated(const TSurfaceId& 	aSurface, 
    1.83 +										TInt 			aBuffer, 
    1.84 +										const TRegion* 	aRegion, 
    1.85 +										TRequestStatus* aStatusAvailable, 
    1.86 +										TRequestStatus* aStatusDisplayed, 
    1.87 +										TUint32* 		aTimeStamp, 
    1.88 +										TRequestStatus* aStatusDispXTimes, 
    1.89 +										TInt* 			aDisplayedXTimes);
    1.90 +
    1.91 +	virtual void	Delete(void){}
    1.92 +	virtual TInt ApiVersion(void) {return 0;}
    1.93 +	virtual TVersion InternalVersion(void){return TVersion();}
    1.94 +protected:  //From CBase
    1.95 +    virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
    1.96 +private:
    1.97 +	CTContentUpdateReceiver(TInt aScreen);
    1.98 +	void ConstructL();
    1.99 +	TInt CheckNewNotifications();
   1.100 +	void DoSetInternalPriorityL();
   1.101 +	static TInt CallBack(TAny *aAny);
   1.102 +    TInt Add(TRequestStatus *aStatus, RequestType aType, 
   1.103 +            TInt aDisplayedXTimes = 1, TUint32* aTimeStamp = NULL);
   1.104 +	void Remove(TInt aIndex);		
   1.105 +private:
   1.106 +	TThreadId iThreadId; //thread from which ContentUpdated is called
   1.107 +	TThreadId iReceiverThreadId; 
   1.108 +	TBool iStop;
   1.109 +	TInt iScreen;
   1.110 +	CPeriodic* iPeriodic;
   1.111 +	RequestObject iArray[1024]; //should be big enough
   1.112 +	TInt iNumberElements;
   1.113 +	TBool iVisible;
   1.114 +	TBool iSetInternalPriority;
   1.115 +	TThreadPriority iInternalPriority;
   1.116 +	CRequestOrder* iCompositionOrder;
   1.117 +	RFastLock iLock;
   1.118 +	RSemaphore iPriorityLock;
   1.119 +	};
   1.120 +
   1.121 +IMPORT_C TInt StartTestUpdateReceiver(CTContentUpdateReceiver*& aReceiver, TInt aScreen);
   1.122 +IMPORT_C void CloseTestUpdateReceiver(CTContentUpdateReceiver* aReceiver);
   1.123 +
   1.124 +
   1.125 +
   1.126 +inline TBool CTContentUpdateReceiver::OutstandingRequest()
   1.127 +	{ return iNumberElements > 0;}
   1.128 +	
   1.129 +
   1.130 +#endif	// __TCOMPOSITIONBACKEND_H__