uiacceltk/hitchcock/AlfRenderStage/inc/alfrssendbuffer.h
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008 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:   Handles serializing of data and sending it to alf streamer server.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CALFSENDBUFFER_H_
       
    19 #define CALFSENDBUFFER_H_
       
    20 
       
    21 #include <e32cmn.h>
       
    22 #include <e32std.h> 
       
    23 #include <s32mem.h>
       
    24 #include <gdi.h>
       
    25 #include <alfwindowstructs.h>
       
    26 #include <huiwscanvascommands.h>
       
    27 #include "alfrenderstageutils.h"
       
    28 
       
    29 #define _OLD_STREAM
       
    30 
       
    31 const TInt KAlfWsCommandCount = 90; 
       
    32 const TInt KAlfWsMaxParameterCount = 15;
       
    33 const TInt KAlfRsSearchRectMaxCount = 9;
       
    34 
       
    35 class RAlfBridgerClient;
       
    36 class CAlfCommandDebug;
       
    37 class TRgb;
       
    38 class CAlfRenderStage;
       
    39 class TResourceReader;
       
    40 class CAlfCompositionCntrlClient;
       
    41 /**
       
    42  *  The class handles data serialization and syncronous sending to server. Multiple renderstages will share the same chunk.
       
    43  *
       
    44  *  @code
       
    45  *   iAlfSendBuffer = CAlfRsSendBuffer::NewL();
       
    46  *  @endcode
       
    47  *
       
    48  *  @lib alfrenderstage.lib
       
    49  *  @since S60 v5.2
       
    50  */
       
    51 NONSHARABLE_CLASS(CAlfRsSendBuffer) : public CActive, public MAlfBridge
       
    52 	{
       
    53     public: // New methods
       
    54       
       
    55 	    /**
       
    56 	     * NewL
       
    57 	     * 
       
    58 	     * Constructor
       
    59 	     * 
       
    60 	     * @param aParent   
       
    61 	     * @param aScreenNumber   
       
    62 	     * @return  New instance of the class
       
    63 	     */
       
    64 		static CAlfRsSendBuffer* NewL( CAlfRenderStage& aParent, TInt aScreenNumber );
       
    65 
       
    66 	    /**
       
    67 	     * C++ destructor.
       
    68 	     */
       
    69 		virtual ~CAlfRsSendBuffer();
       
    70 
       
    71 		/**
       
    72 	     * ConnectL
       
    73 	     *
       
    74 	     * Establish connection to AlfStreamerServer.
       
    75 	     *
       
    76 	     * @return ETrue, if connection was made or connection was already established. Otherwise returns EFalse
       
    77 	     */
       
    78 		TBool ConnectL();
       
    79 
       
    80         /**
       
    81          * Connected
       
    82          *
       
    83          * Check connection state
       
    84          *
       
    85          * @return Connection state
       
    86          */
       
    87 		TBool Connected(){ return iChunk.Handle(); }
       
    88 		
       
    89         /**
       
    90          * WriteIntsL
       
    91          * 
       
    92          * Convenience function for writing TInt values to the stream
       
    93          *
       
    94          * @param aCommand  CommandId
       
    95          * @param aCount    Amount of TInt values to be streamed
       
    96          * @param aFirst    The first value
       
    97          * @param ...       variable aCount-1 amount of TInt values
       
    98          */
       
    99 	    void WriteIntsL( const TUint8& aCommand, TInt aCount, TRefByValue<const TInt> aFirst, ...);
       
   100 
       
   101 	    /**
       
   102          * WriteIntL
       
   103          * 
       
   104          * Convenience function for writing possible unsupported command (depending on its parameters) to the stream 
       
   105          *
       
   106          * @param aCommand   CommandId
       
   107          * @param aValue    parameters value
       
   108          */
       
   109 	    void WriteIntL( const TUint8& aCommand, TInt aValue );
       
   110 	    
       
   111         /**
       
   112          * WriteRegionL
       
   113          * 
       
   114          * Convenience function for writing region to the stream 
       
   115          *
       
   116          * @param aCommand   CommandId
       
   117          * @param aRegion    Region
       
   118          */
       
   119 	    void WriteRegionL( const TUint8& aCommand, const TRegion& aRegion );
       
   120 	    
       
   121 	    /**
       
   122          * WriteDescriptorAndIntsL
       
   123          * 
       
   124          * Convenience function for writing TDesC reference and TInt values to the stream.
       
   125          * Inserts padding to ensure that text starts on divisible by 4 offset.
       
   126          *
       
   127          * @param aCommand  CommandId
       
   128          * @param aText     Descriptor to be streamed
       
   129          * @param aCount    Amount of TInt values to be streamed
       
   130          * @param aFirst    The first value
       
   131          * @param ...       variable aCount-1 amount of TInt values
       
   132          */
       
   133         void WriteDescriptorAndIntsL( const TUint8& aCommand, const TDesC& aText, TInt aCount, TRefByValue<const TInt> aFirst,... );
       
   134 
       
   135         /**
       
   136          * WriteDescriptorL
       
   137          * 
       
   138          * Convenience function for writing TDesC reference to the stream. 
       
   139          * Inserts padding to ensure that text starts on divisible by 4 offset.
       
   140          *
       
   141          * @param aCommand  CommandId
       
   142          * @param aText  Descriptor to be streamed
       
   143          * @param aTextParameter    Text parameters
       
   144          * @param aCount Amount of Ints to be streamed
       
   145          * @param aFirst    The first value
       
   146          * @param ...       variable aCount-1 amount of TInt values
       
   147          */
       
   148         void WriteDescriptorAndIntsL(const TUint8& aCommand, const TDesC& aText, const CGraphicsContext::TTextParameters* aTextParameter, TInt aCount, TRefByValue<const TInt> aFirst, ... );
       
   149 
       
   150 	    /**
       
   151          * WriteCommandL
       
   152          * 
       
   153          * Convenience function for writing 1 value to the stream
       
   154          *
       
   155          * @param aCommand  Command
       
   156          * @param aSize  Size
       
   157          */
       
   158         void WriteCommandL( const TUint8& aCommand, TInt aSize = 0);
       
   159 
       
   160         /**
       
   161          * WritePointArrayL
       
   162          * 
       
   163          * Convenience function for writing pointer array to the stream
       
   164          *
       
   165          * @param aCommand  CommandId
       
   166          * @param aPoWriteIntList  Point array to be streamed
       
   167          */
       
   168         void WritePointArrayL( const TUint8& aCommand, const CArrayFix<TPoint>* aPoWriteIntList );
       
   169 
       
   170         /**
       
   171          * WritePointArrayL
       
   172          * 
       
   173          * Convenience function for writing pointer array to the stream
       
   174          *
       
   175          * @param aCommand  CommandId
       
   176          * @param aPoWriteIntList  Point array to be streamed
       
   177          * @param aNumPoints  Point array to be streamed
       
   178          */
       
   179         void WritePointArrayL( const TUint8& aCommand, const TPoint* aPoWriteIntList, TInt aNumPoints );
       
   180 
       
   181         /**
       
   182          * WritePointArrayL
       
   183          * 
       
   184          * Convenience function for writing pointer array to the stream
       
   185          *
       
   186          * @param aCommand  CommandId
       
   187          * @param aPoWriteIntList  Point array to be streamed
       
   188          */
       
   189         void WritePointArrayL( const TUint8& aCommand, const TArray<TPoint>* aPoWriteIntList );
       
   190         
       
   191         /**
       
   192          * WriteFlagsL
       
   193          * 
       
   194          * Write flags to the stream
       
   195          */
       
   196         void WriteFlagsL();
       
   197         
       
   198 	//
       
   199 	// ARRAY IMPLEMENTATION
       
   200 	//	
       
   201 	struct TOffsetElem
       
   202 	{
       
   203 	TInt32 iOffset; // offset from beginning of buffer
       
   204 	TInt32 iSize;   // size of the data.
       
   205 	TInt32 iLayerId;
       
   206     TRect iBoundingRectangle;
       
   207     };
       
   208 
       
   209 
       
   210 	void WriteArrayHeaderTemplateL();
       
   211 	void InitTOffsetElemArray(RArray<TOffsetElem> &aOffset);
       
   212 	void WriteArrayHeaderL(const TOffsetElem &aIndexArrayOffset);
       
   213 	TOffsetElem WriteIndexArrayL(const RArray<TOffsetElem> &aOffset);
       
   214 	void InitMarker(TInt &aMarker);
       
   215 	void StartMarkerL(TInt &aMarker, TRect &aRectangle, TInt &aLayer, TRect aBoundingRectangle, TInt aLayerId);
       
   216 	void EndMarkerL(RArray<TOffsetElem> &aOffset, TInt &aMarker, const TRect &aRectangle, TInt aLayerId);
       
   217     void StartMarkerL(TRect aBoundingRectangle, TInt aLayerId);
       
   218     void EndMarkerL();
       
   219 	
       
   220        /**
       
   221         * SendL
       
   222         *
       
   223         * Sends commands to via AlfBridger to AlfStreamerServer. Flushes the buffer.
       
   224         * iBufStream is ready for writing after this call.
       
   225         *
       
   226         * @param aStatus  Request status
       
   227         */
       
   228         void SendL( TRequestStatus* aStatus );
       
   229 
       
   230         /**
       
   231          * Commit
       
   232          * 
       
   233          * Report the last written offset. Reader side may read until
       
   234 		 * offset.
       
   235          * 
       
   236          */
       
   237         void Commit();
       
   238 
       
   239         /**
       
   240          * CommitL
       
   241          * 
       
   242          * Starts the timer for FlushBuffer call. The idea is to deliver bigger 
       
   243          * patch of commands to alf in one go and avoid unnecessary IPC calls.
       
   244          * 
       
   245          */
       
   246         void CommitL( );
       
   247 
       
   248         /**
       
   249          * SetFlag
       
   250          * 
       
   251          * Set flags
       
   252          * 
       
   253          * @param aFlag  Flags
       
   254          */
       
   255         void SetFlag( TAlfSendBufferFrameFlags aFlag );
       
   256 
       
   257         /**
       
   258          * EndFrameL
       
   259          * 
       
   260          * Prepares frame for sending
       
   261          */
       
   262         void EndFrameL();
       
   263 
       
   264         /**
       
   265          * FrameContainsDataL
       
   266          * 
       
   267          * @return  ETrue, if data has been serialized to the frame after previous call to PrepareBufferL. this is used for filtering out empty
       
   268          *          frames. Wserv might be fixed in the future and this could become obsolete.
       
   269          */
       
   270         TBool FrameContainsDataL();
       
   271 
       
   272         /**
       
   273          * SendAsyncCmd
       
   274          * 
       
   275          * Called by CRsAlfNativeWindowListener::RequestEvent. Used when requesting native window handle from 
       
   276          * Alf.
       
   277          * 
       
   278          * @param aFlag  aCmd
       
   279          * @param aFlag  aBuf
       
   280          * @param aFlag  aStatus
       
   281          */
       
   282 		void SendAsyncCmd(TInt aCmd, TDes8& aBuf, TRequestStatus& aStatus);
       
   283 
       
   284         /**
       
   285          * OpenPrimaryChunkForWritingL
       
   286          * 
       
   287          * Open the stream 
       
   288          */
       
   289 		void OpenPrimaryChunkForWritingL();
       
   290 		
       
   291         /**
       
   292          * PrepareBufferL
       
   293          * 
       
   294          * Resets buffer. Must be called before Write*L and SendSyncL.
       
   295          */
       
   296         void PrepareBufferL();
       
   297 
       
   298 		/**
       
   299          * WriteWindowDataL
       
   300          *
       
   301          * Writes data to the stream
       
   302          *
       
   303          * @param aWindowUid
       
   304          * @param aRegionSize
       
   305          * @param aShapeRegionSize
       
   306          */
       
   307         void WriteWindowDataL(TUint32 aWindowUid, TInt aRegionSize, TInt aShapeRegionSize );
       
   308 
       
   309         /**
       
   310          * WriteFrameSizeTemplateL
       
   311          * 
       
   312          * Writes a temporary value to the beginning of a frame. This value is later updated with WriteNextFrameBeginL.
       
   313          */
       
   314         void WriteFollowingFrameOffsetTemplateL();
       
   315         
       
   316         /**
       
   317          * WriteFollowingFrameOffsetL
       
   318          * 
       
   319          * Goes back to header of the drawing commands and updates the offset to the following frame.
       
   320          * This is called, when drawing into a single window in a frame is complete.
       
   321          * 
       
   322          * @return  ETrue, If this frame contains any commands. Otherwise EFalse.
       
   323          */
       
   324         TBool WriteFollowingFrameOffsetL(TBool aWriteArray= ETrue);
       
   325 	 	
       
   326         /**
       
   327 		 * WriteWindowIdentifierL
       
   328 		 *
       
   329 		 * Convience function for writing window id and group id to the stream
       
   330 		 */
       
   331 		void WriteWindowIdentifierL();
       
   332 
       
   333 		/**
       
   334 		 * FlushBuffer
       
   335 		 * 
       
   336 		 * Commands are not passed immediately after they are serialized. There
       
   337 		 * is a timer, which regularly flushes the buffer. See doFlushBuffer. 
       
   338 		 *
       
   339 		 * Buffer is also flushed (or in fact the flushtimer is canceled, and buffer
       
   340 		 * is flushed) when SendL is called from CAlfRsRenderStage
       
   341 		 * 
       
   342 		 */
       
   343 		void FlushBuffer();
       
   344 
       
   345         /**
       
   346          * SetSupportedCommand
       
   347          * 
       
   348          * Sets this command as supported
       
   349          * 
       
   350          * @param aIndex
       
   351          * @param aSupport
       
   352          */
       
   353 		void SetSupportedCommand( TInt aIndex, TInt8 aSupport );
       
   354   
       
   355 		/**
       
   356 		 * AppendPatternSearchCache
       
   357 		 * 
       
   358 		 * Caches data for the pattern search. This is call from CAlfRsGc. Cache is released by
       
   359 		 * ResetPatternSearch.
       
   360 		 * 
       
   361          * @param aSourceBitmap
       
   362          * @param aMaskBitmap
       
   363          * @param aSourceRect
       
   364          * @param aDestPos
       
   365          * @param aInvertMask
       
   366 		 */
       
   367 	    void AppendPatternSearchCache( const CFbsBitmap& aSourceBitmap, const CFbsBitmap* aMaskBitmap,const TRect& aSourceRect, const TPoint& aDestPos, TBool aInvertMask );
       
   368 
       
   369         /**
       
   370          * PreviousCommand
       
   371          * 
       
   372          * This is used for filtering out sequential reset commands in window command stream
       
   373          * 
       
   374          * @return Previous command
       
   375          */
       
   376         inline TInt PreviousCommand(){ return iPreviousCommand; } 
       
   377         
       
   378     public: // From CActive
       
   379 
       
   380 	    void RunL();
       
   381 	    void DoCancel();
       
   382 
       
   383 	private:
       
   384 	    
       
   385        /**
       
   386         * CAlfRsSendBuffer
       
   387         * 
       
   388         * C++ constructor
       
   389         * 
       
   390         * @param aParent
       
   391         * @param aScreenNumber
       
   392         */
       
   393 	    CAlfRsSendBuffer( CAlfRenderStage& aParent, TInt aScreenNumber ) : iParent( aParent), iScreenNumber( aScreenNumber) , CActive( EPriorityStandard ){CActiveScheduler::Add( this ); };
       
   394 
       
   395        /**
       
   396         * ConstructL
       
   397         * 
       
   398         * Constructor
       
   399         */
       
   400         void ConstructL();
       
   401 
       
   402         /**
       
   403          * ReadNonSupportedCommandsL
       
   404          * 
       
   405          * It is known that some commands are not/cannot be supported by certain
       
   406          * renderers. Each frame is inspected in case of such command and frame 
       
   407          * is marked if it has unsupported commands for certain renderer. This
       
   408          * information can be in the future used for selecting suitable renderer
       
   409          * during runtime.
       
   410          * 
       
   411          * @todo This table could be shared with multiple renderstages. 
       
   412          *       Currently each sendbuffer has own table.
       
   413          */
       
   414         void ReadNonSupportedCommandsL();
       
   415         
       
   416         // only in debug mode
       
   417 #ifdef _ALF_PRINT_WS_COMMANDS_
       
   418         void ReadCommandDescriptionsL();
       
   419 #endif
       
   420 
       
   421 		/**
       
   422 		 * SeekL
       
   423 		 * 
       
   424 		 */
       
   425 	    void SeekL( const TInt aOffset );
       
   426 	    
       
   427 	    /**
       
   428 	     * ConvertToBitsL
       
   429 	     * 
       
   430 	     * Converts aCount bytes of data into one byte.
       
   431 	     * 
       
   432 	     * @param  aCount  Must be under 7.
       
   433 	     * @param  aReader
       
   434 	     * @return Converted result
       
   435 	     */
       
   436 	    TUint8 ConvertToBitsL( TInt aCount, TResourceReader* aReader );
       
   437            
       
   438         /**
       
   439          * JumpToAnotherChunkL
       
   440          */
       
   441 	    void JumpToAnotherChunkL( TInt32 aChunkId, TInt aChunkSize );
       
   442 
       
   443         /**
       
   444          * WriteInt8L
       
   445          */
       
   446 	    inline void WriteInt8L( const TInt8& aValue )
       
   447 	        {
       
   448 #ifdef _OLD_STREAM
       
   449 	        iBufStream->WriteInt8L( aValue );
       
   450 #else
       
   451 	        //memcpy( ( TUint8*)(iStreamPtr->Ptr()+iOffset), (const TUint8*)&aValue, sizeof(TInt8));
       
   452 	        *(( TUint8*)(iStreamPtr->Ptr()+iOffset)) = aValue;
       
   453 #endif
       
   454             iOffset += sizeof(TInt8);
       
   455             }
       
   456 		
       
   457         /**
       
   458          * WriteInt32L
       
   459          */
       
   460 	    inline void WriteInt32L( const TInt32& aValue )
       
   461 	        {
       
   462 #ifdef _OLD_STREAM
       
   463 	        iBufStream->WriteInt32L( aValue );
       
   464 #else
       
   465 	        memcpy( ( TUint8*)(iStreamPtr->Ptr()+iOffset), (const TUint8*)&aValue, sizeof(TInt32));
       
   466 #endif
       
   467             iOffset += sizeof(TInt32);
       
   468 	        }
       
   469 	    
       
   470         /**
       
   471          * WriteL
       
   472          */
       
   473 	    inline void WriteL( const TUint8* aPtr, TInt aSize )
       
   474 	        {
       
   475 #ifdef _OLD_STREAM	        
       
   476 	        iBufStream->WriteL( aPtr, aSize );
       
   477 #else
       
   478 	        memcpy( ( TUint8*)(iStreamPtr->Ptr()+iOffset), (const TUint8*)aPtr, aSize);
       
   479 #endif
       
   480 	        iOffset += aSize;
       
   481 	        }
       
   482 
       
   483         /**
       
   484          * DoCreateTemporaryChunkL
       
   485          */
       
   486 		void DoCreateTemporaryChunkL( TInt aMinimumRequiredSize );
       
   487 	    
       
   488 	    /**
       
   489 	     * DoWrapL
       
   490 	     * 
       
   491 	     * Wraps the writing in the chunk. This happens when write head has reached the maximum size of the chunk.
       
   492 	     * After wrapping, writing continues from the beginning of the chunk. If wrap happens during a frame, then 
       
   493 	     * the frame is split into two parts. The first part is padded (@see InsertPaddingL) 
       
   494 	     * 
       
   495 	     */
       
   496 	    void DoWrapL( TInt aCommandSize, TBool aCreateTempororaryChunk );
       
   497 	    
       
   498 	    /**
       
   499 	     * ReserveSpaceL
       
   500 	     * 
       
   501 	     * Checks if there is enough space to stream the command. Calls DoWrap 
       
   502 	     * or DoWait, if there is not enough space for serializing the command. 
       
   503 	     * 
       
   504 	     * @param  aCommandSize
       
   505 	     */
       
   506 	    TBool ReserveSpaceL( TInt aCommandSize );
       
   507 	    
       
   508         /**
       
   509          * InitCommandL
       
   510          */
       
   511 	    TBool InitCommandL( const TUint8& aCommand, TInt aSize );
       
   512 
       
   513         /**
       
   514          * CreateTemporaryChunkL
       
   515          */
       
   516 	    TBool CreateTemporaryChunkL( TInt& aSize );
       
   517 	    
       
   518         /**
       
   519          * OpenRewindChunkL
       
   520          */
       
   521 	    void OpenRewindChunkL( TInt aSize );
       
   522 	    
       
   523 	    /**
       
   524 	     * DoPatternSearch
       
   525 	     * 
       
   526 	     * Searches for certain bitblit pattern.
       
   527 	     * 
       
   528 	     * This functions is most likely to change in the future.
       
   529 	     * 
       
   530 	     */
       
   531 	    void DoPatternSearch( const TUint8& aCommand, TInt aSize );
       
   532 	    
       
   533 	    /**
       
   534 	     * ResetPatternSearch
       
   535 	     * 
       
   536 	     * Called when searched pattern was not found and search needs to start
       
   537 	     * from beginning.
       
   538 	     */
       
   539 	    void ResetPatternSearch();
       
   540 	  
       
   541 	    /**
       
   542 	     * FinalizePatternL
       
   543 	     * 
       
   544 	     * Full pattern was found. Replace the bitblits with EAlfCombinedBitBlit
       
   545 	     * that joins the clipping regions, drawrects and partial images into single 
       
   546 	     * command.
       
   547 	     */
       
   548 	    void FinalizePatternL(const TUint8& aCommand);
       
   549 	    
       
   550 	    /**
       
   551 	     * InsertPaddingL
       
   552 	     * 
       
   553 	     * Each frame payload need to start on address divisible by 4.
       
   554 	     * Otherwise operations on the streamed data will fail due to alignment
       
   555 	     * issues. This function adds padding if necessary.
       
   556 	     */
       
   557 	    void InsertPaddingL();
       
   558 
       
   559     public:	    
       
   560 	    RAlfBridgerClient* Client()
       
   561 	        {
       
   562             return iAlfBridgerClient;
       
   563             }
       
   564         void WriteIntsL(TUint8 aCommand, TInt aCount, TInt* aArray);
       
   565 	        
       
   566 	private:    // data
       
   567 	    
       
   568         /**
       
   569          * If this is true this class acts as a stub, the does not really do anything.
       
   570          * That is used when we handle tv-out drawing commands as they should not go to anywhere. 
       
   571          */
       
   572 	    TBool iDisabled;
       
   573 	    
       
   574         /**
       
   575     	 * Window Uid is cached for the use of FlushBuffer
       
   576     	 */
       
   577     	TUint32 iWindowId;
       
   578 
       
   579         TInt iWindowGroupIdentifier;
       
   580 
       
   581         /**
       
   582          * Stream access for chunk received from server side
       
   583          */
       
   584 #ifdef _OLD_STREAM
       
   585         RMemWriteStream* iBufStream;
       
   586 #else        
       
   587         TPtr8* iStreamPtr;
       
   588 #endif
       
   589         
       
   590         TInt iNextFrameOffsetPos;
       
   591         
       
   592         TBool iIsSprite;
       
   593         
       
   594         /**
       
   595     	 *	Bridge to Alf stream server
       
   596     	 *
       
   597     	 * 	Own.
       
   598     	 */
       
   599     	RAlfBridgerClient* iAlfBridgerClient;
       
   600 
       
   601         /**
       
   602          * Our handle to server chunk. InitBufferL must be called before this is valid.
       
   603          */
       
   604         RChunk iChunk;
       
   605 
       
   606         /**
       
   607          * Cache chunks are needed for 2 purposes. See DoCreateTemporaryChunkL for more information.
       
   608          * 1. During booting, the primary chunk (owned by alf) is not available and data must be serialized into something
       
   609          * 2. App (and sequentially Wserv) pushes more data than the primary chunk can chew (write head reachs read head).
       
   610          */  
       
   611         RArray<RChunk> iCacheChunks;
       
   612         
       
   613         /**
       
   614     	 * Non drawing window updates have no relevance to the drawing. If frame update contains only such
       
   615     	 * commands, it can be discarded altogether.
       
   616     	 *
       
   617     	 * Use Mark() to mark the place of frame start. Use RollBack() to set the buffer to the original place,
       
   618     	 * if only non-drawing commands were issued. See CAlfGraphicsContext::iDrawCommandCount for more details.
       
   619     	 */
       
   620 #ifdef _OLD_STREAM
       
   621         TStreamPos iFrameBeginOffset;
       
   622 #else
       
   623         TInt iFrameBeginOffset;
       
   624 #endif
       
   625         /**
       
   626          * Data transfer is normally asynchronous operation. iParent is used for the callback.
       
   627          * Not own.
       
   628          */
       
   629         CAlfRenderStage& iParent;
       
   630 
       
   631         /**
       
   632          * The maximum size of the iChunk and iBufStream
       
   633          */
       
   634         TInt iUsedChunkMaxSize;
       
   635         
       
   636         TInt iPrimaryChunkMaxSize;
       
   637         
       
   638         TTime   iBeginTime;
       
   639         
       
   640         TInt iOffset;
       
   641         
       
   642         /**
       
   643          * iState values
       
   644          */
       
   645         enum
       
   646             {
       
   647             EIdle,
       
   648             EWaitingAck,
       
   649             EWaitingHandle
       
   650             };
       
   651 
       
   652         TInt iState;
       
   653         
       
   654         TInt iTemplateOpen;
       
   655 
       
   656         TRequestStatus* iQuedStatus;
       
   657 
       
   658         TChunkHeader* iChunkHeader;
       
   659         
       
   660         TBool iReceivingDrawingCommands;
       
   661 
       
   662         /**
       
   663          * Debug variable for tracking the delivered chunk sizes. Can be used for optimizing the junk size.
       
   664          */
       
   665         //TInt iMaxSentBatchSize;
       
   666         
       
   667         TBool iWrappingFrame;
       
   668         
       
   669         /**
       
   670          * Screen connected to this CAlfRsSendBuffer
       
   671          */
       
   672         TInt iScreenNumber; 
       
   673 
       
   674         CPeriodic* iFlushBufferTimer;
       
   675         
       
   676         TUint8 iNonSupportedCommandsInWindow;
       
   677         
       
   678         /**
       
   679          * See ReadNonSupportedCommandsL for more information
       
   680          */
       
   681         TUint8 iNonSupportedCommands[KAlfWsCommandCount];
       
   682 
       
   683         TUint8 iSupportedCommandParameters[KAlfWsCommandCount][2]; // [index of first parameter in iSupportedParameters][index of last parameter in iSupportedParameters] 
       
   684         TInt8 iSupportedParameters[KAlfWsMaxParameterCount][2]; // [parameter value][render support], note the limited count
       
   685         
       
   686         TInt iPerformanceIssueCommandCount;
       
   687         
       
   688         TInt iMaxPerformanceIssueCommandCount;
       
   689         
       
   690         struct TWindowHeaderStruct
       
   691             {
       
   692             TInt32 iWindowEndOffset;
       
   693             TUint8 iCommandEndMarker;
       
   694             TUint8 iContainsUnsupportedCommandsCommand;
       
   695             TUint8 iUnsupportedCommandsInWindow;
       
   696             };
       
   697                 
       
   698         TWindowHeaderStruct iWindowHeaderStruct;
       
   699         
       
   700         TUint8 iFramePadding;
       
   701         
       
   702         TInt32 iFlags;
       
   703 
       
   704         TUint8 iPreviousCommand;
       
   705         
       
   706         /**
       
   707          * AlfRsSendBuffers searches certain bitblit pattern in the serialized 
       
   708          * commands. It tries to combine joined bitblits into one command, which 
       
   709          * can be handled more efficiently on HW.
       
   710          * 
       
   711          * See DoPatternSearch, AppendPatternSearchCache, ResetPatternSearch and FinalizePatternL for more 
       
   712          * information.
       
   713          * 
       
   714          */ 
       
   715         TInt iPatternSearchState;
       
   716         
       
   717         TInt iPatterSearchSequentialBlits;
       
   718         
       
   719         TInt iPenStyle;
       
   720         
       
   721         /**
       
   722          * Under normal circumtances, a single chunk is used for passing the 
       
   723          * commands to alf. However, if Wserv pushes large frames that fill the
       
   724          * whole chunk, alfsendbuffer takes a growing cache chunk into use.
       
   725          * 
       
   726          * The cache chunk is destroyed, when it is no longer needed.
       
   727          */
       
   728        
       
   729         TUint8 iChunkInUse;
       
   730         
       
   731         /**
       
   732          * Joined clipping region is usually different than the following joined blit region (iSearchPatternBlitRect)
       
   733          */
       
   734         RRegionBuf<KAlfRsSearchRectMaxCount> iSearchPatternClipRegion;
       
   735         
       
   736         RRegionBuf<KAlfRsSearchRectMaxCount> iSearchPatternBlitRect;
       
   737         
       
   738         class TBlitStruct
       
   739             {
       
   740         
       
   741         public:
       
   742         
       
   743         	TBlitStruct( TInt aHandle, TInt aMaskHandle, TPoint aTl ) : iHandle( aHandle ), iMaskHandle( aMaskHandle ), iTl( aTl ){};
       
   744             TInt iHandle;
       
   745             TInt iMaskHandle;
       
   746             TPoint iTl;
       
   747             };
       
   748         
       
   749         RArray<TBlitStruct> iPatternHandleCache;
       
   750 #ifdef _OLD_STREAM        
       
   751         TStreamPos iPatternCacheBeginPosition;
       
   752 #else
       
   753         TInt iPatternCacheBeginPosition;
       
   754 #endif
       
   755         TBool iBooting;
       
   756         
       
   757 #ifdef _ALF_PRINT_WS_COMMANDS_
       
   758 
       
   759         /**
       
   760          * debug for printing the serializaed commands in human understandable format
       
   761          */
       
   762         TBool iLog;
       
   763         
       
   764         CAlfCommandDebug* iCommandDebugger;
       
   765         
       
   766         class TPatternCommand
       
   767             {
       
   768         public:
       
   769         
       
   770             TPatternCommand( TUint8 aCommand, TInt aSize ): iCommand( aCommand ), iSize(aSize){};
       
   771             
       
   772             TUint8 iCommand;
       
   773             
       
   774             TInt iSize;
       
   775             };
       
   776 			
       
   777         RArray<TPatternCommand> iPatternCommands;
       
   778                 
       
   779 #endif  
       
   780 
       
   781         // caches text. If same text is used 2nd time inside buffer
       
   782         HBufC16* iCachedText;
       
   783         CAlfCompositionCntrlClient* iAlfCompositionCntrlClient;
       
   784         
       
   785         // array implementation
       
   786         RArray<TOffsetElem> iOffsetArray;
       
   787         TInt iMarker;
       
   788         TRect iBoundingRectangle;
       
   789         TInt iLayerId;
       
   790         TInt iArrayImplOffset;
       
   791         TInt iPreviousBlockOffset;
       
   792         TInt iExtraLayerId;
       
   793         TBool iLayersEnabled;
       
   794 	};
       
   795 #endif /*CALFSENDBUFFER_H_*/