os/graphics/graphicsdeviceinterface/directgdi/test/tdirectgdieglcontent_server.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) 2007-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
#ifndef __TDIRECTGDIEGLCONTENT_SERVER_H__
sl@0
    23
#define __TDIRECTGDIEGLCONTENT_SERVER_H__
sl@0
    24
sl@0
    25
#include <e32base.h>
sl@0
    26
#include <pixelformats.h>
sl@0
    27
#include <graphics/sgimage.h>
sl@0
    28
#include <graphics/sgimagecollection.h>
sl@0
    29
#include <GLES/egl.h>
sl@0
    30
sl@0
    31
/**
sl@0
    32
Egl content panic codes
sl@0
    33
*/
sl@0
    34
enum TEglContentPanic
sl@0
    35
	{
sl@0
    36
	EPanicBadDescriptor,
sl@0
    37
	EPanicIllegalFunction,
sl@0
    38
	EPanicAlreadyReceiving
sl@0
    39
	};
sl@0
    40
sl@0
    41
void PanicClient(const RMessagePtr2& aMessage, TEglContentPanic aPanic);
sl@0
    42
sl@0
    43
const TInt KEglContentDelay = 33333; // frame rate: 30 fps
sl@0
    44
sl@0
    45
class CGLCube;
sl@0
    46
sl@0
    47
/**
sl@0
    48
This class contains the egl content renderer.
sl@0
    49
CEglContent is a wrapper for CGLCube and works in two modes:
sl@0
    50
	- Synchronous – when requested for a TsgDrawableId object CEglContent 
sl@0
    51
		it returns it from CGLCube and the frame number is increased.  
sl@0
    52
		Thus in the next request the next frame is obtained. 
sl@0
    53
		Nothing is rendered until the new request occurs.
sl@0
    54
	- Asynchronous – in this mode CEglContent forces GLCube to render 
sl@0
    55
		frames at 30 fps frequency. On the request last rendered a frame is returned 
sl@0
    56
		and generation is continued in the background.
sl@0
    57
	- Asynchronous debug - start rendering the next frame (only one) immediately
sl@0
    58
*/
sl@0
    59
class CEglContent : public CTimer
sl@0
    60
	{
sl@0
    61
public:
sl@0
    62
	/** Available rendering modes */
sl@0
    63
	enum TMode
sl@0
    64
		{
sl@0
    65
		ESync, // Rendering is synchronised with client
sl@0
    66
		EAsync, // Rendering is asynchronous with fixed rate
sl@0
    67
		EAsyncDebug // Rendering is debug asynchronous with fixed rate
sl@0
    68
		};
sl@0
    69
public:
sl@0
    70
	static CEglContent* NewL();
sl@0
    71
	static CEglContent* NewLC();
sl@0
    72
	virtual ~CEglContent();
sl@0
    73
sl@0
    74
	void SetMode(TMode aMode);
sl@0
    75
	TInt GetImage(TSgDrawableId& aId);
sl@0
    76
sl@0
    77
private:
sl@0
    78
	CEglContent();
sl@0
    79
	void ConstructL();
sl@0
    80
	void RenderNextFrame();
sl@0
    81
sl@0
    82
private: // from CTimer
sl@0
    83
	void RunL();
sl@0
    84
sl@0
    85
private:
sl@0
    86
	CGLCube* iCube;
sl@0
    87
	/** Rendering mode (sync or async) */
sl@0
    88
	TMode iMode;
sl@0
    89
	/** Frame number to be rendered */
sl@0
    90
	TInt iFrame;
sl@0
    91
	/** Last rendered frame number */
sl@0
    92
	TInt iLastFrame;
sl@0
    93
	};
sl@0
    94
sl@0
    95
/**
sl@0
    96
This class contains egl content server.
sl@0
    97
Implements server and manages CEglContent object.
sl@0
    98
*/
sl@0
    99
class CEglContentServer : public CServer2
sl@0
   100
	{
sl@0
   101
public:
sl@0
   102
	static CServer2* NewLC();
sl@0
   103
	void AddSession();
sl@0
   104
	void DropSession();
sl@0
   105
	void GetSyncImage(TSgDrawableId& aId);
sl@0
   106
	TInt GetAsyncImage(TSgDrawableId& aId);
sl@0
   107
	TInt GetAsyncImageDebug(TSgDrawableId& aId);
sl@0
   108
private:
sl@0
   109
	CEglContentServer();
sl@0
   110
	~CEglContentServer();
sl@0
   111
	void ConstructL();
sl@0
   112
	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
sl@0
   113
private:
sl@0
   114
	TInt iSessionCount;
sl@0
   115
	CEglContent* iContent;
sl@0
   116
    };
sl@0
   117
sl@0
   118
/**
sl@0
   119
This class contains server side of egl content server session.
sl@0
   120
*/
sl@0
   121
class CEglContentSession : public CSession2
sl@0
   122
	{
sl@0
   123
public:
sl@0
   124
	CEglContentSession();
sl@0
   125
	void Create();
sl@0
   126
private:
sl@0
   127
	~CEglContentSession();
sl@0
   128
	CEglContentServer& Server();
sl@0
   129
	void ServiceL(const RMessage2& aMessage);
sl@0
   130
	void ServiceError(const RMessage2& aMessage, TInt aError);
sl@0
   131
	};
sl@0
   132
sl@0
   133
#endif