vghwinterface/vghwapiwrapper/inc/apiwrapper.h
branchbug235_bringup_0
changeset 53 c2ef9095503a
parent 24 a3f46bb01be2
equal deleted inserted replaced
52:39e5f73667ba 53:c2ef9095503a
       
     1 // Copyright (c) 2010 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 #ifndef APIWRAPPER_H
       
    17 #define APIWRAPPER_H
       
    18 
       
    19 #ifndef PSU_PLATFORMTHREADING_H
       
    20 #include "platformthreading.h"
       
    21 #endif
       
    22 
       
    23 #ifndef PSU_PLATFORMTYPES_H
       
    24 #include "platformtypes.h"
       
    25 #endif
       
    26 #include "remotefunctioncall.h"
       
    27 
       
    28 class RemoteFunctionCall;
       
    29 class MGraphicsVHWCallback;
       
    30 
       
    31 class APIWrapperStack
       
    32 {
       
    33     public:
       
    34         APIWrapperStack(): iStack( NULL ), iStackIndex(0), iStackSize(0)
       
    35         {
       
    36         }
       
    37 
       
    38         bool InitStack( int stackSize )
       
    39         {
       
    40             if ( iStack )
       
    41             {
       
    42                 delete [] iStack;
       
    43             }
       
    44 
       
    45             iStack = (char*)new unsigned long[(stackSize+3)/4];
       
    46             iStackIndex = 0;
       
    47             iStackSize = stackSize;
       
    48             return iStack != NULL;
       
    49         }
       
    50 
       
    51         void* AllocFromStack( int size, int alignment )
       
    52         {
       
    53             unsigned int adjustedIndex = RemoteFunctionCallData::AlignIndex( iStackIndex, alignment );
       
    54             if ( adjustedIndex + size < iStackSize )
       
    55             {
       
    56                 iStackIndex = adjustedIndex + size;
       
    57                 return (void*)(iStack + adjustedIndex);
       
    58             }
       
    59             else
       
    60             {
       
    61                 return NULL;
       
    62             }
       
    63         }
       
    64 
       
    65         void ClearStack()
       
    66         {
       
    67             iStackIndex = 0;
       
    68         }
       
    69 
       
    70         ~APIWrapperStack()
       
    71         {
       
    72             delete [] iStack;
       
    73             iStack = NULL;
       
    74         }
       
    75 
       
    76     private:
       
    77 
       
    78         char* iStack;
       
    79         unsigned int iStackIndex;
       
    80         unsigned int iStackSize;
       
    81 };
       
    82 
       
    83 
       
    84 class APIWrapper
       
    85 {
       
    86 public:
       
    87 	virtual ~APIWrapper();
       
    88 
       
    89 	//void SetCurrentRFC(  );
       
    90 
       
    91 	virtual void SetProcessInformation( TUint32 aProcess, TUint32 aThread ) = 0;
       
    92 	virtual void Cleanup( TUint32 aProcess, TUint32 aThread ) = 0;
       
    93     virtual int DispatchRequest( unsigned long aCode ) = 0;
       
    94 
       
    95 protected:
       
    96     APIWrapper( RemoteFunctionCallData& currentFunctionCall, 
       
    97 		APIWrapperStack* stack,
       
    98         void* result,
       
    99 		MGraphicsVHWCallback* serviceIf);
       
   100 
       
   101 	virtual int WriteReply();
       
   102 
       
   103 protected:
       
   104 	RemoteFunctionCallData& m_currentFunctionCallData;
       
   105     void* m_currentResult;
       
   106     APIWrapperStack* iStack;
       
   107     MGraphicsVHWCallback* iServiceIf;
       
   108 };
       
   109 
       
   110 #endif