graphicscomposition/surfaceupdate/tsrc/tcompositionbackend.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2006-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  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 
       
    23 #if !defined(__TCOMPOSITIONBACKEND_H__)
       
    24 #define __TCOMPOSITIONBACKEND_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <graphics/surface.h>
       
    28 #include <graphics/compositionsurfaceupdate.h>
       
    29 #include <graphics/extensioncontainer.h>
       
    30 #include "trequestorder.h"
       
    31 
       
    32 /**
       
    33 The following constants signify the delay in microseconds between two 
       
    34 emulations of composition. During the emulation mock receiver will 
       
    35 process a number of outstanding requests and issues the signal 
       
    36 back to the SUS. Content update receiver with highest priority will process the 
       
    37 requests at highest rate.
       
    38 */
       
    39 const TInt KCompositionInterval = 1000000 / 20; // for composition threads with normal priority
       
    40 const TInt KCompositionIntervalLong = KCompositionInterval * 2; // for composition threads with lower priority
       
    41 const TInt KCompositionIntervalShort = KCompositionInterval / 2; // for composition threads with higher priority
       
    42 
       
    43 enum RequestType
       
    44 	{
       
    45 	EReqEmpty = 0,
       
    46 	EReqAvailable,
       
    47 	EReqDisplayed,
       
    48 	EReqDisplayedXTimes,	
       
    49 	};
       
    50 	
       
    51 class RequestObject
       
    52 	{
       
    53 public:
       
    54 	RequestType iType;
       
    55 	TRequestStatus* iStatus;
       
    56 	TUint32* iTimeStamp;
       
    57 	TInt iDisplayedXTimes;
       
    58 	};
       
    59 
       
    60 NONSHARABLE_CLASS(CTContentUpdateReceiver) : 
       
    61 public CExtensionContainer,
       
    62 public MCompositionSurfaceUpdate
       
    63 	{
       
    64 public:
       
    65 	static CTContentUpdateReceiver* NewL(TInt aScreen);
       
    66 	~CTContentUpdateReceiver();
       
    67 	static TInt ThreadFunction(TAny* aAny);
       
    68 	TInt Screen() {return iScreen;}
       
    69 	void Stop();
       
    70 	void SetCompositionOrder(CRequestOrder* aOrder) { iCompositionOrder = aOrder;}
       
    71 	IMPORT_C void SetVisible(TBool aVisible);
       
    72 	IMPORT_C TInt SetInternalPriority(TThreadPriority aInternalPriority);
       
    73 	inline TBool OutstandingRequest(); //returns ETrue if there are any oustanding requests need to be processed by the mock receiver
       
    74 
       
    75 	/**	
       
    76 	Mark the surface as dirty and request for composition.
       
    77 	The function doesn't take onwership of aRegion
       
    78 	*/	
       
    79 	virtual void ContentUpdated(const TSurfaceId& 	aSurface, 
       
    80 										TInt 			aBuffer, 
       
    81 										const TRegion* 	aRegion, 
       
    82 										TRequestStatus* aStatusAvailable, 
       
    83 										TRequestStatus* aStatusDisplayed, 
       
    84 										TUint32* 		aTimeStamp, 
       
    85 										TRequestStatus* aStatusDispXTimes, 
       
    86 										TInt* 			aDisplayedXTimes);
       
    87 
       
    88 	virtual void	Delete(void){}
       
    89 	virtual TInt ApiVersion(void) {return 0;}
       
    90 	virtual TVersion InternalVersion(void){return TVersion();}
       
    91 protected:  //From CBase
       
    92     virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
       
    93 private:
       
    94 	CTContentUpdateReceiver(TInt aScreen);
       
    95 	void ConstructL();
       
    96 	TInt CheckNewNotifications();
       
    97 	void DoSetInternalPriorityL();
       
    98 	static TInt CallBack(TAny *aAny);
       
    99     TInt Add(TRequestStatus *aStatus, RequestType aType, 
       
   100             TInt aDisplayedXTimes = 1, TUint32* aTimeStamp = NULL);
       
   101 	void Remove(TInt aIndex);		
       
   102 private:
       
   103 	TThreadId iThreadId; //thread from which ContentUpdated is called
       
   104 	TThreadId iReceiverThreadId; 
       
   105 	TBool iStop;
       
   106 	TInt iScreen;
       
   107 	CPeriodic* iPeriodic;
       
   108 	RequestObject iArray[1024]; //should be big enough
       
   109 	TInt iNumberElements;
       
   110 	TBool iVisible;
       
   111 	TBool iSetInternalPriority;
       
   112 	TThreadPriority iInternalPriority;
       
   113 	CRequestOrder* iCompositionOrder;
       
   114 	RFastLock iLock;
       
   115 	RSemaphore iPriorityLock;
       
   116 	};
       
   117 
       
   118 IMPORT_C TInt StartTestUpdateReceiver(CTContentUpdateReceiver*& aReceiver, TInt aScreen);
       
   119 IMPORT_C void CloseTestUpdateReceiver(CTContentUpdateReceiver* aReceiver);
       
   120 
       
   121 
       
   122 
       
   123 inline TBool CTContentUpdateReceiver::OutstandingRequest()
       
   124 	{ return iNumberElements > 0;}
       
   125 	
       
   126 
       
   127 #endif	// __TCOMPOSITIONBACKEND_H__