public void DoGUI(int frameIndex, float width, float ypos, float height) { Rect drawRect = new Rect(0f, ypos - 1f, width, height + 1f); float num = 169f; 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.profilerColors = ProfilerColors.colors; nativeProfilerTimeline_InitializeArgs.allocationSampleColor = ProfilerColors.allocationSample; nativeProfilerTimeline_InitializeArgs.internalSampleColor = ProfilerColors.internalSample; 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(); profilerFrameDataIterator.SetRoot(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.CalculateBars(drawRect, frameIndex, this.animationTime); this.DrawBars(drawRect, frameIndex); GUI.BeginClip(this.m_TimeArea.drawRect); drawRect.x = 0f; drawRect.y = 0f; bool enabled = GUI.enabled; GUI.enabled = false; ProfilerFrameDataIterator profilerFrameDataIterator2 = new ProfilerFrameDataIterator(); int threadCount = profilerFrameDataIterator2.GetThreadCount(frameIndex); int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(frameIndex); if (previousFrameIndex != -1) { profilerFrameDataIterator2.SetRoot(previousFrameIndex, 0); this.DoProfilerFrame(previousFrameIndex, drawRect, true, threadCount, -profilerFrameDataIterator2.frameTimeMS); } int nextFrameIndex = ProfilerDriver.GetNextFrameIndex(frameIndex); if (nextFrameIndex != -1) { profilerFrameDataIterator2.SetRoot(frameIndex, 0); this.DoProfilerFrame(nextFrameIndex, drawRect, true, threadCount, profilerFrameDataIterator2.frameTimeMS); } GUI.enabled = enabled; threadCount = 0; this.DoProfilerFrame(frameIndex, drawRect, false, threadCount, 0f); GUI.EndClip(); this.DoSelectionTooltip(frameIndex, this.m_TimeArea.drawRect); }
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 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); }