mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/inc/graphicsurface.h
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 // Copyright (c) 2007-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 // Reference sample client-side "provider" interface CWsGraphic plugin using GCE Surfaces
       
    15 // Copied from common/generic/graphics/wserv/nga/samplegraphicsurfacedrawer
       
    16 // if the CRP tests suddenly starts to break or fail to build it might be due to this file has changed in CBR
       
    17 // 
       
    18 //
       
    19 
       
    20 
       
    21 #ifndef __GRAPHICSURFACE_H__
       
    22 #define __GRAPHICSURFACE_H__
       
    23 
       
    24 #include <w32std.h>
       
    25 #include <w32stdgraphic.h>
       
    26 #include <graphics/surface.h>
       
    27 #include <graphics/surfaceconfiguration.h>
       
    28 
       
    29 enum TDrawWsGraphicArgumentFlags
       
    30 	{
       
    31 	EDrawWsAllScreens							=0x00000001,
       
    32 	EDrawWsTSurfaceIdIgnored 					=0x00000002,	//<Indicates that the client should NOT supply
       
    33 	EDrawWsNotifyProviderTSurfaceIdChanged		=0x00000100,
       
    34 	EDrawWsNotifyProviderConfigChanged			=0x00000200,
       
    35 	EDrawWsNotifyProviderPlayControlsChanged	=0x00000400,
       
    36 	EDrawWsNotifyProviderSurfaceUnreferenced	=0x00000800,
       
    37 	EDrawWsNotifyProviderConfigRereferenced		=0x00001000,	//<Triggers a one-shot config notification when drawn after an unreference
       
    38 	EDrawWsNotifyProviderConfigNextReref		=0x00002000,	//<Automatic one-shot set after unreferenced if 
       
    39 	EDrawWsNotifyError							=0x00010000,
       
    40 	EDrawWsNotifyProviderAll					=0x000FFF00,
       
    41 	EDrawWsUpdateTSurfaceId						=0x00100000,
       
    42 	EDrawWsUpdateConfiguration					=0x00200000,
       
    43 	EDrawWsUpdatePlayerControls					=0x00400000,
       
    44 	EDrawWsUpdateAll							=0x0FF00000,
       
    45 	};
       
    46 
       
    47 //KUidGraphicMsgSurface=  0x10285C57 	  To    0x10285C5B
       
    48 class TWsSurfaceConfiguration: public TWsGraphicMsgFixedBase
       
    49 /** data attached to a CWindowGc::DrawWsGraphic to allow the artwork to understand surface configuration commands.
       
    50 Also use to notify owner client of config change.
       
    51 
       
    52 @publishedAll
       
    53 @released
       
    54 */	{
       
    55 public:
       
    56 	enum
       
    57 		{
       
    58 		ETypeId = 0x10285C57
       
    59 		};
       
    60 		TWsSurfaceConfiguration()
       
    61 		:	TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this))
       
    62 		{	}
       
    63 		TWsSurfaceConfiguration(const TSurfaceConfiguration& aConfig)
       
    64 		:	TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this)),
       
    65 			iConfig(aConfig)
       
    66 			
       
    67 		{	}
       
    68 	TSurfaceConfiguration iConfig;
       
    69 	};
       
    70 
       
    71 class TWsDebugResultCode: public TWsGraphicMsgFixedBase
       
    72 /** Data attached to a message to the artwork provider notifying it of a command result code
       
    73 This code is always followed by the command that caused it (TSurfaceConfig)
       
    74 */
       
    75 	{
       
    76 public:
       
    77 	enum
       
    78 		{
       
    79 		ETypeId = 0x10285C5A
       
    80 		};
       
    81 	TWsDebugResultCode():	TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this))
       
    82 		{	}
       
    83 	TInt iResult;
       
    84 	TInt iExtra;
       
    85 	TInt iLineNum;
       
    86 	};
       
    87 
       
    88 
       
    89 class TWsSurfaceUnreferenced: public TWsGraphicMsgFixedBase
       
    90 /** data attached to a message to the artwork provider to allow it to react if a surface is no longer drawn
       
    91 play-stop-pause commands.
       
    92 
       
    93 @publishedAll
       
    94 @released
       
    95 */	{
       
    96 public:
       
    97 	enum
       
    98 		{
       
    99 		ETypeId = 0x10285C58
       
   100 		};
       
   101 	TWsSurfaceUnreferenced():	TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this))
       
   102 		{	}
       
   103 	TSurfaceId iId;
       
   104 	};
       
   105 class CWsGraphicDrawerSurface;
       
   106 class TWsDebugResultCode;
       
   107 class CWsGraphicSurface: public CWsGraphic
       
   108 /** Client representation of a window-server-side CFbsBitmap owned by this Client
       
   109 
       
   110 @publishedAll
       
   111 @released
       
   112 */
       
   113 	{
       
   114 	friend class CWsGraphicDrawerSurface;
       
   115 public:
       
   116 	IMPORT_C static CWsGraphicSurface* NewL(const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   117 	IMPORT_C static CWsGraphicSurface* NewL(TUid aUid,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   118 	IMPORT_C static CWsGraphicSurface* NewL(const TWsGraphicId& aReplace,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   119 	IMPORT_C  void ConstructL(const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   120 	IMPORT_C  void ConstructL(TUid aUid,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   121 	IMPORT_C  void ConstructL(const TWsGraphicId& aReplace,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   122 	IMPORT_C ~CWsGraphicSurface();
       
   123 protected: 
       
   124 	IMPORT_C TInt ShareGlobally();
       
   125 	IMPORT_C TInt UnShareGlobally();
       
   126 	IMPORT_C TInt Share(TSecureId aClientId);
       
   127 	IMPORT_C TInt UnShare(TSecureId aClientId);
       
   128 	IMPORT_C TInt SendMessage(const TSurfaceConfiguration&);
       
   129 	IMPORT_C TInt SendMessage(const TWsGraphicAnimation&);
       
   130 
       
   131 	virtual void HandleMessage(const TSurfaceConfiguration&)		{}
       
   132 	virtual void HandleMessage(const TWsGraphicAnimation&)			{}
       
   133 	virtual void HandleMessage(const TWsSurfaceUnreferenced&)		{}
       
   134 	virtual void HandleMessage(const TWsDebugResultCode&)		{}
       
   135 	virtual void HandleOtherMessage(const TWsGraphicMsgFixedBase&)	{}
       
   136 	IMPORT_C virtual TInt CWsGraphicSurface_Reserved1();
       
   137 	IMPORT_C virtual TInt CWsGraphicSurface_Reserved2();
       
   138 	IMPORT_C virtual TInt CWsGraphicSurface_Reserved3();
       
   139 protected:
       
   140 	class TConstructParams;
       
   141 	IMPORT_C TConstructParams* MakeParamsLC(const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray<TUint>*  aScreensMap=NULL);
       
   142 	IMPORT_C CWsGraphicSurface();		//Derivers should implement NewL to call ConstructL
       
   143 	IMPORT_C void RegisterScreens(const TSurfaceConfiguration& aSurface,const TArray<TUint>*  aScreensMap=NULL);
       
   144 	IMPORT_C void UnRegisterScreens();
       
   145 private:
       
   146 	void HandleMessage(const TDesC8& aData);
       
   147 	void OnReplace();
       
   148 
       
   149 private: //data
       
   150 	TSurfaceId		iRegisteredId;
       
   151 	RArray<TUint>	iRegisteredScreens;
       
   152 	};
       
   153 
       
   154 /** Used as the parameter payload to construct the drawer
       
   155 */
       
   156 class CWsGraphicSurface::TConstructParams
       
   157 	{
       
   158 public:
       
   159 	TInt Size()
       
   160 		{	return iParamFlags.Size()+iConfig.Size()+2*sizeof(TWsGraphicMsgFixedBase);	}
       
   161 	void* operator new(TUint size,TInt aNumExtras)
       
   162 		{
       
   163 		return ::operator new(size+((aNumExtras>=0)?aNumExtras*sizeof(TInt):0));
       
   164 		}
       
   165 	void operator delete(void* aObj,TInt /*aNumExtras*/)
       
   166 		{
       
   167 		::operator delete(aObj);
       
   168 		}
       
   169 	void operator delete(void* aObj)
       
   170 		{
       
   171 		::operator delete(aObj);
       
   172 		}
       
   173 	TWsSurfaceConfiguration iConfig;
       
   174 	class TParamFlags:public TWsGraphicMsgFixedBase
       
   175 		{
       
   176 		public:
       
   177 		enum
       
   178 			{
       
   179 			ETypeId = 0x10285C59
       
   180 			};
       
   181 
       
   182 		TParamFlags(): TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this))
       
   183 			{}
       
   184 		TParamFlags(TInt aNumExtras): TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this)+aNumExtras*sizeof(TInt))
       
   185 			{}
       
   186 		TUint iDrawWsGraphicArgumentFlags;
       
   187 		TUint iScreensMap[1];	//THIS MUST BE THE LAST FIELD!!!
       
   188 		} iParamFlags;
       
   189 	TConstructParams()	
       
   190 	{	}
       
   191 	TConstructParams(const TSurfaceConfiguration& aConfig,TInt aNumExtras=0)
       
   192 	:	iConfig(aConfig),iParamFlags(aNumExtras)
       
   193 	{	}
       
   194 	TCleanupItem	CleanupItem()	{ return TCleanupItem(Cleanup,this);	}
       
   195 	static void Cleanup(void* p)	{	delete(TConstructParams*)p;	}	
       
   196 	};
       
   197 
       
   198 #endif //__GRAPHICSURFACE_H__
       
   199