public FrameDataTreeViewItem(FrameDataView frameDataView, int id, int depth, TreeViewItem parent) : base(id, depth, parent, null) { Assert.IsNotNull(frameDataView); m_FrameDataView = frameDataView; m_Initialized = false; }
static ProfilerColors() { // Areas are defined by stats in ProfilerStats.cpp file. // Color are driven by CPU profiler chart area colors and must be consistent with CPU timeline sample colors. // Sample color is defined by ProfilerGroup (category) and defined in s_ProfilerGroupInfos table. s_DefaultColors = new Color[] { FrameDataView.GetMarkerCategoryColor(0), // "Rendering" FrameDataView.GetMarkerCategoryColor(1), // "Scripts" FrameDataView.GetMarkerCategoryColor(5), // "Physics" FrameDataView.GetMarkerCategoryColor(6), // "Animation" FrameDataView.GetMarkerCategoryColor(15), // "GarbageCollector" FrameDataView.GetMarkerCategoryColor(16), // "VSync" FrameDataView.GetMarkerCategoryColor(11), // "Global Illumination" FrameDataView.GetMarkerCategoryColor(24), // "UI" new Color(122.0f / 255.0f, 123.0f / 255.0f, 30.0f / 255.0f, 1.0f), // "Others" new Color(240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f), // light-coral new Color(169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f), // dark-gray new Color(139.0f / 255.0f, 0.0f, 139.0f / 255.0f, 1.0f), // dark-magenta new Color(255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f), // moccasin new Color(32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f), // light-sea-green new Color(0.4831376f, 0.6211768f, 0.0219608f, 1.0f), new Color(0.3827448f, 0.2886272f, 0.5239216f, 1.0f), new Color(0.8f, 0.4423528f, 0.0f, 1.0f), new Color(0.4486272f, 0.4078432f, 0.050196f, 1.0f), new Color(0.4831376f, 0.6211768f, 0.0219608f, 1.0f), }; s_ColorBlindSafeColors = new Color[s_DefaultColors.Length]; VisionUtility.GetColorBlindSafePalette(s_ColorBlindSafeColors, 0.3f, 1f); }
static ProfilerColors() { ProfilerColors.s_DefaultColors = new Color[] { FrameDataView.GetMarkerCategoryColor(0), FrameDataView.GetMarkerCategoryColor(1), FrameDataView.GetMarkerCategoryColor(5), FrameDataView.GetMarkerCategoryColor(15), FrameDataView.GetMarkerCategoryColor(16), FrameDataView.GetMarkerCategoryColor(11), FrameDataView.GetMarkerCategoryColor(24), new Color(0.478431374f, 0.482352942f, 0.117647059f, 1f), new Color(0.9411765f, 0.5019608f, 0.5019608f, 1f), new Color(0.6627451f, 0.6627451f, 0.6627451f, 1f), new Color(0.545098066f, 0f, 0.545098066f, 1f), new Color(1f, 0.894117653f, 0.709803939f, 1f), new Color(0.1254902f, 0.698039234f, 0.6666667f, 1f), new Color(0.4831376f, 0.6211768f, 0.0219608f, 1f), new Color(0.3827448f, 0.2886272f, 0.5239216f, 1f), new Color(0.8f, 0.4423528f, 0f, 1f), new Color(0.4486272f, 0.4078432f, 0.050196f, 1f), new Color(0.4831376f, 0.6211768f, 0.0219608f, 1f) }; ProfilerColors.s_ColorBlindSafeColors = new Color[ProfilerColors.s_DefaultColors.Length]; VisionUtility.GetColorBlindSafePalette(ProfilerColors.s_ColorBlindSafeColors, 0.3f, 1f); }
internal void Init(FrameDataView frameDataView, int id, int depth, TreeViewItem parent) { this.id = id; this.depth = depth; this.parent = parent; this.displayName = null; m_FrameDataView = frameDataView; m_Initialized = false; }
public void Clear() { if (this.m_FrameDataView != null) { this.m_FrameDataView.Dispose(); this.m_FrameDataView = null; base.Reload(); } }
public void Clear() { if (m_FrameDataView == null) { return; } m_FrameDataView.Dispose(); m_FrameDataView = null; Reload(); }
static float GetCounterValueAsFloat(FrameDataView frameData, string name) { var id = frameData.GetMarkerId(name); if (id == FrameDataView.invalidMarkerId) { return(-1); } return(frameData.GetCounterValueAsFloat(id)); }
internal void DrawToolbar(FrameDataView frameDataView) { const float sidebarWidth = Chart.kSideWidth - 1; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Width(sidebarWidth)); DrawViewTypePopup(ProfilerViewType.Timeline); EditorGUILayout.EndHorizontal(); var height = EditorStyles.toolbar.CalcHeight(GUIContent.none, 0f); var timeRulerRect = EditorGUILayout.GetControlRect(false, height, GUIStyle.none, GUILayout.ExpandWidth(true)); var iter = new ProfilerFrameDataIterator(); iter.SetRoot(frameDataView.frameIndex, 0); var frameTime = iter.frameTimeMS; DoTimeRulerGUI(timeRulerRect, frameTime); }
FrameDataTreeViewItem AcquireFrameDataTreeViewItem(FrameDataView frameDataView, int id, int depth, TreeViewItem parent) { if (m_RowsPool.Count > 0) { FrameDataTreeViewItem child = (FrameDataTreeViewItem)m_RowsPool[m_RowsPool.Count - 1]; m_RowsPool.RemoveAt(m_RowsPool.Count - 1); child.Init(m_FrameDataView, id, depth, parent); if (child.children != null) { m_ChildrenPool.Push(child.children); child.children = null; } return(child); } return(new FrameDataTreeViewItem(m_FrameDataView, id, depth, parent)); }
public void Clear() { if (m_FrameDataView == null) { return; } m_FrameDataView.Dispose(); m_FrameDataView = null; m_RowsPool.Clear(); m_ChildrenPool.Clear(); m_ReusableVisitList.Clear(); m_ReusableChildrenIds.Clear(); m_TreeTraversalStatePool.Clear(); Reload(); }
internal void DrawToolbar(FrameDataView frameDataView) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[] { GUILayout.Width(179f) }); base.DrawViewTypePopup(ProfilerViewType.Timeline); EditorGUILayout.EndHorizontal(); float height = EditorStyles.toolbar.CalcHeight(GUIContent.none, 0f); Rect controlRect = EditorGUILayout.GetControlRect(false, height, GUIStyle.none, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); profilerFrameDataIterator.SetRoot(frameDataView.frameIndex, 0); float frameTimeMS = profilerFrameDataIterator.frameTimeMS; this.DoTimeRulerGUI(controlRect, frameTimeMS); }
public void SetFrameDataView(FrameDataView frameDataView) { bool flag = !object.Equals(this.m_FrameDataView, frameDataView); bool flag2 = frameDataView != null && (frameDataView.sortColumn != this.m_MultiColumnHeader.sortedProfilerColumn || frameDataView.sortColumnAscending != this.m_MultiColumnHeader.sortedProfilerColumnAscending); if (flag) { this.StoreExpandedState(); this.StoreSelectedState(); } this.m_FrameDataView = frameDataView; if (flag2) { this.m_FrameDataView.Sort(this.m_MultiColumnHeader.sortedProfilerColumn, this.m_MultiColumnHeader.sortedProfilerColumnAscending); } if (flag || flag2) { base.Reload(); } }
public void SetFrameDataView(FrameDataView frameDataView) { var needReload = !Equals(m_FrameDataView, frameDataView); var needSorting = frameDataView != null && (frameDataView.sortColumn != m_MultiColumnHeader.sortedProfilerColumn || frameDataView.sortColumnAscending != m_MultiColumnHeader.sortedProfilerColumnAscending); if (needReload) { StoreExpandedState(); StoreSelectedState(); } m_FrameDataView = frameDataView; if (needSorting) { m_FrameDataView.Sort(m_MultiColumnHeader.sortedProfilerColumn, m_MultiColumnHeader.sortedProfilerColumnAscending); } if (needReload || needSorting) { Reload(); } }
public void DoGUI(FrameDataView frameDataView, float width, float ypos, float height) { if (frameDataView == null || !frameDataView.IsValid()) { GUILayout.Label(ProfilerFrameDataViewBase.BaseStyles.noData, ProfilerFrameDataViewBase.BaseStyles.label, new GUILayoutOption[0]); } else { Rect drawRect = new Rect(0f, ypos - 1f, width, height + 1f); float num = 179f; if (Event.current.type == EventType.Repaint) { ProfilerTimelineGUI.styles.profilerGraphBackground.Draw(drawRect, false, false, false, false); EditorStyles.toolbar.Draw(new Rect(0f, ypos + height - 15f, num, 15f), false, false, false, false); } bool flag = false; if (this.m_TimeArea == null) { flag = true; this.m_TimeArea = new ZoomableArea(); this.m_TimeArea.hRangeLocked = false; this.m_TimeArea.vRangeLocked = true; this.m_TimeArea.hSlider = true; this.m_TimeArea.vSlider = false; this.m_TimeArea.scaleWithWindow = true; this.m_TimeArea.rect = new Rect(drawRect.x + num - 1f, drawRect.y, drawRect.width - num, drawRect.height); this.m_TimeArea.margin = 10f; } if (flag) { NativeProfilerTimeline_InitializeArgs nativeProfilerTimeline_InitializeArgs = default(NativeProfilerTimeline_InitializeArgs); nativeProfilerTimeline_InitializeArgs.Reset(); nativeProfilerTimeline_InitializeArgs.ghostAlpha = 0.3f; nativeProfilerTimeline_InitializeArgs.nonSelectedAlpha = 0.75f; nativeProfilerTimeline_InitializeArgs.guiStyle = ProfilerTimelineGUI.styles.bar.m_Ptr; nativeProfilerTimeline_InitializeArgs.lineHeight = 16f; nativeProfilerTimeline_InitializeArgs.textFadeOutWidth = 20f; nativeProfilerTimeline_InitializeArgs.textFadeStartWidth = 50f; NativeProfilerTimeline.Initialize(ref nativeProfilerTimeline_InitializeArgs); } ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int threadCount = profilerFrameDataIterator.GetThreadCount(frameDataView.frameIndex); profilerFrameDataIterator.SetRoot(frameDataView.frameIndex, 0); this.m_TimeArea.hBaseRangeMin = 0f; this.m_TimeArea.hBaseRangeMax = profilerFrameDataIterator.frameTimeMS; if (flag) { this.PerformFrameSelected(profilerFrameDataIterator.frameTimeMS); } this.m_TimeArea.rect = new Rect(drawRect.x + num, drawRect.y, drawRect.width - num, drawRect.height); this.m_TimeArea.BeginViewGUI(); this.m_TimeArea.EndViewGUI(); drawRect = this.m_TimeArea.drawRect; this.DrawGrid(drawRect, profilerFrameDataIterator.frameTimeMS); this.MarkDeadOrClearThread(); this.CalculateBars(ref profilerFrameDataIterator, drawRect, frameDataView.frameIndex, this.animationTime); this.DrawBars(drawRect, frameDataView.frameIndex); this.DoRangeSelection(this.m_TimeArea.drawRect); GUI.BeginClip(this.m_TimeArea.drawRect); drawRect.x = 0f; drawRect.y = 0f; bool enabled = GUI.enabled; GUI.enabled = false; int num2 = (!this.m_Window.IsRecording()) ? 3 : 1; int num3 = num2; int num4 = frameDataView.frameIndex; float num5 = 0f; do { int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(num4); if (previousFrameIndex == -1) { break; } profilerFrameDataIterator.SetRoot(previousFrameIndex, 0); num5 -= profilerFrameDataIterator.frameTimeMS; num4 = previousFrameIndex; num3--; }while (num5 > this.m_TimeArea.shownArea.x && num3 > 0); while (num4 != -1 && num4 != frameDataView.frameIndex) { profilerFrameDataIterator.SetRoot(num4, 0); this.DoProfilerFrame(num4, drawRect, true, threadCount, num5); num5 += profilerFrameDataIterator.frameTimeMS; num4 = ProfilerDriver.GetNextFrameIndex(num4); } num3 = num2; num4 = frameDataView.frameIndex; num5 = 0f; while (num5 < this.m_TimeArea.shownArea.x + this.m_TimeArea.shownArea.width && num3 >= 0) { if (frameDataView.frameIndex != num4) { this.DoProfilerFrame(num4, drawRect, true, threadCount, num5); } profilerFrameDataIterator.SetRoot(num4, 0); num4 = ProfilerDriver.GetNextFrameIndex(num4); if (num4 == -1) { break; } num5 += profilerFrameDataIterator.frameTimeMS; num3--; } GUI.enabled = enabled; threadCount = 0; this.DoProfilerFrame(frameDataView.frameIndex, drawRect, false, threadCount, 0f); GUI.EndClip(); this.DoSelectionTooltip(frameDataView.frameIndex, this.m_TimeArea.drawRect); } }
public FrameDataTreeViewItem(FrameDataView frameDataView, int id, int depth, TreeViewItem parent) : base(id, depth, parent, null) { this.m_FrameDataView = frameDataView; this.m_Initialized = false; }
public void DoGUI(FrameDataView frameDataView, float width, float ypos, float height) { if (frameDataView == null || !frameDataView.IsValid()) { GUILayout.Label(BaseStyles.noData, BaseStyles.label); return; } Rect fullRect = new Rect(0, ypos - 1, width, height + 1); float sideWidth = Chart.kSideWidth - 1; if (Event.current.type == EventType.Repaint) { styles.profilerGraphBackground.Draw(fullRect, false, false, false, false); // The bar in the lower left side that fills the space next to the horizontal scrollbar. EditorStyles.toolbar.Draw(new Rect(0, ypos + height - 15, sideWidth, 15), false, false, false, false); } bool initializing = false; if (m_TimeArea == null) { initializing = true; m_TimeArea = new ZoomableArea(); m_TimeArea.hRangeLocked = false; m_TimeArea.vRangeLocked = true; m_TimeArea.hSlider = true; m_TimeArea.vSlider = false; m_TimeArea.scaleWithWindow = true; m_TimeArea.rect = new Rect(fullRect.x + sideWidth - 1, fullRect.y, fullRect.width - sideWidth, fullRect.height); m_TimeArea.margin = 10; } if (initializing) { NativeProfilerTimeline_InitializeArgs args = new NativeProfilerTimeline_InitializeArgs(); args.Reset(); args.ghostAlpha = 0.3f; args.nonSelectedAlpha = 0.75f; args.guiStyle = styles.bar.m_Ptr; args.lineHeight = kLineHeight; args.textFadeOutWidth = kTextFadeOutWidth; args.textFadeStartWidth = kTextFadeStartWidth; NativeProfilerTimeline.Initialize(ref args); } var iter = new ProfilerFrameDataIterator(); int threadCount = iter.GetThreadCount(frameDataView.frameIndex); iter.SetRoot(frameDataView.frameIndex, 0); m_TimeArea.hBaseRangeMin = 0; m_TimeArea.hBaseRangeMax = iter.frameTimeMS; if (initializing) { PerformFrameSelected(iter.frameTimeMS); } m_TimeArea.rect = new Rect(fullRect.x + sideWidth, fullRect.y, fullRect.width - sideWidth, fullRect.height); m_TimeArea.BeginViewGUI(); m_TimeArea.EndViewGUI(); fullRect = m_TimeArea.drawRect; DrawGrid(fullRect, iter.frameTimeMS); MarkDeadOrClearThread(); CalculateBars(ref iter, fullRect, frameDataView.frameIndex, animationTime); DrawBars(fullRect, frameDataView.frameIndex); DoRangeSelection(m_TimeArea.drawRect); GUI.BeginClip(m_TimeArea.drawRect); fullRect.x = 0; fullRect.y = 0; bool oldEnabled = GUI.enabled; GUI.enabled = false; // Walk backwards to find how many previous frames we need to show. int maxContextFramesToShow = m_Window.IsRecording() ? 1 : 3; int numContextFramesToShow = maxContextFramesToShow; int currentFrame = frameDataView.frameIndex; float currentTime = 0; do { int prevFrame = ProfilerDriver.GetPreviousFrameIndex(currentFrame); if (prevFrame == -1) { break; } iter.SetRoot(prevFrame, 0); currentTime -= iter.frameTimeMS; currentFrame = prevFrame; --numContextFramesToShow; }while (currentTime > m_TimeArea.shownArea.x && numContextFramesToShow > 0); // Draw previous frames while (currentFrame != -1 && currentFrame != frameDataView.frameIndex) { iter.SetRoot(currentFrame, 0); DoProfilerFrame(currentFrame, fullRect, true, threadCount, currentTime); currentTime += iter.frameTimeMS; currentFrame = ProfilerDriver.GetNextFrameIndex(currentFrame); } // Draw next frames numContextFramesToShow = maxContextFramesToShow; currentFrame = frameDataView.frameIndex; currentTime = 0; while (currentTime < m_TimeArea.shownArea.x + m_TimeArea.shownArea.width && numContextFramesToShow >= 0) { if (frameDataView.frameIndex != currentFrame) { DoProfilerFrame(currentFrame, fullRect, true, threadCount, currentTime); } iter.SetRoot(currentFrame, 0); currentFrame = ProfilerDriver.GetNextFrameIndex(currentFrame); if (currentFrame == -1) { break; } currentTime += iter.frameTimeMS; --numContextFramesToShow; } GUI.enabled = oldEnabled; // Draw center frame last to get on top threadCount = 0; DoProfilerFrame(frameDataView.frameIndex, fullRect, false, threadCount, 0); GUI.EndClip(); // Draw tooltips on top of clip to be able to extend outside of timeline area DoSelectionTooltip(frameDataView.frameIndex, m_TimeArea.drawRect); }