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