uiaccelerator_plat/alf_visual_api/inc/alf/alfscreenbuffer.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Screen buffer class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFSCREENBUFFER_H
       
    21 #define C_ALFSCREENBUFFER_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class CAlfEnv;
       
    26 
       
    27 /**
       
    28  * @deprecated 
       
    29  *  Observer class for screen buffer.
       
    30  */
       
    31 class MAlfScreenBufferObserver
       
    32     {
       
    33     /**
       
    34      * Screen buffer Events.
       
    35      */
       
    36 public:     
       
    37         enum TAlfScreenBufferEvent
       
    38             {
       
    39             ENone,
       
    40             ECreated,  			// Buffer created 
       
    41             EDeleted, 			// Buffer deleted
       
    42             ERestored, 			// Not yet implemented
       
    43             EReleased, 			// Not yet implemented
       
    44             EBufferDrawComplete // Buffer has been drawn to window
       
    45             };
       
    46     
       
    47     /**
       
    48      * Alf calls this when all the content have been draw to the back buffer.
       
    49      * If EFalse is returned, the buffer is locked until the observer calls RequestNextBuffer().
       
    50      * If ETrue is returned, the RequestNextBuffer() is called automatically, immediately after this method returns.
       
    51      *
       
    52      * @param aBufferUid Unique id of the buffer.
       
    53      * @param aDisplayRect Screen buffer rect.
       
    54      * @param aDirtyRect Dirty rect for the buffer.
       
    55      * @return Return True, if buffer can be freed automatically after this call.
       
    56      */
       
    57     virtual TBool BufferComplete(TUid aBufferUid, TRect& aDisplayRect, TRect& aDirtyRect) = 0;
       
    58     
       
    59     /**
       
    60      * Alf calls this when e.g. the back buffer is created or deleted.
       
    61      *
       
    62      * @param aId The unique id of the buffer.
       
    63      * @param aEvent @see MAlfScreenBufferObserver::TAlfScreenBufferEvent
       
    64      */
       
    65     virtual void HandleScreenBufferEvent(TUid aBufferUid, TInt aEvent) = 0;
       
    66     };
       
    67 
       
    68 
       
    69 /**
       
    70  * This interface is to be used when drawing the buffer to the window etc.      
       
    71  */
       
    72 class MAlfBufferDrawer
       
    73     {
       
    74 public:
       
    75     /**
       
    76      * Clean all resources (usually delete this).
       
    77      */
       
    78     virtual void ReleaseDrawer() = 0;    
       
    79     };
       
    80 
       
    81 /**
       
    82  * @deprecated 
       
    83  * This interface is to be used when modifying the buffer (sent back to server).      
       
    84  * Could be attached to special content visual.
       
    85  */
       
    86 class MAlfBufferGc
       
    87     {
       
    88     public:
       
    89     /**
       
    90      * Clean all resources (usually delete this).
       
    91      */
       
    92     virtual void ReleaseGc() = 0;
       
    93     };
       
    94 
       
    95 
       
    96 /**
       
    97  * @deprecated 
       
    98  * The class for managing screen buffers.
       
    99  *
       
   100  * Usage:
       
   101  * @code
       
   102  * 
       
   103  * //Create screen buffer and observer
       
   104  * CAlfScreenBuffer* screenBuffer = CAlfScreenBuffer::NewL( *iEnv );
       
   105  * CallbackObserver* observer = new (ELeave) CallbackObserver();
       
   106  * 
       
   107  * // Add observer
       
   108  * screenBuffer->AddObserverL( testScreenBufferUid, observer );
       
   109  * MAlfBufferDrawer* drawer = screenBuffer->GetDrawingInterface( SYMBIAN_BUFFER_DRAWER_UID, 
       
   110  * 																	testScreenBufferUid );
       
   111  * 
       
   112  * //Request for next sceenbuffer
       
   113  * screenBuffer->RequestNextBuffer( testScreenBufferUid );
       
   114  * 
       
   115  * drawer->ReleaseDrawer();
       
   116  * drawer = NULL; 
       
   117  * 
       
   118  * //Remove observer
       
   119  * 	screenBuffer->RemoveObserver( testScreenBufferUid );
       
   120  * 
       
   121  * //Clean up
       
   122  *  delete screenBuffer;
       
   123  *  delete observer;
       
   124  * 
       
   125  * @endcode
       
   126  */
       
   127 NONSHARABLE_CLASS(CAlfScreenBuffer): public CBase
       
   128     {
       
   129 public:
       
   130 	enum TAlfScreenBufferFlags 
       
   131 		{
       
   132 		EFlagNone = 0,
       
   133 		EFlagDisableDrawToWindow = 1 // Do not automatically draw buffer content to the window
       
   134 		};
       
   135 
       
   136     /**
       
   137      * Constructor.
       
   138      *
       
   139      * @param aEnv Alf environment.
       
   140      */
       
   141     IMPORT_C static CAlfScreenBuffer* NewL(CAlfEnv& aEnv);
       
   142     
       
   143     /**
       
   144      * Constructor.
       
   145      * 
       
   146      * Creates own Alf environment
       
   147      */
       
   148     IMPORT_C static CAlfScreenBuffer* NewL();
       
   149     
       
   150     /**
       
   151      * Destructor.
       
   152      *
       
   153      * If Alf environment is owned, it is deleted.
       
   154      */
       
   155     IMPORT_C virtual ~CAlfScreenBuffer();
       
   156     
       
   157     /**
       
   158      * Returns an instance of an interface for drawing the buffer e.g. to a window. 
       
   159      *
       
   160      * @param aInterfaceUid Unique id of the interface.
       
   161      * @param aBufferUid Unique id of the buffer.
       
   162      */
       
   163     IMPORT_C MAlfBufferDrawer* GetDrawingInterface(TUid aInterfaceUid, TUid aBufferUid);
       
   164     
       
   165     /**
       
   166      * Returns an instance of an interface for drawing to the buffer. 
       
   167      *
       
   168      * @param aInterfaceUid Unique id of the interface.
       
   169      * @param aBufferUid Unique id of the buffer.
       
   170      */
       
   171     IMPORT_C MAlfBufferGc* GetGraphicsContext(TUid aInterfaceUid, TUid aBufferUid);  
       
   172     
       
   173     /**
       
   174      * Request next buffer from the server. Unlocks buffer for drawing.
       
   175      *
       
   176      * @param aBufferUid Unique id of the buffer.
       
   177      */
       
   178     IMPORT_C void RequestNextBuffer(TUid aBufferUid);  
       
   179     
       
   180     /**
       
   181      * Request the server to draw the screen buffer to the window.
       
   182      *
       
   183      * @param aBufferUid Unique id of the buffer.
       
   184      */
       
   185     IMPORT_C void RequestBufferDraw(TUid aBufferUid);  
       
   186     
       
   187     /**
       
   188      * Add an observer for a buffer.
       
   189      *
       
   190      * @param aBufferUid Unique id of the buffer.
       
   191      * @param aObserver Pointer to the observer.
       
   192      * @param aPriority Not yet implemented.
       
   193      */
       
   194     IMPORT_C void AddObserverL(TUid aBufferUid, MAlfScreenBufferObserver* aObserver, TInt aPriority = 0  );  
       
   195     
       
   196     /**
       
   197      * Add an observer for a buffer.
       
   198      *
       
   199      * @param aBufferUid Unique id of the buffer.
       
   200      * @param aFlags Screen buffer flags.
       
   201      * @param aObserver Pointer to the observer.
       
   202      * @param aPriority Not yet implemented.
       
   203      */
       
   204     IMPORT_C void AddObserverL(TUid aBufferUid, TUint aFlags, MAlfScreenBufferObserver* aObserver, TInt aPriority = 0  );  
       
   205     
       
   206     /**
       
   207      * Remove observer from the buffer.
       
   208      *
       
   209      * @param aBufferUid Unique id of the buffer.
       
   210      */
       
   211     IMPORT_C void RemoveObserver(TUid aBufferId);  
       
   212 
       
   213 private: 
       
   214     	CAlfScreenBuffer();
       
   215     	CAlfScreenBuffer(CAlfEnv& aEnv);
       
   216 		void ConstructL(CAlfEnv* aEnv, TBool aIsAlfEnvOwned);
       
   217 		void ConstructL();
       
   218 		
       
   219 private:    
       
   220         class CPrivateData;
       
   221         CPrivateData* iData; 
       
   222     };
       
   223 
       
   224 #endif // C_ALFSCREENBUFFER_H