uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp
branchRCL_3
changeset 50 1801340c26a2
parent 49 c9d868f1e20c
child 51 e5af45d51884
equal deleted inserted replaced
49:c9d868f1e20c 50:1801340c26a2
    31     #include "alflogger.h"
    31     #include "alflogger.h"
    32     #undef _ALF_LOGGING
    32     #undef _ALF_LOGGING
    33 #else
    33 #else
    34     #include "alflogger.h"
    34     #include "alflogger.h"
    35 #endif
    35 #endif
       
    36 
       
    37 #ifdef ALF_MEMORYLOGGING
       
    38 #include <hal.h>
       
    39 #endif
       
    40 
    36 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    37 // Constructor
    42 // Constructor
    38 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
    39 //
    44 //
    40 CAlfNode::CAlfNode( ) :  
    45 CAlfNode::CAlfNode( ) :  
    41     iVisible( ETrue )
    46     iVisible( ETrue )
    42     {
    47     {
    43     }
    48     }
    44 
    49 
       
    50 
       
    51 void CAlfNode::ReportOOM()
       
    52     {
       
    53 #ifdef ALF_MEMORYLOGGING
       
    54     RDebug::Printf("CAlfNode::ReportOOM");
       
    55 
       
    56     TInt totalSpaceAllocated = 0;
       
    57     TInt cellsAllocatedInHeap = User::AllocSize(totalSpaceAllocated);
       
    58     TInt largestFreeBlock = 0;
       
    59     TInt totalFreeSpaceInHeap = User::Available(largestFreeBlock);
       
    60     TInt freeRAM = 0;
       
    61     if ( HAL::Get( HALData::EMemoryRAMFree, freeRAM ) != KErrNone )
       
    62         {
       
    63         freeRAM = -1;
       
    64         }
       
    65         
       
    66     RDebug::Printf("CAlfNode::ReportOOM - Allocated space: %d, Amount of allocated cells: %d, Largest free block: %d, Free space in heap: %d",
       
    67             totalSpaceAllocated,
       
    68             cellsAllocatedInHeap,
       
    69             largestFreeBlock,
       
    70             totalFreeSpaceInHeap);
       
    71     RDebug::Printf("CAlfNode::ReportOOM - Free RAM in system: %d", freeRAM);
       
    72 #endif
       
    73     }
    45 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    46 // ConstructL
    75 // ConstructL
    47 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    48 //
    77 //
    49 void CAlfNode::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream  )
    78 void CAlfNode::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream  )
   363 // CAlfNode::TraverseNodeTree
   392 // CAlfNode::TraverseNodeTree
   364 // Traverse through node tree and fill node array 
   393 // Traverse through node tree and fill node array 
   365 // ---------------------------------------------------------------------------
   394 // ---------------------------------------------------------------------------
   366 //
   395 //
   367 
   396 
   368 // ---------------------------------------------------------------------------
       
   369 // CAlfNode::TraverseNodeTree
       
   370 // Traverse through node tree and fill node array 
       
   371 // ---------------------------------------------------------------------------
       
   372 //
       
   373 
       
   374 void CAlfNode::TraverseNodeTree( CAlfNode* node,  RPointerArray<CAlfNode>& nodes, TBool aTraverseOnlySiblings, TBool aAddMe)
   397 void CAlfNode::TraverseNodeTree( CAlfNode* node,  RPointerArray<CAlfNode>& nodes, TBool aTraverseOnlySiblings, TBool aAddMe)
   375     {
   398     {
   376     // Exit if we've already finished walking the tree.
   399     // Exit if we've already finished walking the tree.
   377     if ( node == NULL) 
   400     if ( node == NULL) 
   378         { 
   401         { 
   379         __ALFLOGSTRING(" returning NULL");                                  
   402         __ALFLOGSTRING("TraverseNodeTree returning - NULL");                                  
   380         return;
   403         return;
   381         }
   404         }
   382     if (!aTraverseOnlySiblings)
   405     
   383         {
   406     while ( node )
   384         if ( node->iSpriteChild ) 
   407         {
   385             {
   408         if (!aTraverseOnlySiblings)
   386         CAlfNode* spritenode = node->iSpriteChild ;
   409             {   
   387             while ( spritenode )
   410             if ( node->iSpriteChild ) 
   388                 {
   411                 {
   389                 nodes.Append( spritenode );                
   412                 CAlfNode* spritenode = node->iSpriteChild ;
   390                 spritenode = spritenode->iSibling;
   413                 while ( spritenode )
   391                 }
   414                     {
   392             }
   415                     nodes.Append( spritenode );                
   393     
   416                     spritenode = spritenode->iSibling;
   394         if( node->iTextCursor )
   417                     }
   395             {
   418                 }
   396             nodes.Append(node->iTextCursor );            
   419     
   397             }
   420             if( node->iTextCursor )
   398     
   421                 {
   399         if( node->iAnimChild )
   422                 nodes.Append(node->iTextCursor );            
   400             {
   423                 }
   401             CAlfNode* animnode = node->iAnimChild ;
   424     
   402             while ( animnode )
   425             if( node->iAnimChild )
   403                 {
   426                 {
   404                 nodes.Append( animnode );                
   427                 CAlfNode* animnode = node->iAnimChild ;
   405                 animnode = animnode->iSibling;
   428                 while ( animnode )
   406                 }
   429                     {
   407             }
   430                     nodes.Append( animnode );                
       
   431                     animnode = animnode->iSibling;
       
   432                     }
       
   433                 }
   408         
   434         
   409         if ( node->iChild)
   435             if ( node->iChild)
   410             {                
   436                 {                
   411             TraverseNodeTree(node->iChild , nodes, EFalse, ETrue);            
   437                 TraverseNodeTree(node->iChild , nodes, EFalse, ETrue);            
   412             }
   438                 }
   413         } 
   439             } 
   414 
   440 
   415     if (aAddMe)
   441         if (aAddMe)
   416         {
   442             {
   417         nodes.Append( node );
   443             nodes.Append( node );
   418         }
   444             }
   419 
   445 
   420     if ( node->iSibling )
   446         // Without recursion, continue with the following:
   421         {                
   447         // TraverseNodeTree(node->iSibling, nodes, ETrue, ETrue);
   422         TraverseNodeTree(node->iSibling, nodes, ETrue, ETrue);               
   448         node = node->iSibling;
       
   449         aTraverseOnlySiblings = ETrue;
       
   450         aAddMe = ETrue;
   423         }
   451         }
   424     }
   452     }
   425 
   453 
   426 // ---------------------------------------------------------------------------
   454 // ---------------------------------------------------------------------------
   427 // OrdinalPosition
   455 // OrdinalPosition
   988 //
  1016 //
   989 TAny* CAlfNode::CreateWindowAttributes(TInt& aIndex, TInt aSize )
  1017 TAny* CAlfNode::CreateWindowAttributes(TInt& aIndex, TInt aSize )
   990     {
  1018     {
   991     TAny* attributes = NULL;
  1019     TAny* attributes = NULL;
   992     TRAP_IGNORE(attributes = (TAny*)iModel->Server().Bridge()->AppendVarDataL( aSize, aIndex ))
  1020     TRAP_IGNORE(attributes = (TAny*)iModel->Server().Bridge()->AppendVarDataL( aSize, aIndex ))
   993     Mem::FillZ( (TUint8*)attributes, aSize ); // Initialize the returned memory area to 0
  1021     if (attributes)
       
  1022         {
       
  1023         Mem::FillZ( (TUint8*)attributes, aSize ); // Initialize the returned memory area to 0
       
  1024         }
       
  1025     else
       
  1026         {
       
  1027         CAlfNode::ReportOOM();
       
  1028         }
   994     return attributes;
  1029     return attributes;
   995     }
  1030     }
   996 
  1031 
   997 // ---------------------------------------------------------------------------
  1032 // ---------------------------------------------------------------------------
   998 // SiblingOrderChanged
  1033 // SiblingOrderChanged
  1305             {
  1340             {
  1306             //!!!! There is no window???
  1341             //!!!! There is no window???
  1307             // position must be updated, because it not necessary the first drawn.
  1342             // position must be updated, because it not necessary the first drawn.
  1308             TInt offset;
  1343             TInt offset;
  1309             TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
  1344             TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
  1310             windowAttributes->iOrdinalPosition = ordinal; 
  1345             if (windowAttributes)
  1311             windowAttributes->iWindowNodeType = iType;
  1346                 {
  1312             windowAttributes->iScreenNumber = iScreenNumber;
  1347                 windowAttributes->iOrdinalPosition = ordinal; 
  1313             // for updating window group ordinals
  1348                 windowAttributes->iWindowNodeType = iType;
  1314             iModel->Server().Bridge()->AddData( EAlfDSReorder, 
  1349                 windowAttributes->iScreenNumber = iScreenNumber;
  1315                     iGroupId, 
  1350                 // for updating window group ordinals
  1316                     iId, 
  1351                 iModel->Server().Bridge()->AddData( EAlfDSReorder, 
  1317                     (TAny*)offset );
  1352                         iGroupId, 
       
  1353                         iId, 
       
  1354                         (TAny*)offset );
       
  1355                 }
       
  1356 			else
       
  1357 				{
       
  1358 		        CAlfNode::ReportOOM();
       
  1359 				}
  1318             }
  1360             }
  1319         }
  1361         }
  1320     AMT_MAP_NODE_SET_ORDINAL_POSITION();
  1362     AMT_MAP_NODE_SET_ORDINAL_POSITION();
  1321     }
  1363     }
  1322 
  1364 
  1382        iType != MWsWindowTreeNode::EWinTreeNodeStandardTextCursor &&
  1424        iType != MWsWindowTreeNode::EWinTreeNodeStandardTextCursor &&
  1383         !iAlphaChannelTransparencyEnabled)
  1425         !iAlphaChannelTransparencyEnabled)
  1384         {
  1426         {
  1385         nodeFlags |= EAlfWinNodeFlagOpaque;         
  1427         nodeFlags |= EAlfWinNodeFlagOpaque;         
  1386         }
  1428         }
  1387         
  1429     
  1388     if ( iType == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor )
  1430 	// New drawing commands always replace all the previous drawing commands for text cursor and anim nodes.
       
  1431     if (   iType == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor 
       
  1432         || iType == MWsWindowTreeNode:: EWinTreeNodeAnim )
  1389         {
  1433         {
  1390         emptyBuffer = ETrue;
  1434         emptyBuffer = ETrue;
  1391         }
  1435         }
  1392        
  1436        
  1393     iWindow->PostPartialBuffer( iModel->ChunkBase(aChunkInUse) + aCurrentPos, aFrameSize, aPartial, aLastPart , emptyBuffer, nodeFlags );
  1437     iWindow->PostPartialBuffer( iModel->ChunkBase(aChunkInUse) + aCurrentPos, aFrameSize, aPartial, aLastPart , emptyBuffer, nodeFlags );
  1508                 {
  1552                 {
  1509                 iWindow->SetTransparencyAlphaChannel( aNewValue );
  1553                 iWindow->SetTransparencyAlphaChannel( aNewValue );
  1510                 }
  1554                 }
  1511             break;
  1555             break;
  1512             }
  1556             }
       
  1557         case MWsWindowTreeObserver::EScreenDeviceValid:
       
  1558             {
       
  1559             iWindow->SetScreenDeviceValid(aNewValue);
       
  1560             break;
       
  1561             }
       
  1562         default:
       
  1563             break;
  1513         }
  1564         }
  1514     if ( aFlag == MWsWindowTreeObserver::ENonFading && HasChildren() )
  1565     if ( aFlag == MWsWindowTreeObserver::ENonFading && HasChildren() )
  1515         {
  1566         {
  1516         UpdateChildrenFlags( aFlag, iFadeState );
  1567         UpdateChildrenFlags( aFlag, iFadeState );
  1517         }
  1568         }
  1900     
  1951     
  1901     ResolveParent( parentId, iId );
  1952     ResolveParent( parentId, iId );
  1902     
  1953     
  1903     TInt offset;
  1954     TInt offset;
  1904     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
  1955     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
  1905     windowAttributes->iWindowNodeType = iType; 
  1956     if (windowAttributes)
  1906     windowAttributes->iClientHandle = clientHandle;
  1957         {
  1907     windowAttributes->iScreenNumber = iScreenNumber;
  1958         windowAttributes->iWindowNodeType = iType; 
  1908     windowAttributes->iSecureId = iSecureId;
  1959         windowAttributes->iClientHandle = clientHandle;
  1909     windowAttributes->iParentNodeId = parentId;
  1960         windowAttributes->iScreenNumber = iScreenNumber;
  1910 	
  1961         windowAttributes->iSecureId = iSecureId;
  1911     iModel->Server().Bridge()->AddData( EAlfDSNewWindow, 
  1962         windowAttributes->iParentNodeId = parentId;
  1912             iGroupId, 
  1963         
  1913             iId, 
  1964         iModel->Server().Bridge()->AddData( EAlfDSNewWindow, 
  1914             (TAny*)offset );
  1965                 iGroupId, 
  1915     
  1966                 iId, 
       
  1967                 (TAny*)offset );
       
  1968         }
       
  1969     else
       
  1970         {
       
  1971         CAlfNode::ReportOOM();
       
  1972         }
       
  1973         
  1916     AMT_MAP_STREAMER_NODE_GROUP_CONSTRUCT();
  1974     AMT_MAP_STREAMER_NODE_GROUP_CONSTRUCT();
  1917 	}
  1975 	}
  1918 
  1976 
  1919 // ---------------------------------------------------------------------------
  1977 // ---------------------------------------------------------------------------
  1920 // NewL
  1978 // NewL
  2003     
  2061     
  2004     if (iModel)
  2062     if (iModel)
  2005         {
  2063         {
  2006         TInt offset;
  2064         TInt offset;
  2007         TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
  2065         TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
  2008         windowAttributes->iWindowNodeType = iType; 
  2066         if (windowAttributes)
  2009         windowAttributes->iScreenNumber = iScreenNumber; 
  2067             {
  2010 
  2068             windowAttributes->iWindowNodeType = iType; 
  2011         iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
  2069             windowAttributes->iScreenNumber = iScreenNumber; 
  2012                 iGroupId, 
  2070     
  2013                 iId, 
  2071             iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
  2014                 (TAny*)offset );
  2072                     iGroupId, 
       
  2073                     iId, 
       
  2074                     (TAny*)offset );
       
  2075             }
       
  2076 		else
       
  2077 			{
       
  2078 			CAlfNode::ReportOOM();
       
  2079 			}
  2015         iWindow = 0; // just in case
  2080         iWindow = 0; // just in case
  2016         }
  2081         }
  2017     RemoveDependencies( iParent->iChild );
  2082     RemoveDependencies( iParent->iChild );
  2018     };
  2083     };
  2019 
  2084 
  2142     
  2207     
  2143     CreateWindowL(0,0,iParent->iId); // Currently renderstage does not deliver ws/wg handles
  2208     CreateWindowL(0,0,iParent->iId); // Currently renderstage does not deliver ws/wg handles
  2144     TInt offset;
  2209     TInt offset;
  2145     // pass rest of the cursor data
  2210     // pass rest of the cursor data
  2146     TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes));
  2211     TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes));
  2147     attributes->iColor = iColor;
  2212     if (attributes)
  2148     attributes->iFlags = iFlags;
  2213         {
  2149     attributes->iFlashInterval = iFlashInterval;
  2214         attributes->iColor = iColor;
  2150     attributes->iScreenNumber = iScreenNumber;
  2215         attributes->iFlags = iFlags;
  2151     
  2216         attributes->iFlashInterval = iFlashInterval;
  2152     aModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
  2217         attributes->iScreenNumber = iScreenNumber;
  2153             iGroupId, 
  2218         
  2154             iId, 
  2219         aModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
  2155             (TAny*)offset );
  2220                 iGroupId, 
  2156     
  2221                 iId, 
  2157     UpdateOrdinalPosition();
  2222                 (TAny*)offset );
  2158     
  2223         
  2159     AMT_MAP_STREAMER_TEXT_CURSOR_CONSTRUCT();
  2224         UpdateOrdinalPosition();
       
  2225         
       
  2226         AMT_MAP_STREAMER_TEXT_CURSOR_CONSTRUCT();
       
  2227         }
       
  2228 	else
       
  2229 		{
       
  2230 		CAlfNode::ReportOOM();
       
  2231 		}
  2160     }
  2232     }
  2161 
  2233 
  2162 // ---------------------------------------------------------------------------
  2234 // ---------------------------------------------------------------------------
  2163 // NewL
  2235 // NewL
  2164 // ---------------------------------------------------------------------------
  2236 // ---------------------------------------------------------------------------
  2204             break;
  2276             break;
  2205             }
  2277             }
  2206         }
  2278         }
  2207     TInt offset;
  2279     TInt offset;
  2208     TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes));
  2280     TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes));
  2209        attributes->iColor = iColor;
  2281     if (attributes)
  2210        attributes->iFlags = iFlags;
  2282         {
  2211        attributes->iFlashInterval = iFlashInterval;
  2283         attributes->iColor = iColor;
  2212        attributes->iScreenNumber = iScreenNumber;
  2284         attributes->iFlags = iFlags;
  2213        __ALFLOGSTRING("Forwarding cursor data");
  2285         attributes->iFlashInterval = iFlashInterval;
  2214        iModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
  2286         attributes->iScreenNumber = iScreenNumber;
       
  2287         __ALFLOGSTRING("Forwarding cursor data");
       
  2288         iModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
  2215                iGroupId, 
  2289                iGroupId, 
  2216                iId, 
  2290                iId, 
  2217                (TAny*)offset );
  2291                (TAny*)offset );
  2218        
  2292         AMT_MAP_STREAMER_TEXT_CURSOR_CHANGE();
  2219    AMT_MAP_STREAMER_TEXT_CURSOR_CHANGE();
  2293         }
       
  2294 	else
       
  2295 		{
       
  2296 		CAlfNode::ReportOOM();
       
  2297 		}		
  2220     }
  2298     }
  2221 CAlfNodeTextCursor::~CAlfNodeTextCursor( )
  2299 CAlfNodeTextCursor::~CAlfNodeTextCursor( )
  2222     {
  2300     {
  2223     // text cursor is the only text cursor in its parent. No need to check siblings.
  2301     // text cursor is the only text cursor in its parent. No need to check siblings.
  2224     if(iParent)
  2302     if(iParent)