public void SetData(ProfileDataView dataView, int depthFilter, List <string> nameFilters, List <string> nameExcludes, TimingOptions.TimingOption timingOption, int threadSelectionCount) { m_RequestedRangeSettings = new RangeSettings(dataView, depthFilter, nameFilters, nameExcludes, timingOption, threadSelectionCount); if (m_CurrentSettings.rangeSettings != m_RequestedRangeSettings) { m_TimeRangeDirty = true; } }
public RangeSettings(ProfileDataView dataView, int depthFilter, List <string> nameFilters, List <string> nameExcludes, TimingOptions.TimingOption timingOption, int threadSelectionCount) { // Make a copy rather than keeping a reference this.dataView = dataView == null ? new ProfileDataView() : new ProfileDataView(dataView); this.depthFilter = depthFilter; this.nameFilters = nameFilters; this.nameExcludes = nameExcludes; this.timingOption = timingOption; this.threadSelectionCount = threadSelectionCount; }
static public ProfileAnalyzerExportWindow Open(float screenX, float screenY, ProfileDataView profileSingleView, ProfileDataView profileLeftView, ProfileDataView profileRightView) { ProfileAnalyzerExportWindow window = GetWindow <ProfileAnalyzerExportWindow>("Export"); window.minSize = new Vector2(200, 140); window.position = new Rect(screenX, screenY, 200, 140); window.SetData(profileSingleView, profileLeftView, profileRightView); window.Show(); return(window); }
public ProfileTable(TreeViewState state, MultiColumnHeader multicolumnHeader, ProfileDataView dataView, ProfileAnalyzerWindow profileAnalyzerWindow, Draw2D draw2D, Color barColor) : base(state, multicolumnHeader) { m_2D = draw2D; m_DataView = dataView; m_ProfileAnalyzerWindow = profileAnalyzerWindow; m_BarColor = barColor; m_MaxColumns = Enum.GetValues(typeof(MyColumns)).Length; Assert.AreEqual(m_SortOptions.Length, m_MaxColumns, "Ensure number of sort options are in sync with number of MyColumns enum values"); // Custom setup rowHeight = kRowHeights; showAlternatingRowBackgrounds = true; showBorder = true; customFoldoutYOffset = (kRowHeights - EditorGUIUtility.singleLineHeight) * 0.5f; // center foldout in the row since we also center content. See RowGUI // extraSpaceBeforeIconAndLabel = 0; multicolumnHeader.sortingChanged += OnSortingChanged; multicolumnHeader.visibleColumnsChanged += OnVisibleColumnsChanged; Reload(); }
bool UpdateAutoDepthFilter(ProfileDataView profileLeftView, ProfileDataView profileRightView) { if (m_DepthFilterAuto) { var newDepthFilter1 = m_DepthFilter1; var newDepthFilter2 = m_DepthFilter2; ClampDepthFilterForAutoRespectingDiff(ref newDepthFilter1, ref newDepthFilter2, profileLeftView, profileRightView); if (m_DepthFilter1 != newDepthFilter1) { m_DepthFilter1 = newDepthFilter1; return(true); } if (m_DepthFilter2 != newDepthFilter2) { m_DepthFilter2 = newDepthFilter2; return(true); } } return(false); }
public void SetData(ProfileDataView profileDataView, ProfileDataView leftDataView, ProfileDataView rightDataView) { m_ProfileDataView = profileDataView; m_LeftDataView = leftDataView; m_RightDataView = rightDataView; }
public int Draw(MarkerData marker, ProfileDataView markerContext, int topNumber, string[] topStrings, int[] topValues) { GUIStyle style = GUI.skin.label; float w = m_WidthColumn0; float h = style.lineHeight; float ySpacing = 2; float barHeight = h - ySpacing; EditorGUILayout.BeginVertical(GUILayout.Width(w + m_WidthColumn1 + m_WidthColumn2 + m_WidthColumn3)); topNumber = DrawTopNumber(topNumber, topStrings, topValues); /* * EditorGUILayout.BeginHorizontal(); * EditorGUILayout.LabelField("", GUILayout.Width(w)); * EditorGUILayout.LabelField("Value", GUILayout.Width(LayoutSize.WidthColumn1)); * EditorGUILayout.LabelField("Frame", GUILayout.Width(LayoutSize.WidthColumn2)); * EditorGUILayout.EndHorizontal(); */ // var frameSummary = m_ProfileSingleView.analysis.GetFrameSummary(); float barMax = marker.msMax; // frameSummary.msMax if (m_Units.Units == Units.Count) { barMax = marker.countMax; } // Marker frames are ordered by frame time // If we are sorting by count then we need to apply a sort bool showCount = m_Units.Units == Units.Count; List <FrameTime> frames = GetTopN(marker, topNumber, showCount); foreach (FrameTime frameTime in frames) { float barValue = (m_Units.Units == Units.Count) ? frameTime.count : frameTime.ms; float barLength = Math.Min((w * barValue) / barMax, w); EditorGUILayout.BeginHorizontal(); if (m_2D.DrawStart(w, h, Draw2D.Origin.TopLeft, style)) { m_2D.DrawFilledBox(0, ySpacing, barLength, barHeight, colorBar); m_2D.DrawFilledBox(barLength, ySpacing, w - barLength, barHeight, colorBarBackground); m_2D.DrawEnd(); Rect rect = GUILayoutUtility.GetLastRect(); GUI.Label(rect, new GUIContent("", m_Units.ToTooltipString(barValue, true))); } EditorGUILayout.LabelField(m_Units.ToGUIContentWithTooltips(barValue, true), GUILayout.Width(m_WidthColumn2)); if (m_DrawFrameIndexButton != null) { m_DrawFrameIndexButton(frameTime.frameIndex, markerContext); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } // Show blank space for missing frames var content = new GUIContent("", ""); Vector2 size = GUI.skin.button.CalcSize(content); h = Math.Max(barHeight, size.y); for (int i = frames.Count; i < topNumber; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Height(h)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); return(topNumber); }
internal bool UpdateDepthForCompareSync(ProfileAnalysis leftAnalysis, ProfileAnalysis rightAnalysis, List <MarkerPairing> pairings, ProfileDataView profileLeftView, ProfileDataView profileRightView) { int originalDepthDiff = mostCommonDepthDiff; int newDepthDiff = CalculateDepthDifference(leftAnalysis, rightAnalysis, pairings); if (newDepthDiff != originalDepthDiff) { UpdateAutoDepthFilter(profileLeftView, profileRightView); return(true); } return(false); }
internal bool UpdateDepthFilters(bool singleView, ProfileDataView profileSingleView, ProfileDataView profileLeftView, ProfileDataView profileRightView) { bool changed = false; if (!singleView) { // First respect the auto flag if (UpdateAutoDepthFilter(profileLeftView, profileRightView)) { changed = true; } // Make sure Single matches the updated comparison view if (profileLeftView.path == profileSingleView.path) { // Use same filter on single view if its the same file if (m_DepthFilter != m_DepthFilter1) { m_DepthFilter = m_DepthFilter1; changed = true; } } if (profileRightView.path == profileSingleView.path) { // Use same filter on single view if its the same file if (m_DepthFilter != m_DepthFilter2) { m_DepthFilter = m_DepthFilter2; changed = true; } } } else { // Make sure comparisons match updated single view if (profileLeftView.path == profileSingleView.path) { // Use same filter on comparison left view if its the same file if (m_DepthFilter1 != m_DepthFilter) { m_DepthFilter1 = m_DepthFilter; changed = true; } if (m_DepthFilterAuto) { var newDepthFilter2 = m_DepthFilter; ClampDepthFilterForAutoRespectingDiff(ref m_DepthFilter1, ref newDepthFilter2, profileLeftView, profileRightView); if (m_DepthFilter2 != newDepthFilter2) { m_DepthFilter2 = newDepthFilter2; changed = true; } if (UpdateAutoDepthFilter(profileLeftView, profileRightView)) { changed = true; } } if (UpdateAutoDepthFilter(profileLeftView, profileRightView)) { changed = true; } } if (profileRightView.path == profileSingleView.path) { // Use same filter on comparison right view if its the same file if (m_DepthFilter2 != m_DepthFilter) { m_DepthFilter2 = m_DepthFilter; changed = true; } if (m_DepthFilterAuto) { var newDepthFilter1 = m_DepthFilter; ClampDepthFilterForAutoRespectingDiff(ref newDepthFilter1, ref m_DepthFilter2, profileLeftView, profileRightView); if (m_DepthFilter1 != newDepthFilter1) { m_DepthFilter1 = newDepthFilter1; changed = true; } if (UpdateAutoDepthFilter(profileLeftView, profileRightView)) { changed = true; } } } } return(changed); }
internal void DrawDepthFilter(bool isAnalysisRunning, bool singleView, ProfileDataView profileSingleView, ProfileDataView profileLeftView, ProfileDataView profileRightView) { #if !UNITY_2019_1_OR_NEWER bool triggerRefresh = false; if (!isAnalysisRunning) { if (singleView) { var maxDepth = profileSingleView.GetMaxDepth(); if (m_DepthStrings == null || maxDepth != m_OldDepthRaw1) { SetDepthStringsSingle(maxDepth, out m_DepthStrings, out m_DepthValues); m_OldDepthRaw1 = maxDepth; triggerRefresh = true; } } else { if (m_DepthFilterAuto) { var maxLeftRaw = profileLeftView.GetMaxDepth(); var maxRightRaw = profileRightView.GetMaxDepth(); if (m_DepthStringsAuto == null || m_OldDepthRaw1 != maxLeftRaw || m_OldDepthRaw2 != maxRightRaw) { SetDepthStringsCompare(maxLeftRaw, out m_DepthStringsAuto, out m_DepthValuesAuto, maxRightRaw); m_OldDepthRaw1 = maxLeftRaw; m_OldDepthRaw2 = maxRightRaw; triggerRefresh = true; } } else { var maxDepthLeft = profileLeftView.GetMaxDepth(); if (m_DepthStrings1 == null || m_OldDepthRaw1 != maxDepthLeft) { SetDepthStringsSingle(maxDepthLeft, out m_DepthStrings1, out m_DepthValues1); m_OldDepthRaw1 = maxDepthLeft; triggerRefresh = true; } var maxDepthRight = profileRightView.GetMaxDepth(); if (m_DepthStrings2 == null || m_OldDepthRaw2 != maxDepthRight) { SetDepthStringsSingle(maxDepthRight, out m_DepthStrings2, out m_DepthValues2); m_OldDepthRaw2 = maxDepthRight; triggerRefresh = true; } } } } #endif bool lastEnabled = GUI.enabled; bool enabled = !isAnalysisRunning; EditorGUILayout.BeginHorizontal(); if (singleView) { EditorGUILayout.LabelField(ProfileAnalyzerWindow.Styles.depthTitle, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsLeftLabelWidth)); #if UNITY_2019_1_OR_NEWER DrawDepthFilterDropdown(null, enabled, profileSingleView, (primary, left, right) => m_DepthFilter = primary, ViewType.Single, profileSingleView, profileLeftView, profileRightView); #else if (m_DepthStrings != null) { var lastDepthFilter = m_DepthFilter; m_DepthFilter = m_DepthFilter == ProfileAnalyzer.kDepthAll ? ProfileAnalyzer.kDepthAll : profileSingleView.ClampToValidDepthValue(m_DepthFilter); GUI.enabled = enabled; m_DepthFilter = EditorGUILayout.IntPopup(m_DepthFilter, m_DepthStrings, m_DepthValues, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); GUI.enabled = lastEnabled; if (m_DepthFilter != lastDepthFilter) { triggerRefresh = true; } } #endif } else { EditorGUILayout.LabelField(ProfileAnalyzerWindow.Styles.depthTitle, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsLeftLabelWidth)); if (m_DepthFilterAuto) { #if UNITY_2019_1_OR_NEWER DrawDepthFilterDropdown(null, enabled, profileLeftView, (primary, left, right) => { m_DepthFilter1 = left; m_DepthFilter2 = right; ClampDepthFilterForAutoRespectingDiff(ref m_DepthFilter1, ref m_DepthFilter2, profileLeftView, profileRightView); }, ViewType.Locked, profileSingleView, profileLeftView, profileRightView); #else if (m_DepthStringsAuto != null) { var leftMax = profileLeftView.GetMaxDepth(); var rightMax = profileRightView.GetMaxDepth(); var lastDepthFilterDropdownIndex = CalcSliceMenuEntryIndex(m_DepthFilter1, m_DepthFilter2, leftMax, rightMax); ClampDepthFilterForAutoRespectingDiff(ref m_DepthFilter1, ref m_DepthFilter2, profileLeftView, profileRightView); var layoutOptionWidth = ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth; if (m_DepthFilter1 != m_DepthFilter2) { layoutOptionWidth = ProfileAnalyzerWindow.LayoutSize.FilterOptionsLockedEnumWidth; } GUI.enabled = enabled; var depthFilterDropdownIndex = Mathf.Clamp(lastDepthFilterDropdownIndex, -1, m_DepthStringsAuto.Length - 1); depthFilterDropdownIndex = EditorGUILayout.IntPopup(depthFilterDropdownIndex, m_DepthStringsAuto, m_DepthValuesAuto, GUILayout.Width(layoutOptionWidth)); GUI.enabled = lastEnabled; if (depthFilterDropdownIndex != lastDepthFilterDropdownIndex) { if (depthFilterDropdownIndex == ProfileAnalyzer.kDepthAll) { m_DepthFilter1 = m_DepthFilter2 = ProfileAnalyzer.kDepthAll; } else { CalcAutoSlicesFromMenuEntryIndex(depthFilterDropdownIndex, ref m_DepthFilter1, ref m_DepthFilter2, leftMax, rightMax); } ClampDepthFilterForAutoRespectingDiff(ref m_DepthFilter1, ref m_DepthFilter2, profileLeftView, profileRightView); triggerRefresh = true; } } #endif } else { #if UNITY_2019_1_OR_NEWER DrawDepthFilterDropdown(ProfileAnalyzerWindow.Styles.leftDepthTitle, enabled, profileLeftView, (primary, left, right) => m_DepthFilter1 = primary, ViewType.Left, profileSingleView, profileLeftView, profileRightView); #else if (m_DepthStrings1 != null) { EditorGUILayout.LabelField(ProfileAnalyzerWindow.Styles.leftDepthTitle, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); int lastDepthFilter1 = m_DepthFilter1; m_DepthFilter1 = m_DepthFilter1 == ProfileAnalyzer.kDepthAll ? ProfileAnalyzer.kDepthAll : profileLeftView.ClampToValidDepthValue(m_DepthFilter1); GUI.enabled = enabled; m_DepthFilter1 = EditorGUILayout.IntPopup(m_DepthFilter1, m_DepthStrings1, m_DepthValues1, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); GUI.enabled = lastEnabled; if (m_DepthFilter1 != lastDepthFilter1) { triggerRefresh = true; } } #endif #if UNITY_2019_1_OR_NEWER DrawDepthFilterDropdown(ProfileAnalyzerWindow.Styles.rightDepthTitle, enabled && !m_DepthFilterAuto, profileRightView, (primary, left, right) => m_DepthFilter2 = primary, ViewType.Right, profileSingleView, profileLeftView, profileRightView); #else if (m_DepthStrings2 != null) { EditorGUILayout.LabelField(ProfileAnalyzerWindow.Styles.rightDepthTitle, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); int lastDepthFilter2 = m_DepthFilter2; m_DepthFilter2 = m_DepthFilter2 == ProfileAnalyzer.kDepthAll ? ProfileAnalyzer.kDepthAll : profileRightView.ClampToValidDepthValue(m_DepthFilter2); GUI.enabled = enabled && !m_DepthFilterAuto; m_DepthFilter2 = EditorGUILayout.IntPopup(m_DepthFilter2, m_DepthStrings2, m_DepthValues2, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); GUI.enabled = lastEnabled; if (m_DepthFilter2 != lastDepthFilter2) { triggerRefresh = true; } } #endif } bool lastDepthFilterLock = m_DepthFilterAuto; GUI.enabled = enabled; m_DepthFilterAuto = EditorGUILayout.ToggleLeft(ProfileAnalyzerWindow.Styles.autoDepthTitle, m_DepthFilterAuto); GUI.enabled = lastEnabled; if (m_DepthFilterAuto != lastDepthFilterLock) { if (UpdateDepthFilters(singleView, profileSingleView, profileLeftView, profileRightView)) { m_UpdateActiveTabCallback(true); } #if !UNITY_2019_1_OR_NEWER m_DepthStringsAuto = null; m_DepthStrings1 = null; m_DepthStrings2 = null; #endif } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); #if !UNITY_2019_1_OR_NEWER if (triggerRefresh) { UpdateDepthFilters(singleView, profileSingleView, profileLeftView, profileRightView); m_UpdateActiveTabCallback(true); } #endif }
void ClampDepthFilterForAutoRespectingDiff(ref int filterDepthLeft, ref int filterDepthRight, ProfileDataView profileLeftView, ProfileDataView profileRightView) { if (filterDepthLeft == ProfileAnalyzer.kDepthAll && filterDepthRight == ProfileAnalyzer.kDepthAll) { // nothing to do here, keep showing all return; } var leftMax = profileLeftView.GetMaxDepth(); var rightMax = profileRightView.GetMaxDepth(); var sliceMenuEntryIndex = CalcSliceMenuEntryIndex(filterDepthLeft, filterDepthRight, leftMax, rightMax); CalcAutoSlicesFromMenuEntryIndex(sliceMenuEntryIndex, ref filterDepthLeft, ref filterDepthRight, leftMax, rightMax); }
void DrawDepthFilterDropdown(GUIContent title, bool enabled, ProfileDataView view, Action <int, int, int> callback, ViewType viewType, ProfileDataView profileSingleView, ProfileDataView profileLeftView, ProfileDataView profileRightView) { if (title != null) { EditorGUILayout.LabelField(title, GUILayout.Width(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); } int depthFilter = ProfileAnalyzer.kDepthAll; int depthFilterOther = ProfileAnalyzer.kDepthAll; var maxDepth = view.GetMaxDepth(); var maxDepthLeft = ProfileAnalyzer.kDepthAll; var maxDepthRight = ProfileAnalyzer.kDepthAll; var oldDepthFilter = ProfileAnalyzer.kDepthAll; var oldDepthFilterOtherLocked = ProfileAnalyzer.kDepthAll; var depthDiff = mostCommonDepthDiff; GUIContent content; switch (viewType) { case ViewType.Single: oldDepthFilter = m_DepthFilter; depthFilter = m_DepthFilter = m_DepthFilter == ProfileAnalyzer.kDepthAll ? ProfileAnalyzer.kDepthAll : profileSingleView.ClampToValidDepthValue(m_DepthFilter); content = new GUIContent(DepthFilterToString(depthFilter)); depthFilterOther = depthFilter; depthDiff = 0; break; case ViewType.Left: oldDepthFilter = m_DepthFilter1; depthFilter = m_DepthFilter1 = m_DepthFilter1 == ProfileAnalyzer.kDepthAll ? ProfileAnalyzer.kDepthAll : profileLeftView.ClampToValidDepthValue(m_DepthFilter1); content = new GUIContent(DepthFilterToString(depthFilter)); depthFilterOther = depthFilter; break; case ViewType.Right: oldDepthFilter = m_DepthFilter2; depthFilter = m_DepthFilter2 = m_DepthFilter2 == ProfileAnalyzer.kDepthAll ? ProfileAnalyzer.kDepthAll : profileRightView.ClampToValidDepthValue(m_DepthFilter2); content = new GUIContent(DepthFilterToString(depthFilter)); depthFilterOther = depthFilter; break; case ViewType.Locked: oldDepthFilter = m_DepthFilter1; oldDepthFilterOtherLocked = m_DepthFilter2; maxDepth = maxDepthLeft = profileLeftView.GetMaxDepth(); maxDepthRight = profileRightView.GetMaxDepth(); ClampDepthFilterForAutoRespectingDiff(ref m_DepthFilter1, ref m_DepthFilter2, profileLeftView, profileRightView); depthFilter = m_DepthFilter1; depthFilterOther = m_DepthFilter2; content = new GUIContent(DepthFilterToString(m_DepthFilter1, m_DepthFilter2, mostCommonDepthDiff < 0)); break; default: throw new NotImplementedException(); } var lastEnabled = GUI.enabled; GUI.enabled = enabled; var rect = GUILayoutUtility.GetRect(content, EditorStyles.popup, GUILayout.MinWidth(ProfileAnalyzerWindow.LayoutSize.FilterOptionsEnumWidth)); if (GUI.Button(rect, content, EditorStyles.popup)) { var dropdown = new DepthSliceDropdown(maxDepth, depthFilter, depthFilterOther, (slice, left, right) => { if (slice != depthFilter || (viewType == ViewType.Locked && (left != m_DepthFilter1 || right != m_DepthFilter2))) { callback(slice, left, right); UpdateDepthFilters(viewType == ViewType.Single, profileSingleView, profileLeftView, profileRightView); m_UpdateActiveTabCallback(true); } }, depthDiff, maxDepthRight); dropdown.Show(rect); EditorGUIUtility.ExitGUI(); } else { // The depths can change because the data changed, not just because the user selected a different option in the dropdown // in that case, the depth filters need to perform a refresh if (oldDepthFilter != depthFilter || viewType == ViewType.Locked && oldDepthFilterOtherLocked != depthFilterOther) { UpdateDepthFilters(viewType == ViewType.Single, profileSingleView, profileLeftView, profileRightView); m_UpdateActiveTabCallback(true); } } GUI.enabled = lastEnabled; }