Ejemplo n.º 1
0
        protected override TreeViewItem BuildRoot()
        {
            int idForhiddenRoot               = -1;
            int depthForHiddenRoot            = -1;
            FileAccessTreeViewItem root       = new FileAccessTreeViewItem(idForhiddenRoot, depthForHiddenRoot, "root", null);
            FileIOFrameSetup       frameSetup = m_ProfilerView.GetFrameSetup();
            int currentFrame = m_ProfilerView.GetSelectedFrame();

            if (!m_CaptureData.accessesSorted)
            {
                m_CaptureData.m_FileAccessData.Sort((data1, data2) => data1.startNs.CompareTo(data2.startNs));
                m_CaptureData.accessesSorted = true;
            }

            var data = m_CaptureData.m_FileAccessData;

            for (int index = 0, id = 0; index < data.Count; ++index)
            {
                var fileAccess = data[index];

                var filename = Path.GetFileName(fileAccess.filename);

                if (!m_ProfilerView.FilterContains(filename))
                {
                    continue;
                }

                if (frameSetup == FileIOFrameSetup.ThisFrame)
                {
                    if (currentFrame < fileAccess.firstFrameIndex || currentFrame > fileAccess.lastFrameIndex)
                    {
                        continue;
                    }
                }

                if (!m_ProfilerView.FilterActive())
                {
                    fileAccess.index = id;
                }

                var item = new FileAccessTreeViewItem(id, 0, fileAccess.filename, fileAccess);
                root.AddChild(item);
                id++;
            }

            // Return root of the tree
            return(root);
        }
Ejemplo n.º 2
0
        void CellGUI(Rect cellRect, FileAccessTreeViewItem item, FileIOColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);
            switch (column)
            {
            case FileIOColumns.Index:
                int id = item.fileAccessMarker.index > 0 ? item.fileAccessMarker.index + 1 : item.id + 1;
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", id)));
                break;

            case FileIOColumns.Timestamp:
            {
                var    ts   = TimeSpan.FromMilliseconds(item.fileAccessMarker.startTimeMs);
                string time = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D4}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                CellLabel(cellRect, item, new GUIContent(time, string.Format("{0}ms", item.fileAccessMarker.startTimeMs)));
                break;
            }

            case FileIOColumns.Duration:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0:f2}", item.fileAccessMarker.ms)));
                break;

            case FileIOColumns.Filename:
                CellLabel(cellRect, item, new GUIContent(item.fileAccessMarker.readableFileName, item.fileAccessMarker.readablePath));
                break;

            case FileIOColumns.ThreadName:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", item.fileAccessMarker.threadName)));
                break;

            case FileIOColumns.SizeBytes:
                if (item.fileAccessMarker.type == FileAccessType.Seek)
                {
                    CellLabel(cellRect, item, new GUIContent(string.Format("{0}", EditorUtility.FormatBytes((int)item.fileAccessMarker.newOffsetBytes)), string.Format("New offset: {0} B", item.fileAccessMarker.newOffsetBytes)));
                }
                else
                {
                    CellLabel(cellRect, item, new GUIContent(string.Format("{0}", EditorUtility.FormatBytes((int)item.fileAccessMarker.sizeBytes)), string.Format("{0} B", item.fileAccessMarker.sizeBytes)));
                }
                break;

            case FileIOColumns.OffsetBytes:
                if (item.fileAccessMarker.type == FileAccessType.Seek)
                {
                    CellLabel(cellRect, item, new GUIContent(string.Format("{0}", EditorUtility.FormatBytes((int)item.fileAccessMarker.originBytes)), string.Format("Seek origin: {0} B", item.fileAccessMarker.originBytes)));
                }
                else
                {
                    CellLabel(cellRect, item, new GUIContent(string.Format("{0}", EditorUtility.FormatBytes((int)item.fileAccessMarker.offsetBytes)), string.Format("{0} B", item.fileAccessMarker.offsetBytes)));
                }
                break;

            case FileIOColumns.Type:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", item.fileAccessMarker.type.ToString())));
                break;

            case FileIOColumns.FirstFrameIndex:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", item.fileAccessMarker.firstFrameIndex + 1)));     // Shift by one to match the indexing by the CPU view
                break;

            case FileIOColumns.Frames:
            {
                string label;
                if (m_ProfilerView.GetFrameSetup() == FileIOFrameSetup.ThisFrame)
                {
                    int selectedFrame          = m_ProfilerView.GetSelectedFrame(); // will the range of frames in the profiler window always match up with the item.fileAccessMarker.frameIndexes?
                    int framesSinceAccessStart = (selectedFrame - item.fileAccessMarker.firstFrameIndex) + 1;
                    label = $"{framesSinceAccessStart}/{item.fileAccessMarker.frameCount}";
                }
                else
                {
                    label = item.fileAccessMarker.frameCount.ToString();
                }

                CellLabel(cellRect, item, new GUIContent(label));
                break;
            }

            case FileIOColumns.Bandwidth:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", item.fileAccessMarker.averageBandwidthMBps)));
                break;
            }

            ShowContextMenu(cellRect, item.fileAccessMarker);
        }
Ejemplo n.º 3
0
 private void CellLabel(Rect cellRect, FileAccessTreeViewItem item, GUIContent content)
 {
     EditorGUI.LabelField(cellRect, content);
 }