26 #include "alfwindowdata.h" |
26 #include "alfwindowdata.h" |
27 |
27 |
28 #include <string.h> |
28 #include <string.h> |
29 #include <s32mem.h> |
29 #include <s32mem.h> |
30 |
30 |
|
31 #ifdef ALF_MEMORYLOGGING |
|
32 #include <hal.h> |
|
33 #endif |
|
34 |
31 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
32 // NewL |
36 // NewL |
33 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
34 // |
38 // |
35 CAlfWindow* CAlfWindow::NewL(TUint aId, CAlfWindowManager& aOwner, const TSize& aSizeInPixels) |
39 CAlfWindow* CAlfWindow::NewL(TUint aId, CAlfWindowManager& aOwner, const TSize& aSizeInPixels) |
57 iData->iWindowArea.Close(); |
61 iData->iWindowArea.Close(); |
58 |
62 |
59 delete iData; |
63 delete iData; |
60 } |
64 } |
61 } |
65 } |
62 |
66 |
|
67 void CAlfWindow::ReportOOM() |
|
68 { |
|
69 #ifdef ALF_MEMORYLOGGING |
|
70 RDebug::Printf("CAlfWindow::ReportOOM"); |
|
71 TInt totalSpaceAllocated = 0; |
|
72 TInt cellAllocatedInHeap = User::AllocSize(totalSpaceAllocated); |
|
73 TInt largestFreeBlock = 0; |
|
74 TInt totalFreeSpaceInHeap = User::Available(largestFreeBlock); |
|
75 TInt freeRAM = 0; |
|
76 if ( HAL::Get( HALData::EMemoryRAMFree, freeRAM ) != KErrNone ) |
|
77 { |
|
78 freeRAM = -1; |
|
79 } |
|
80 |
|
81 RDebug::Printf("CAlfWindow::ReportOOM - Allocated space: %d, Amount of allocated cells: %d, Largest free block: %d, Free space in heap: %d", |
|
82 totalSpaceAllocated, |
|
83 cellAllocatedInHeap, |
|
84 largestFreeBlock, |
|
85 totalFreeSpaceInHeap); |
|
86 RDebug::Printf("CAlfWindow::ReportOOM - Free RAM in system: %d", freeRAM); |
|
87 #endif |
|
88 } |
|
89 |
63 // --------------------------------------------------------------------------- |
90 // --------------------------------------------------------------------------- |
64 // WsInfo |
91 // WsInfo |
65 // --------------------------------------------------------------------------- |
92 // --------------------------------------------------------------------------- |
66 // |
93 // |
67 EXPORT_C const TAlfWServInfo& CAlfWindow::WsInfo() const |
94 EXPORT_C const TAlfWServInfo& CAlfWindow::WsInfo() const |
505 TInt& aOffset, TInt aScreenNumber, const TPoint& aOrigin, const TRegion& aRegion) |
532 TInt& aOffset, TInt aScreenNumber, const TPoint& aOrigin, const TRegion& aRegion) |
506 { |
533 { |
507 const TInt size = ( 4*aRegion.Count() + 4 ) * sizeof(TInt32); |
534 const TInt size = ( 4*aRegion.Count() + 4 ) * sizeof(TInt32); |
508 TAny* data = (TAny*)iData->iWindowManager->Bridge()->AppendVarDataL( size, aOffset ); |
535 TAny* data = (TAny*)iData->iWindowManager->Bridge()->AppendVarDataL( size, aOffset ); |
509 |
536 |
510 RMemWriteStream str( data, size ); |
537 if (data) |
511 str.WriteInt32L( aScreenNumber ); |
538 { |
512 str.WriteInt32L( aOrigin.iX ); |
539 RMemWriteStream str( data, size ); |
513 str.WriteInt32L( aOrigin.iY ); |
540 str.WriteInt32L( aScreenNumber ); |
514 str.WriteInt32L( aRegion.Count() ); |
541 str.WriteInt32L( aOrigin.iX ); |
515 |
542 str.WriteInt32L( aOrigin.iY ); |
516 for (TInt i = 0; i < aRegion.Count(); ++i ) |
543 str.WriteInt32L( aRegion.Count() ); |
517 { |
544 |
518 const TRect rect(aRegion[i]); |
545 for (TInt i = 0; i < aRegion.Count(); ++i ) |
519 str.WriteInt32L(rect.iTl.iX); |
546 { |
520 str.WriteInt32L(rect.iTl.iY); |
547 const TRect rect(aRegion[i]); |
521 str.WriteInt32L(rect.iBr.iX); |
548 str.WriteInt32L(rect.iTl.iX); |
522 str.WriteInt32L(rect.iBr.iY); |
549 str.WriteInt32L(rect.iTl.iY); |
523 } |
550 str.WriteInt32L(rect.iBr.iX); |
524 |
551 str.WriteInt32L(rect.iBr.iY); |
|
552 } |
|
553 } |
|
554 else |
|
555 { |
|
556 CAlfWindow::ReportOOM(); |
|
557 } |
|
558 |
525 return data; |
559 return data; |
526 } |
560 } |
527 |
561 |
528 // --------------------------------------------------------------------------- |
562 // --------------------------------------------------------------------------- |
529 // SetWindowArea |
563 // SetWindowArea |
624 // --------------------------------------------------------------------------- |
658 // --------------------------------------------------------------------------- |
625 // |
659 // |
626 TBool CAlfWindow::TransparencyAlphaChannel() const |
660 TBool CAlfWindow::TransparencyAlphaChannel() const |
627 { |
661 { |
628 return iData->iTransparencyAlphaChannel; |
662 return iData->iTransparencyAlphaChannel; |
|
663 } |
|
664 |
|
665 // --------------------------------------------------------------------------- |
|
666 // SetScreenDeviceValid |
|
667 // --------------------------------------------------------------------------- |
|
668 // |
|
669 void CAlfWindow::SetScreenDeviceValid(TBool aValid) |
|
670 { |
|
671 if ( WsInfo().iNodeType != MWsWindowTreeNode::EWinTreeNodeClient ) |
|
672 { |
|
673 // We intentionally omit other than client windows. Actually, we |
|
674 // we should get this valid information only for top level windows. |
|
675 return; |
|
676 } |
|
677 |
|
678 if (!IsInsertedToScene()) |
|
679 { |
|
680 iData->iScreenDeviceValid = aValid; |
|
681 return; |
|
682 } |
|
683 |
|
684 TAlfWServInfo wservInfo = WsInfo(); |
|
685 |
|
686 TInt offset; |
|
687 TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset); |
|
688 if ( windowAttributes ) |
|
689 { |
|
690 windowAttributes->iActive = aValid; |
|
691 windowAttributes->iScreenNumber = wservInfo.iScreenNumber; |
|
692 |
|
693 TAlfBridgerData d; |
|
694 d.Set(EAlfDSSetScreenDeviceValid, |
|
695 wservInfo.iRefId.iWindowGroupId, |
|
696 wservInfo.iRefId.iWindowIdentifer, |
|
697 (TAny*)offset); |
|
698 |
|
699 if (iData->iWindowManager->PostIt(d)) |
|
700 { |
|
701 iData->iScreenDeviceValid = aValid; |
|
702 } |
|
703 } |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // IsScreenDeviceValid |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 TBool CAlfWindow::IsScreenDeviceValid() const |
|
711 { |
|
712 return iData->iScreenDeviceValid; |
629 } |
713 } |
630 |
714 |
631 // --------------------------------------------------------------------------- |
715 // --------------------------------------------------------------------------- |
632 // IsIncludedToVisibilityCalculation |
716 // IsIncludedToVisibilityCalculation |
633 // --------------------------------------------------------------------------- |
717 // --------------------------------------------------------------------------- |
705 iData->iIsActive = EFalse; |
789 iData->iIsActive = EFalse; |
706 iData->iOpacity = 1.0f; |
790 iData->iOpacity = 1.0f; |
707 iData->iWindowArea = RRegion(); |
791 iData->iWindowArea = RRegion(); |
708 iData->iTransparencyAlphaChannel = EFalse; |
792 iData->iTransparencyAlphaChannel = EFalse; |
709 iData->iIncludeToVisibilityCalculation = EFalse; |
793 iData->iIncludeToVisibilityCalculation = EFalse; |
|
794 iData->iScreenDeviceValid = ETrue; |
710 |
795 |
711 SetSize(aSizeInPixels); |
796 SetSize(aSizeInPixels); |
712 } |
797 } |
713 |
798 |
714 // --------------------------------------------------------------------------- |
799 // --------------------------------------------------------------------------- |
969 TRAP_IGNORE(windowCommandBuffer = (TAlfWindowCommandBufferAttributes*)iData->iWindowManager->Bridge()->AppendVarDataL( sizeof(TAlfWindowCommandBufferAttributes), aIndex )) |
1066 TRAP_IGNORE(windowCommandBuffer = (TAlfWindowCommandBufferAttributes*)iData->iWindowManager->Bridge()->AppendVarDataL( sizeof(TAlfWindowCommandBufferAttributes), aIndex )) |
970 if ( windowCommandBuffer ) |
1067 if ( windowCommandBuffer ) |
971 { |
1068 { |
972 *windowCommandBuffer = empty; |
1069 *windowCommandBuffer = empty; |
973 } |
1070 } |
|
1071 else |
|
1072 { |
|
1073 CAlfWindow::ReportOOM(); |
|
1074 } |
974 return windowCommandBuffer; |
1075 return windowCommandBuffer; |
975 } |
1076 } |