uiacceltk/hitchcock/ServerCore/Src/alfwindow.cpp
branchRCL_3
changeset 18 1801340c26a2
parent 6 10534483575f
child 19 e5af45d51884
--- a/uiacceltk/hitchcock/ServerCore/Src/alfwindow.cpp	Thu Jul 15 19:40:07 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfwindow.cpp	Thu Aug 19 10:48:02 2010 +0300
@@ -28,6 +28,10 @@
 #include <string.h>
 #include <s32mem.h>
 
+#ifdef ALF_MEMORYLOGGING
+#include <hal.h>
+#endif
+
 // ---------------------------------------------------------------------------
 // NewL
 // ---------------------------------------------------------------------------
@@ -59,7 +63,30 @@
         delete iData;
         }
     }
-        
+
+void CAlfWindow::ReportOOM()
+    {
+#ifdef ALF_MEMORYLOGGING
+    RDebug::Printf("CAlfWindow::ReportOOM");
+    TInt totalSpaceAllocated = 0;
+    TInt cellAllocatedInHeap = User::AllocSize(totalSpaceAllocated);
+    TInt largestFreeBlock = 0;
+    TInt totalFreeSpaceInHeap = User::Available(largestFreeBlock);
+    TInt freeRAM = 0;
+    if ( HAL::Get( HALData::EMemoryRAMFree, freeRAM ) != KErrNone )
+        {
+        freeRAM = -1;
+        }
+
+    RDebug::Printf("CAlfWindow::ReportOOM - Allocated space: %d, Amount of allocated cells: %d, Largest free block: %d, Free space in heap: %d",
+            totalSpaceAllocated,
+            cellAllocatedInHeap,
+            largestFreeBlock,
+            totalFreeSpaceInHeap);
+    RDebug::Printf("CAlfWindow::ReportOOM - Free RAM in system: %d", freeRAM);
+#endif
+    }
+
 // ---------------------------------------------------------------------------
 // WsInfo
 // ---------------------------------------------------------------------------
@@ -507,21 +534,28 @@
     const TInt size = ( 4*aRegion.Count() + 4 ) * sizeof(TInt32);
     TAny* data = (TAny*)iData->iWindowManager->Bridge()->AppendVarDataL( size, aOffset );
 
-    RMemWriteStream str( data, size );
-    str.WriteInt32L( aScreenNumber );
-    str.WriteInt32L( aOrigin.iX );
-    str.WriteInt32L( aOrigin.iY );
-    str.WriteInt32L( aRegion.Count() );
-        
-    for (TInt i = 0; i < aRegion.Count(); ++i )
+    if (data)
         {
-        const TRect rect(aRegion[i]);
-        str.WriteInt32L(rect.iTl.iX);
-        str.WriteInt32L(rect.iTl.iY);
-        str.WriteInt32L(rect.iBr.iX);
-        str.WriteInt32L(rect.iBr.iY);
+        RMemWriteStream str( data, size );
+        str.WriteInt32L( aScreenNumber );
+        str.WriteInt32L( aOrigin.iX );
+        str.WriteInt32L( aOrigin.iY );
+        str.WriteInt32L( aRegion.Count() );
+            
+        for (TInt i = 0; i < aRegion.Count(); ++i )
+            {
+            const TRect rect(aRegion[i]);
+            str.WriteInt32L(rect.iTl.iX);
+            str.WriteInt32L(rect.iTl.iY);
+            str.WriteInt32L(rect.iBr.iX);
+            str.WriteInt32L(rect.iBr.iY);
+            }
         }
-    
+    else
+        {
+        CAlfWindow::ReportOOM();
+        }
+        
     return data;
     }
 
@@ -629,6 +663,56 @@
     }
 
 // ---------------------------------------------------------------------------
+// SetScreenDeviceValid
+// ---------------------------------------------------------------------------
+//
+void CAlfWindow::SetScreenDeviceValid(TBool aValid)
+    {
+    if ( WsInfo().iNodeType != MWsWindowTreeNode::EWinTreeNodeClient )
+        {
+        // We intentionally omit other than client windows. Actually, we 
+		// we should get this valid information only for top level windows.
+		return;
+        }
+
+    if (!IsInsertedToScene())
+        {
+        iData->iScreenDeviceValid = aValid;
+        return;        
+        }
+        
+    TAlfWServInfo wservInfo = WsInfo();
+
+    TInt offset;
+    TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
+    if ( windowAttributes )
+        {
+        windowAttributes->iActive = aValid; 
+        windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
+        
+        TAlfBridgerData d;
+        d.Set(EAlfDSSetScreenDeviceValid, 
+            wservInfo.iRefId.iWindowGroupId, 
+            wservInfo.iRefId.iWindowIdentifer, 
+            (TAny*)offset); 
+
+        if (iData->iWindowManager->PostIt(d))
+            {
+            iData->iScreenDeviceValid = aValid;
+            }
+        }    
+    }
+
+// ---------------------------------------------------------------------------
+// IsScreenDeviceValid
+// ---------------------------------------------------------------------------
+//
+TBool CAlfWindow::IsScreenDeviceValid() const
+    {
+    return iData->iScreenDeviceValid;
+    }
+
+// ---------------------------------------------------------------------------
 // IsIncludedToVisibilityCalculation
 // ---------------------------------------------------------------------------
 //
@@ -707,6 +791,7 @@
     iData->iWindowArea = RRegion();
     iData->iTransparencyAlphaChannel = EFalse;
     iData->iIncludeToVisibilityCalculation = EFalse;
+    iData->iScreenDeviceValid = ETrue;
     
     SetSize(aSizeInPixels);
     }
@@ -891,6 +976,10 @@
             // ???
             }
         }
+    else
+        {
+        ReportOOM();
+        }
     
     }
 
@@ -924,6 +1013,10 @@
             // ???
             }
         }
+    else
+        {
+        CAlfWindow::ReportOOM();
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -955,6 +1048,10 @@
         {
         *attributes = empty;
         }
+    else
+        {
+        CAlfWindow::ReportOOM();
+        }
     return attributes;
     }
 
@@ -971,5 +1068,9 @@
         {
         *windowCommandBuffer = empty;
         }
+    else
+        {
+        CAlfWindow::ReportOOM();
+        }
     return windowCommandBuffer;
     }