void StoreSelectedState()
        {
            if (m_LocalSelectedItemMarkerIdPath == null)
            {
                m_LocalSelectedItemMarkerIdPath = new List <int>();
            }

            if (m_LocalSelectedItemMarkerIdPath.Count == 0 || m_Selected == null)
            {
                return;
            }

            if (m_FrameDataView == null || !m_FrameDataView.valid)
            {
                return;
            }
            var oldSelection = GetSelection();

            if (oldSelection.Count == 0)
            {
                return;
            }

            proxySelectionInfo = default;
            m_FrameDataView.GetItemMarkerIDPath(oldSelection[0], m_LocalSelectedItemMarkerIdPath);
        }
示例#2
0
        protected void OnNoProxyButtonActivated(object sender, EventArgs e)
        {
            if (this.noProxyButton.Active)
            {
                this.Selection = ProxySelection.NOPROXY;
            }

            this.OnChange(sender, e);
        }
示例#3
0
        protected void OnCustomProxyButtonActivated(object sender, EventArgs e)
        {
            if (this.customProxyButton.Active)
            {
                this.Selection = ProxySelection.CUSTOM;
            }

            this.OnChange(sender, e);
        }
示例#4
0
        protected void OnSystemProxyButtonActivated(object sender, EventArgs e)
        {
            if (this.systemProxyButton.Active)
            {
                this.Selection = ProxySelection.SYSTEM;
            }

            this.OnChange(sender, e);
        }
 public void SetSelection(ProfilerTimeSampleSelection selection, bool expandSelection)
 {
     m_Selected = selection;
     m_LocalSelectedItemMarkerIdPath.Clear();
     m_LocalSelectedItemMarkerIdPath.AddRange(selection.markerIdPath);
     m_ExpandDuringNextSelectionMigration = expandSelection;
     m_SelectionNeedsMigration            = true;
     proxySelectionInfo = default;
 }
 // setClearedSelection = false is only supposed to be used when a selection change was reported by the Tree View via SelectionChanged
 // if SetSelection(new List<int>()) would be triggered during SelectionChanged, the TreeViews selection state would get corrupted before it is even fully set.
 void ClearSelection(bool setClearedSelection)
 {
     m_Selected = null;
     m_LocalSelectedItemMarkerIdPath.Clear();
     m_ExpandDuringNextSelectionMigration = false;
     m_SelectionNeedsMigration            = false;
     proxySelectionInfo = default;
     if (setClearedSelection)
     {
         SetSelection(new List <int>());
     }
 }
        void MigrateSelectedState(bool expandIfNecessary, bool framingAllowed)
        {
            if (m_LocalSelectedItemMarkerIdPath == null || m_Selected == null || m_LocalSelectedItemMarkerIdPath.Count != m_Selected.markerNamePath.Count)
            {
                return;
            }

            m_SelectionNeedsMigration = false;

            var markerNamePath = m_Selected.markerNamePath;

            expandIfNecessary |= m_ExpandDuringNextSelectionMigration;

            using (k_MigrateSelectionStateMarker.Auto())
            {
                var safeFrameWithSafeMarkerIds = m_Selected.frameIndexIsSafe && m_FrameDataView.frameIndex == m_Selected.safeFrameIndex;
                var rawHierarchyView           = (m_FrameDataView.viewMode & HierarchyFrameDataView.ViewModes.MergeSamplesWithTheSameName) == HierarchyFrameDataView.ViewModes.Default;
                var allowProxySelection        = !safeFrameWithSafeMarkerIds;

                var finalRawSampleIndex = RawFrameDataView.invalidSampleIndex;

                using (var frameData = new RawFrameDataView(m_FrameDataView.frameIndex, m_FrameDataView.threadIndex))
                {
                    if (!frameData.valid)
                    {
                        return;
                    }
                    if (!safeFrameWithSafeMarkerIds)
                    {
                        // marker names might have changed Ids between frames, update them if that is the case
                        for (int i = 0; i < m_LocalSelectedItemMarkerIdPath.Count; i++)
                        {
                            m_LocalSelectedItemMarkerIdPath[i] = frameData.GetMarkerId(markerNamePath[i]);
                        }
                    }
                    else if (!allowProxySelection)
                    {
                        for (int i = 0; i < m_LocalSelectedItemMarkerIdPath.Count; i++)
                        {
                            var markerIsEditorOnlyMarker = frameData.GetMarkerFlags(m_LocalSelectedItemMarkerIdPath[i]).HasFlag(Unity.Profiling.LowLevel.MarkerFlags.AvailabilityEditor);
                            if (markerIsEditorOnlyMarker && i < m_LocalSelectedItemMarkerIdPath.Count - 1)
                            {
                                // Technically, proxy selections are not supposed to be allowed when switching between views in the same frame.
                                // However, if there are Editor Only markers in the path that are NOT the last item, Hierarchy View might have collapsed the path from this point forward,
                                // so we need to allow Proxy Selections here.
                                allowProxySelection = true;
                                break;
                            }
                        }
                    }
                    var name = m_Selected.sampleDisplayName;
                    m_CachedDeepestRawSampleIndexPath.Clear();
                    if (m_CachedDeepestRawSampleIndexPath.Capacity < markerNamePath.Count)
                    {
                        m_CachedDeepestRawSampleIndexPath.Capacity = markerNamePath.Count;
                    }

                    if (allowProxySelection || rawHierarchyView)
                    {
                        finalRawSampleIndex = ProfilerTimelineGUI.FindFirstSampleThroughMarkerPath(
                            frameData, m_ProfilerSampleNameProvider,
                            m_LocalSelectedItemMarkerIdPath, markerNamePath.Count, ref name,
                            longestMatchingPath: m_CachedDeepestRawSampleIndexPath);
                    }
                    else
                    {
                        finalRawSampleIndex = ProfilerTimelineGUI.FindNextSampleThroughMarkerPath(
                            frameData, m_ProfilerSampleNameProvider,
                            m_LocalSelectedItemMarkerIdPath, markerNamePath.Count, ref name,
                            ref m_CachedDeepestRawSampleIndexPath);
                    }
                }
                var  newSelectedId = m_FrameDataView.GetRootItemID();
                bool selectedItemsPathIsExpanded = true;
                var  proxySelection = new ProxySelection();
                proxySelectionInfo = default;
                var deepestPath = m_CachedDeepestRawSampleIndexPath.Count;

                if (finalRawSampleIndex >= 0 || allowProxySelection && deepestPath > 0)
                {
                    // if a valid raw index was found, find the corresponding HierarchyView Sample id next:
                    newSelectedId = GetItemIdFromRawFrameDataIndexPath(m_FrameDataView, m_CachedDeepestRawSampleIndexPath, out deepestPath, out selectedItemsPathIsExpanded);
                    if (m_LocalSelectedItemMarkerIdPath.Count > deepestPath && newSelectedId >= 0)
                    {
                        proxySelection.hasProxySelection            = true;
                        proxySelection.nonProxyName                 = m_Selected.sampleDisplayName;
                        proxySelection.nonProxySampleStack          = m_Selected.markerNamePath;
                        proxySelection.pathLengthDifferenceForProxy = deepestPath - m_LocalSelectedItemMarkerIdPath.Count;
                    }
                }

                var newSelection = (newSelectedId == 0) ? new List <int>() : new List <int>()
                {
                    newSelectedId
                };
                state.selectedIDs = newSelection;

                // Framing invalidates expanded state and this is very expensive operation to perform each frame.
                // Thus we auto frame selection only when we are not currently receiving profiler data from the Editor we are profiling, or the user opted into a "Live" view of the data
                if (newSelectedId != 0 && isInitialized && framingAllowed && (selectedItemsPathIsExpanded || expandIfNecessary))
                {
                    FrameItem(newSelectedId);
                }
                m_ExpandDuringNextSelectionMigration = false;

                proxySelectionInfo = proxySelection;
            }
        }
示例#8
0
        protected void OnSystemProxyButtonActivated(object sender, EventArgs e) {
            if (this.systemProxyButton.Active) {
                this.Selection = ProxySelection.SYSTEM;
            }

            this.OnChange(sender, e);
        }
示例#9
0
        protected void OnNoProxyButtonActivated(object sender, EventArgs e) {
            if (this.noProxyButton.Active) {
                this.Selection = ProxySelection.NOPROXY;
            }

            this.OnChange(sender, e);
        }
示例#10
0
        protected void OnCustomProxyButtonActivated(object sender, EventArgs e) {
            if (this.customProxyButton.Active) {
                this.Selection = ProxySelection.CUSTOM;
            }

            this.OnChange(sender, e);
        }