uiacceltk/hitchcock/AlfRenderStage/src/alfrssendbuffer.cpp
branchRCL_3
changeset 6 10534483575f
parent 3 d8a3531bc6b8
child 8 46927d61fef3
equal deleted inserted replaced
5:433cbbb6a04b 6:10534483575f
    46 const TInt KFrameHeaderSize = 5000;
    46 const TInt KFrameHeaderSize = 5000;
    47 const TInt KFrameOffsetTemplate = 12345678;
    47 const TInt KFrameOffsetTemplate = 12345678;
    48 const TInt KCacheChunkMinSize = 50000;
    48 const TInt KCacheChunkMinSize = 50000;
    49 const TUint8 KDivisibleByX = 8;
    49 const TUint8 KDivisibleByX = 8;
    50 const TInt KWindowFrameHeader1 = 6; // bytes
    50 const TInt KWindowFrameHeader1 = 6; // bytes
    51 const TInt KWindowFrameHeader2 = 18 + 10; // bytes // TP +10 
    51 
    52 
    52 #ifdef RD_SUBWINDOW_EFFECTS 
       
    53 const TInt KWindowFrameHeader2 = 23 + 10; // bytes // TP +10 
       
    54 #else
       
    55 const TInt KWindowFrameHeader2 = 23;
       
    56 #endif
    53 const TInt KAllRenderersMask = 63;
    57 const TInt KAllRenderersMask = 63;
    54 const TInt KPossiblePerformanceProblemInWindow = 64;
    58 const TInt KPossiblePerformanceProblemInWindow = 64;
    55 const TInt KPossiblePerformanceProblemInWindowThreshold = 1000;
    59 const TInt KPossiblePerformanceProblemInWindowThreshold = 1000;
    56 
    60 
       
    61 const TInt KFlushBufferTimeout = 50*1000; // 50ms
    57 
    62 
    58 enum TPatternSearchStates
    63 enum TPatternSearchStates
    59     {
    64     {
    60     ESeekSetClippingRegion = 0,
    65     ESeekSetClippingRegion = 0,
    61     ESeekBitBlit = 1,
    66     ESeekBitBlit = 1,
   440     {
   445     {
   441     // TODO
   446     // TODO
   442     }
   447     }
   443 
   448 
   444 // ---------------------------------------------------------------------------
   449 // ---------------------------------------------------------------------------
   445 // WriteFlagsL
       
   446 // ---------------------------------------------------------------------------
       
   447 //
       
   448 void CAlfRsSendBuffer::WriteFlagsL( )
       
   449     {
       
   450     if (iDisabled) // return if this send buffer is not in use
       
   451         {
       
   452         return;
       
   453         }
       
   454     
       
   455     // space has been reserved for us
       
   456     WriteInt8L( EAlfFrameFlags ); 
       
   457     WriteInt32L( iFlags);
       
   458     WriteInt8L( EAlfCommandEndMarker );
       
   459     }
       
   460 
       
   461 // ---------------------------------------------------------------------------
       
   462 // WriteCommandL
   450 // WriteCommandL
   463 // writes 1 TInt value to the stream
   451 // writes 1 TInt value to the stream
   464 // ---------------------------------------------------------------------------
   452 // ---------------------------------------------------------------------------
   465 //
   453 //
   466 void CAlfRsSendBuffer::WriteCommandL( const TUint8& aCommand, TInt aSize )
   454 void CAlfRsSendBuffer::WriteCommandL( const TUint8& aCommand, TInt aSize )
   661     if ( !iReceivingDrawingCommands )
   649     if ( !iReceivingDrawingCommands )
   662         {
   650         {
   663         WriteInt8L( EAlfCommandEndMarker );
   651         WriteInt8L( EAlfCommandEndMarker );
   664         }
   652         }
   665   
   653   
       
   654     }
       
   655 
       
   656 // ---------------------------------------------------------------------------
       
   657 // WriteRegionIntsL
       
   658 // ---------------------------------------------------------------------------
       
   659 //
       
   660 void CAlfRsSendBuffer::WriteRegionIntsL( const TUint8& aCommand, const TRegion& aRegion, 
       
   661         TInt aCount, TRefByValue<const TInt> aFirst, ...)
       
   662     {
       
   663     if (iDisabled) // return if this send buffer is not in use
       
   664         {
       
   665         return;
       
   666         }
       
   667     
       
   668     TInt count = aRegion.Count();
       
   669     const TInt size = sizeof(TInt32) * ( 4 * count + 1 + aCount);
       
   670 
       
   671     if (! InitCommandL( aCommand, size )){ return;}
       
   672 #ifdef _ALF_PRINT_WS_COMMANDS_    
       
   673     iCommandDebugger->SetDescriptionAndSize( aCommand, size, R_ALF_COMMAND_DESCRIPTION_ARRAY );
       
   674     iCommandDebugger->SetRegion( aRegion );
       
   675     iCommandDebugger->Print();
       
   676 #endif
       
   677 
       
   678 	if ( aCount > 0 )
       
   679 	    {
       
   680 	    aCount--; // first item is serialized separately. It seems to exist at different location as rest of the parameters.
       
   681 	    WriteInt32L( aFirst );
       
   682 	    WriteL( (TUint8*)&aFirst + sizeof(TInt32), aCount * sizeof(TInt32) );
       
   683 	    }
       
   684 
       
   685     WriteInt32L( count );
       
   686     TInt i = 0;
       
   687     while( i < count )
       
   688         {
       
   689         WriteL( (TUint8*)&aRegion[i].iTl.iX, 4 * sizeof(TInt32 ));
       
   690         i++;
       
   691         }
       
   692     
       
   693     if ( !iReceivingDrawingCommands )
       
   694         {
       
   695         WriteInt8L( EAlfCommandEndMarker );
       
   696         }    
   666     }
   697     }
   667 
   698 
   668 // ---------------------------------------------------------------------------
   699 // ---------------------------------------------------------------------------
   669 // WriteDescriptorAndIntsL
   700 // WriteDescriptorAndIntsL
   670 // writes aCount amount of variables to the stream and updates stream index.
   701 // writes aCount amount of variables to the stream and updates stream index.
   971     iPreviousCommand = EAlfCommandNotInitialized;
  1002     iPreviousCommand = EAlfCommandNotInitialized;
   972 	// Note, the size tells the maximum space needed for the command
  1003 	// Note, the size tells the maximum space needed for the command
   973     TInt size = sizeof(TUint32) + // windowId
  1004     TInt size = sizeof(TUint32) + // windowId
   974         sizeof(TUint32) + // next frame offset
  1005         sizeof(TUint32) + // next frame offset
   975         3 * sizeof(TUint8) + // command + contains unsupported commands + end marker
  1006         3 * sizeof(TUint8) + // command + contains unsupported commands + end marker
       
  1007         sizeof(TUint8) + sizeof(TUint32) + // orientation
   976         sizeof(TUint8) + // screen number ( in WriteFollowingFrameOffsetTemplate)
  1008         sizeof(TUint8) + // screen number ( in WriteFollowingFrameOffsetTemplate)
   977         sizeof(TUint32) * ( 4 * aRegionSize + 1 ) +  // updateregion 
  1009         sizeof(TUint32) * ( 4 * aRegionSize + 1 ) +  // updateregion 
   978         sizeof(TUint8) * KDivisibleByX + // possible padding
  1010         sizeof(TUint8) * KDivisibleByX + // possible padding
   979         sizeof(TUint32) * ( 4 * aShapeRegionSize + 1) + // possible shape region
  1011         sizeof(TUint32) * ( 4 * aShapeRegionSize + 1) + // possible shape region
   980         sizeof(EAlfCommandEndMarker); // endmarker for update region and this command
  1012         sizeof(EAlfCommandEndMarker); // endmarker for update region and this command
  1035 		// actual padding
  1067 		// actual padding
  1036         while ( startPadding-- )
  1068         while ( startPadding-- )
  1037             {
  1069             {
  1038             WriteInt8L( 0 );
  1070             WriteInt8L( 0 );
  1039 			}
  1071 			}
       
  1072 #ifdef RD_SUBWINDOW_EFFECTS         
  1040         iArrayImplOffset = iOffset;
  1073         iArrayImplOffset = iOffset;
  1041         InitMarker(iMarker);
  1074         InitMarker(iMarker);
       
  1075 #endif        
  1042 		WriteInt8L( EAlfFrameContainsUnsupportedCommands );
  1076 		WriteInt8L( EAlfFrameContainsUnsupportedCommands );
  1043         WriteInt8L( 0 );
  1077         WriteInt8L( 0 );
       
  1078 		WriteInt8L( EAlfFrameOrientation );
       
  1079 		WriteInt32L( iOrientation ); 
       
  1080         // These are for subwindow effects, that are not currently enabled
       
  1081 #ifdef RD_SUBWINDOW_EFFECTS         
  1044         WriteArrayHeaderTemplateL();
  1082         WriteArrayHeaderTemplateL();
  1045         InitTOffsetElemArray(iOffsetArray);
  1083         InitTOffsetElemArray(iOffsetArray);
       
  1084 #endif
  1046         // </HEADER2>
  1085         // </HEADER2>
  1047         }
  1086         }
  1048     }
  1087     }
  1049 
  1088 
  1050 // ---------------------------------------------------------------------------
  1089 // ---------------------------------------------------------------------------
  1055     {
  1094     {
  1056     if (iDisabled) // return if this send buffer is not in use
  1095     if (iDisabled) // return if this send buffer is not in use
  1057         {
  1096         {
  1058         return ETrue;
  1097         return ETrue;
  1059         }
  1098         }
       
  1099 #ifdef RD_SUBWINDOW_EFFECTS  
  1060     TOffsetElem e;
  1100     TOffsetElem e;
  1061     if (aSendArray)
  1101     if (aSendArray)
  1062         {
  1102         {
  1063         e = WriteIndexArrayL(iOffsetArray);
  1103         e = WriteIndexArrayL(iOffsetArray);
  1064         }
  1104         }
       
  1105 #endif
  1065     
  1106     
  1066 #ifdef _OLD_STREAM    
  1107 #ifdef _OLD_STREAM    
  1067     if ( iBufStream->Sink() )
  1108     if ( iBufStream->Sink() )
  1068 #endif        
  1109 #endif        
  1069         {
  1110         {
  1107             {
  1148             {
  1108             WriteInt8L( 0xff );
  1149             WriteInt8L( 0xff );
  1109 			}
  1150 			}
  1110         WriteInt8L( EAlfFrameContainsUnsupportedCommands );
  1151         WriteInt8L( EAlfFrameContainsUnsupportedCommands );
  1111 		WriteInt8L( iNonSupportedCommandsInWindow );
  1152 		WriteInt8L( iNonSupportedCommandsInWindow );
       
  1153 	    WriteInt8L( EAlfFrameOrientation );
       
  1154 	    WriteInt32L( iOrientation ); 
       
  1155 #ifdef RD_SUBWINDOW_EFFECTS 
  1112 		if (aSendArray) 
  1156 		if (aSendArray) 
  1113 		    {
  1157 		    {
  1114 		    WriteArrayHeaderL(e);
  1158 		    WriteArrayHeaderL(e);
  1115 		    }
  1159 		    }
       
  1160 #endif
  1116 		/*iWindowHeaderStruct.iWindowEndOffset = previousPos.Offset();
  1161 		/*iWindowHeaderStruct.iWindowEndOffset = previousPos.Offset();
  1117         iWindowHeaderStruct.iUnsupportedCommandsInWindow = iNonSupportedCommandsInWindow;
  1162         iWindowHeaderStruct.iUnsupportedCommandsInWindow = iNonSupportedCommandsInWindow;
  1118         iBufStream->WriteL( (TUint8*)&iWindowHeaderStruct, sizeof(TWindowHeaderStruct) );*/
  1163         iBufStream->WriteL( (TUint8*)&iWindowHeaderStruct, sizeof(TWindowHeaderStruct) );*/
  1119         // <HEADER2>
  1164         // <HEADER2>
  1120         // return to end of frame
  1165         // return to end of frame
  1132 //
  1177 //
  1133 
  1178 
  1134 const TInt KArrayOffsetTemplate = 23456789;
  1179 const TInt KArrayOffsetTemplate = 23456789;
  1135 const TInt KArraySizeTemplate = 23456789;
  1180 const TInt KArraySizeTemplate = 23456789;
  1136 
  1181 
       
  1182 #ifdef RD_SUBWINDOW_EFFECTS
  1137 void CAlfRsSendBuffer::WriteArrayHeaderTemplateL()
  1183 void CAlfRsSendBuffer::WriteArrayHeaderTemplateL()
  1138 {
  1184 {
  1139     WriteInt8L( EAlfCommandIndexArrayHeader );
  1185     WriteInt8L( EAlfCommandIndexArrayHeader );
  1140     WriteInt8L( 0 ); // align
  1186     WriteInt8L( 0 ); // align
  1141     WriteInt32L( KArrayOffsetTemplate ); // these will be rewritten in WriteArrayHeader2
  1187     WriteInt32L( KArrayOffsetTemplate ); // these will be rewritten in WriteArrayHeader2
  1244     }
  1290     }
  1245 void CAlfRsSendBuffer::EndMarkerL()
  1291 void CAlfRsSendBuffer::EndMarkerL()
  1246     {
  1292     {
  1247     EndMarkerL(iOffsetArray, iMarker, iBoundingRectangle, iLayerId);
  1293     EndMarkerL(iOffsetArray, iMarker, iBoundingRectangle, iLayerId);
  1248     }
  1294     }
       
  1295 #endif // RD_SUBWINDOW_EFFECTS
       
  1296 
  1249 // ---------------------------------------------------------------------------
  1297 // ---------------------------------------------------------------------------
  1250 // SendL
  1298 // SendL
  1251 // sends data syncronously in one or more packets to the streamer server
  1299 // sends data syncronously in one or more packets to the streamer server
  1252 // ---------------------------------------------------------------------------
  1300 // ---------------------------------------------------------------------------
  1253 //
  1301 //
  1352     Commit();
  1400     Commit();
  1353     // RDebug::Print(_L("CAlfRsSendBuffer::CommitL - %d %d %d "), iChunkHeader, iChunkHeader->iCommittedWriteOffset, iOffset );
  1401     // RDebug::Print(_L("CAlfRsSendBuffer::CommitL - %d %d %d "), iChunkHeader, iChunkHeader->iCommittedWriteOffset, iOffset );
  1354       if ( !iFlushBufferTimer )
  1402       if ( !iFlushBufferTimer )
  1355         {
  1403         {
  1356         iFlushBufferTimer = CPeriodic::NewL( EPriorityNormal );
  1404         iFlushBufferTimer = CPeriodic::NewL( EPriorityNormal );
  1357         iFlushBufferTimer->Start( 5000, 10 * 1000000 , TCallBack( doFlushBuffer, this ));
  1405         iFlushBufferTimer->Start( KFlushBufferTimeout, 10 * 1000000 , TCallBack( doFlushBuffer, this ));
  1358         }
  1406         }
  1359     if ( !iFlushBufferTimer->IsActive() )
  1407     if ( !iFlushBufferTimer->IsActive() )
  1360         {
  1408         {
  1361         //__ALFLOGSTRING("CAlfRsSendBuffer::CommitL, activating timer");
  1409         //__ALFLOGSTRING("CAlfRsSendBuffer::CommitL, activating timer");
  1362         iFlushBufferTimer->After( 5000 );
  1410         iFlushBufferTimer->After( KFlushBufferTimeout );
  1363         }
  1411         }
  1364     else
  1412     else
  1365     	{
  1413     	{
       
  1414         iFlushBufferTimer->Cancel();
       
  1415         iFlushBufferTimer->After( KFlushBufferTimeout );
  1366     	//__ALFLOGSTRING("CAlfRsSendBuffer::CommitL, timer already active ");
  1416     	//__ALFLOGSTRING("CAlfRsSendBuffer::CommitL, timer already active ");
  1367     	}
  1417     	}
  1368     }
  1418     }
  1369 
  1419 
  1370 // ---------------------------------------------------------------------------
  1420 // ---------------------------------------------------------------------------
  2117 #ifdef _OLD_STREAM    
  2167 #ifdef _OLD_STREAM    
  2118     iBufStream->Sink()->SeekL( MStreamBuf::EWrite, TStreamPos(aOffset));
  2168     iBufStream->Sink()->SeekL( MStreamBuf::EWrite, TStreamPos(aOffset));
  2119 #endif    
  2169 #endif    
  2120     iOffset = aOffset;
  2170     iOffset = aOffset;
  2121     }
  2171     }
       
  2172 
       
  2173 // ---------------------------------------------------------------------------
       
  2174 // SetOrientation
       
  2175 // ---------------------------------------------------------------------------
       
  2176 //
       
  2177 void CAlfRsSendBuffer::SetOrientation(TInt aOrientation)
       
  2178     {
       
  2179     iOrientation = aOrientation;
       
  2180     }
       
  2181