public virtual HeapCell CellByAddress(uint aAddress, out int aIndex)
        {
            HeapCell ret = null;

            aIndex = -1;
            //
            int i = 0;

            foreach (HeapCell cell in this)
            {
                HeapCell.TRegion region = cell.RegionForAddress(aAddress);
                //
                if (region == HeapCell.TRegion.EHeader || region == HeapCell.TRegion.EPayload)
                {
                    aIndex = i;
                    ret    = cell;
                    break;
                }
                else
                {
                    i++;
                }
            }
            //
            return(ret);
        }
Пример #2
0
        private void Navigator_NavNewColumn(HeapCell aCell, HeapCellMetaData aMetaData, uint aAddress, Point aPixelPos, Point aBoxPos, Size aDimensions, Size aBoxSize, Size aPadding)
        {
            System.Diagnostics.Debug.Assert(iCell != null && iCell.Address == aCell.Address);

            // Indicate that we're processing a new box
            ++CellBoxIndex;
            iAddress = aAddress;

            // Set our box coordinates
            iBoxCoordinates = aBoxPos;

            // Get current raw item if we're in the payload section
            iRawItem = null;
            try
            {
                HeapCell.TRegion region = Region;
                if (region == HeapCell.TRegion.EPayload)
                {
                    iRawItem = iCell[aAddress];
                }
            }
            catch (ArgumentException)
            {
            }


            // Some up front calculations that we'll need below...
            RemainingBytes = aCell.Remainder(aAddress);
            int remainingBoxesForThisLine = (aDimensions.Width - BoxCoordinates.X);

            RemainingBoxes             = (int)(RemainingBytes / SymbianUtils.RawItems.RawItem.KSizeOfOneRawItemInBytes);
            RemainingBoxesAfterThisRow = Math.Max(0, RemainingBoxes - remainingBoxesForThisLine);

            // If we can render all the remaining boxes in the not-yet-drawn
            // boxes from this row, we don't need anymore rows.
            RemainingRows = 0;
            if (RemainingBoxesAfterThisRow > 0)
            {
                // Otherwise, we need to identify how many more rows we will need
                // in order to complete the remaining boxes that are left over
                // after this row's boxes.
                RemainingRows = (RemainingBoxesAfterThisRow / aDimensions.Width) + 1;
            }

            // Work out the borders that should be enabled for the cell
            CalculateBorders(aCell, aAddress, aDimensions);
        }
        private void LocateMatch(HeapCell aCell, RawItem aItem, uint aHeaderOffset)
        {
            RelationshipManager linkManager = aCell.RelationshipManager;

            // Now check if this address exactly matches a heap cell
            if (iStats.WithinHeapBounds(aItem.Data))
            {
                // The address of another object within the heap
                // is always the address of the object within the payload
                // section of a heap cell. Therefore in order to find the
                // corresponding heap cell address, we must subtract the
                // heap cell header length from the starting address.
                //
                // In other words, the rawItem.Data value points to a payload address.
                // However, our cell search function (CellByExactAddress) works in
                // terms of a heap cell address. The heap cell includes [header + payload].
                //
                // In order to convert the object address into a heap cell address,
                // we must subtract the allocated heap cell header size from the
                // raw address.
                uint exactMatchAddress = aItem.Data - aHeaderOffset;

                HeapCell cell = iEntries.CellByExactAddress(exactMatchAddress);
                if (cell != null && cell.Address != aCell.Address)
                {
                    linkManager.AddEmbeddedReferenceTo(aItem, cell);
                }
                else if (cell == null)
                {
                    uint partialMatchAddress = aItem.Data;

                    // Didn't find an exact match, but we might find that this address
                    // points to part way through another heap cell.
                    cell = Lookup(partialMatchAddress);
                    if (cell != null && cell.Address != aCell.Address)
                    {
                        // It also has to point to the payload
                        HeapCell.TRegion region = cell.RegionForAddress(partialMatchAddress);
                        if (region == HeapCell.TRegion.EPayload)
                        {
                            linkManager.AddEmbeddedReferenceTo(aItem, cell);
                        }
                    }
                }
            }
        }
Пример #4
0
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // Get the cell colour that is associated with the cell symbol object type
            aMetaData.CellBoxColor = ColourForHeapCell(aCell);

            // Draw actual cell
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);
            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }

            // If first box, we show the number of inwards links to the cell
            HeapCell.TRegion region = aMetaData.Region;
            if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0)
            {
                boxRect.Inflate(KShrinkSize, KShrinkSize);

                // Draw the fill
                Color lightenColor = ColourUtils.LightenMore(aMetaData.CellBoxColor);
                using (SolidBrush brush = new SolidBrush(lightenColor))
                {
                    aGraphics.FillRectangle(brush, boxRect.Rectangle);
                }
                lightenColor = ColourUtils.Lighten(lightenColor);
                using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                {
                    aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);
                }

                // Draw the count
                int count = aCell.RelationshipManager.ReferencedBy.Count;
                if (count == 0)
                {
                    PaintBoxedText(count.ToString(), aGraphics, Color.Red, boxRect);
                }
                else
                {
                    PaintBoxedTextWithLuminanceHandling(count.ToString(), aGraphics, Color.Black, boxRect);
                }
            }
        }
        public void PaintContentBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);
            aGraphics.DrawRectangle(Pens.Black, boxRect.Rectangle);

            // If we're drawing the header, we can decorate the header with an
            // additional line.
            HeapCell.TRegion region = aCell.RegionForAddress(aAddress);
            if (region == HeapCell.TRegion.EHeader)
            {
                Point linePosStart = boxRect.TopLeft;
                linePosStart.X += KHeaderBoxLineCornerOffset;
                Point linePosEnd = boxRect.TopLeft;
                linePosEnd.Y += KHeaderBoxLineCornerOffset;
                //
                aGraphics.DrawLine(Pens.Black, linePosStart, linePosEnd);
            }
        }
        public RawItem RawItemByPixelPos(Point aPixelPos)
        {
            RawItem ret = null;
            //
            Point    boxPos = CoordinateToBox(aPixelPos);
            HeapCell cell   = CellByBoxCoordinates(boxPos);

            //
            if (cell != null)
            {
                uint             rawItemAddress = AddressByBoxCoordinates(boxPos);
                HeapCell.TRegion region         = cell.RegionForAddress(rawItemAddress);

                // We only provide raw items for payload sections
                if (region == HeapCell.TRegion.EPayload)
                {
                    ret = cell[rawItemAddress];
                }
            }
            //
            return(ret);
        }
Пример #7
0
        public static Color CellFillColourByRegion(HeapCell aCell, uint aAddress, out HeapCell.TRegion aRegion)
        {
            // Cell coloring
            aRegion = aCell.RegionForAddress(aAddress);

            Color fillColour = Color.White;

            switch (aRegion)
            {
            case HeapCell.TRegion.EHeader:
                fillColour = Color.GhostWhite;
                break;

            case HeapCell.TRegion.EPayload:
                fillColour = ColourByCellType(aCell);
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            return(fillColour);
        }
Пример #8
0
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // Get the cell colour that is associated with the cell symbol object type
            aMetaData.CellBoxColor = ColourForHeapCell(aCell);
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);

            // Draw actual cell
            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }

            HeapCell.TRegion region = aMetaData.Region;
            if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0)
            {
                // If first box, we show the number of inwards links to the cell
                boxRect.Inflate(KShrinkSize, KShrinkSize);

                // Draw the fill
                Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor);
                using (SolidBrush brush = new SolidBrush(lightenColor))
                {
                    aGraphics.FillRectangle(brush, boxRect.Rectangle);
                }
                lightenColor = ColourUtils.Lighten(lightenColor);
                using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                {
                    aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);
                }

                // Draw the count
                PaintBoxedTextWithLuminanceHandling(aCell.RelationshipManager.EmbeddedReferencesTo.Count.ToString(), aGraphics, Color.Black, boxRect);
            }
            else
            {
                // If we're in the payload section, then get the raw item corresponding to the address we are drawing
                RawItem rawItem = aMetaData.RawItem;
                if (rawItem != null && rawItem.Tag != null && rawItem.Tag is HeapLib.Relationships.RelationshipInfo)
                {
                    RelationshipInfo relInfo = (RelationshipInfo)rawItem.Tag;

                    // Make the box a bit smaller
                    boxRect.Inflate(KShrinkSize, KShrinkSize);

                    // Draw the fill
                    Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor);
                    using (SolidBrush brush = new SolidBrush(lightenColor))
                    {
                        aGraphics.FillRectangle(brush, boxRect.Rectangle);
                    }
                    lightenColor = ColourUtils.Lighten(lightenColor);
                    using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                    {
                        aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);

                        // If it's a clean reference, then draw a diagonal line to decorate the box reference
                        if (relInfo.IsCleanLink)
                        {
                            Point linePosStart = boxRect.TopLeft;
                            linePosStart.X += KHeaderBoxLineCornerOffset;
                            Point linePosEnd = boxRect.TopLeft;
                            linePosEnd.Y += KHeaderBoxLineCornerOffset;
                            //
                            aGraphics.DrawLine(borderPen, linePosStart, linePosEnd);
                        }
                    }
                }
            }
        }
 public HeapViewGridCell(HeapCell aHeapCell, object aCaption, HeapCell.TRegion aRegion)
 {
     HeapCell = aHeapCell;
     Caption  = aCaption;
     Region   = aRegion;
 }
Пример #10
0
        public static Color RampedCellFillColourByRegion(HeapCell aCell, int aCellBoxCount, uint aAddress, out HeapCell.TRegion aRegion)
        {
            // Get the cell colour to use and also the region associated with
            // the cell address.
            Color fillColour = CellFillColourByRegion(aCell, aAddress, out aRegion);

            // If we're rendering the payload we'll want to ramp the cell colour
            // to make it easier to read.
            if (aRegion == HeapCell.TRegion.EPayload)
            {
                fillColour = RampedColourByBoxNumber(fillColour, aCellBoxCount, aCell.Address, aAddress);
            }

            return(fillColour);
        }