sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Reference sample client-side "provider" interface CWsGraphic plugin using GCE Surfaces sl@0: // Copied from common/generic/graphics/wserv/nga/samplegraphicsurfacedrawer sl@0: // if the CRP tests suddenly starts to break or fail to build it might be due to this file has changed in CBR sl@0: // sl@0: // sl@0: sl@0: sl@0: #ifndef __GRAPHICSURFACE_H__ sl@0: #define __GRAPHICSURFACE_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: enum TDrawWsGraphicArgumentFlags sl@0: { sl@0: EDrawWsAllScreens =0x00000001, sl@0: EDrawWsTSurfaceIdIgnored =0x00000002, //* aScreensMap=NULL); sl@0: IMPORT_C static CWsGraphicSurface* NewL(TUid aUid,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray* aScreensMap=NULL); sl@0: IMPORT_C static CWsGraphicSurface* NewL(const TWsGraphicId& aReplace,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray* aScreensMap=NULL); sl@0: IMPORT_C void ConstructL(const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray* aScreensMap=NULL); sl@0: IMPORT_C void ConstructL(TUid aUid,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray* aScreensMap=NULL); sl@0: IMPORT_C void ConstructL(const TWsGraphicId& aReplace,const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray* aScreensMap=NULL); sl@0: IMPORT_C ~CWsGraphicSurface(); sl@0: protected: sl@0: IMPORT_C TInt ShareGlobally(); sl@0: IMPORT_C TInt UnShareGlobally(); sl@0: IMPORT_C TInt Share(TSecureId aClientId); sl@0: IMPORT_C TInt UnShare(TSecureId aClientId); sl@0: IMPORT_C TInt SendMessage(const TSurfaceConfiguration&); sl@0: IMPORT_C TInt SendMessage(const TWsGraphicAnimation&); sl@0: sl@0: virtual void HandleMessage(const TSurfaceConfiguration&) {} sl@0: virtual void HandleMessage(const TWsGraphicAnimation&) {} sl@0: virtual void HandleMessage(const TWsSurfaceUnreferenced&) {} sl@0: virtual void HandleMessage(const TWsDebugResultCode&) {} sl@0: virtual void HandleOtherMessage(const TWsGraphicMsgFixedBase&) {} sl@0: IMPORT_C virtual TInt CWsGraphicSurface_Reserved1(); sl@0: IMPORT_C virtual TInt CWsGraphicSurface_Reserved2(); sl@0: IMPORT_C virtual TInt CWsGraphicSurface_Reserved3(); sl@0: protected: sl@0: class TConstructParams; sl@0: IMPORT_C TConstructParams* MakeParamsLC(const TSurfaceConfiguration& aSurface, TUint aDrawWsGraphicArgumentFlags, const TArray* aScreensMap=NULL); sl@0: IMPORT_C CWsGraphicSurface(); //Derivers should implement NewL to call ConstructL sl@0: IMPORT_C void RegisterScreens(const TSurfaceConfiguration& aSurface,const TArray* aScreensMap=NULL); sl@0: IMPORT_C void UnRegisterScreens(); sl@0: private: sl@0: void HandleMessage(const TDesC8& aData); sl@0: void OnReplace(); sl@0: sl@0: private: //data sl@0: TSurfaceId iRegisteredId; sl@0: RArray iRegisteredScreens; sl@0: }; sl@0: sl@0: /** Used as the parameter payload to construct the drawer sl@0: */ sl@0: class CWsGraphicSurface::TConstructParams sl@0: { sl@0: public: sl@0: TInt Size() sl@0: { return iParamFlags.Size()+iConfig.Size()+2*sizeof(TWsGraphicMsgFixedBase); } sl@0: void* operator new(TUint size,TInt aNumExtras) sl@0: { sl@0: return ::operator new(size+((aNumExtras>=0)?aNumExtras*sizeof(TInt):0)); sl@0: } sl@0: void operator delete(void* aObj,TInt /*aNumExtras*/) sl@0: { sl@0: ::operator delete(aObj); sl@0: } sl@0: void operator delete(void* aObj) sl@0: { sl@0: ::operator delete(aObj); sl@0: } sl@0: TWsSurfaceConfiguration iConfig; sl@0: class TParamFlags:public TWsGraphicMsgFixedBase sl@0: { sl@0: public: sl@0: enum sl@0: { sl@0: ETypeId = 0x10285C59 sl@0: }; sl@0: sl@0: TParamFlags(): TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this)) sl@0: {} sl@0: TParamFlags(TInt aNumExtras): TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this)+aNumExtras*sizeof(TInt)) sl@0: {} sl@0: TUint iDrawWsGraphicArgumentFlags; sl@0: TUint iScreensMap[1]; //THIS MUST BE THE LAST FIELD!!! sl@0: } iParamFlags; sl@0: TConstructParams() sl@0: { } sl@0: TConstructParams(const TSurfaceConfiguration& aConfig,TInt aNumExtras=0) sl@0: : iConfig(aConfig),iParamFlags(aNumExtras) sl@0: { } sl@0: TCleanupItem CleanupItem() { return TCleanupItem(Cleanup,this); } sl@0: static void Cleanup(void* p) { delete(TConstructParams*)p; } sl@0: }; sl@0: sl@0: #endif //__GRAPHICSURFACE_H__ sl@0: