private void DrawNativeProfilerTimeline(Rect threadRect, int frameIndex, int threadIndex, float timeOffset, bool ghost) { bool flag = this.m_SelectedEntry.threadId == threadIndex && this.m_SelectedEntry.frameId == frameIndex; NativeProfilerTimeline_DrawArgs nativeProfilerTimeline_DrawArgs = default(NativeProfilerTimeline_DrawArgs); nativeProfilerTimeline_DrawArgs.Reset(); nativeProfilerTimeline_DrawArgs.frameIndex = frameIndex; nativeProfilerTimeline_DrawArgs.threadIndex = threadIndex; nativeProfilerTimeline_DrawArgs.timeOffset = timeOffset; nativeProfilerTimeline_DrawArgs.threadRect = threadRect; nativeProfilerTimeline_DrawArgs.shownAreaRect = this.m_TimeArea.shownArea; nativeProfilerTimeline_DrawArgs.selectedEntryIndex = ((!flag) ? -1 : this.m_SelectedEntry.nativeIndex); nativeProfilerTimeline_DrawArgs.mousedOverEntryIndex = -1; NativeProfilerTimeline.Draw(ref nativeProfilerTimeline_DrawArgs); }
void DrawNativeProfilerTimeline(Rect threadRect, int frameIndex, int threadIndex, float timeOffset, bool ghost) { bool hasSelection = m_SelectedEntry.threadId == threadIndex && m_SelectedEntry.frameId == frameIndex; NativeProfilerTimeline_DrawArgs drawArgs = new NativeProfilerTimeline_DrawArgs(); drawArgs.Reset(); drawArgs.frameIndex = frameIndex; drawArgs.threadIndex = threadIndex; drawArgs.timeOffset = timeOffset; drawArgs.threadRect = threadRect; drawArgs.shownAreaRect = m_TimeArea.shownArea; drawArgs.selectedEntryIndex = hasSelection ? m_SelectedEntry.nativeIndex : -1; drawArgs.mousedOverEntryIndex = -1; NativeProfilerTimeline.Draw(ref drawArgs); }
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); } }
private void HandleNativeProfilerTimelineInput(Rect threadRect, int frameIndex, int threadIndex, float timeOffset, float topMargin) { if (threadRect.Contains(Event.current.mousePosition)) { bool flag = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag2 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; bool flag3 = (flag || flag2) && Event.current.button == 0; if (flag3) { NativeProfilerTimeline_GetEntryAtPositionArgs nativeProfilerTimeline_GetEntryAtPositionArgs = default(NativeProfilerTimeline_GetEntryAtPositionArgs); nativeProfilerTimeline_GetEntryAtPositionArgs.Reset(); nativeProfilerTimeline_GetEntryAtPositionArgs.frameIndex = frameIndex; nativeProfilerTimeline_GetEntryAtPositionArgs.threadIndex = threadIndex; nativeProfilerTimeline_GetEntryAtPositionArgs.timeOffset = timeOffset; nativeProfilerTimeline_GetEntryAtPositionArgs.threadRect = threadRect; nativeProfilerTimeline_GetEntryAtPositionArgs.shownAreaRect = this.m_TimeArea.shownArea; nativeProfilerTimeline_GetEntryAtPositionArgs.position = Event.current.mousePosition; NativeProfilerTimeline.GetEntryAtPosition(ref nativeProfilerTimeline_GetEntryAtPositionArgs); int out_EntryIndex = nativeProfilerTimeline_GetEntryAtPositionArgs.out_EntryIndex; if (out_EntryIndex != -1) { bool flag4 = !this.m_SelectedEntry.Equals(frameIndex, threadIndex, out_EntryIndex); if (flag4) { NativeProfilerTimeline_GetEntryTimingInfoArgs nativeProfilerTimeline_GetEntryTimingInfoArgs = default(NativeProfilerTimeline_GetEntryTimingInfoArgs); nativeProfilerTimeline_GetEntryTimingInfoArgs.Reset(); nativeProfilerTimeline_GetEntryTimingInfoArgs.frameIndex = frameIndex; nativeProfilerTimeline_GetEntryTimingInfoArgs.threadIndex = threadIndex; nativeProfilerTimeline_GetEntryTimingInfoArgs.entryIndex = out_EntryIndex; nativeProfilerTimeline_GetEntryTimingInfoArgs.calculateFrameData = true; NativeProfilerTimeline.GetEntryTimingInfo(ref nativeProfilerTimeline_GetEntryTimingInfoArgs); NativeProfilerTimeline_GetEntryInstanceInfoArgs nativeProfilerTimeline_GetEntryInstanceInfoArgs = default(NativeProfilerTimeline_GetEntryInstanceInfoArgs); nativeProfilerTimeline_GetEntryInstanceInfoArgs.Reset(); nativeProfilerTimeline_GetEntryInstanceInfoArgs.frameIndex = frameIndex; nativeProfilerTimeline_GetEntryInstanceInfoArgs.threadIndex = threadIndex; nativeProfilerTimeline_GetEntryInstanceInfoArgs.entryIndex = out_EntryIndex; NativeProfilerTimeline.GetEntryInstanceInfo(ref nativeProfilerTimeline_GetEntryInstanceInfoArgs); this.m_Window.SetSelectedPropertyPath(nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_Path); this.m_SelectedEntry.Reset(); this.m_SelectedEntry.frameId = frameIndex; this.m_SelectedEntry.threadId = threadIndex; this.m_SelectedEntry.nativeIndex = out_EntryIndex; this.m_SelectedEntry.instanceId = nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_Id; this.m_SelectedEntry.time = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_LocalStartTime; this.m_SelectedEntry.duration = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_Duration; this.m_SelectedEntry.totalDuration = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_TotalDurationForFrame; this.m_SelectedEntry.instanceCount = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_InstanceCountForFrame; this.m_SelectedEntry.relativeYPos = nativeProfilerTimeline_GetEntryAtPositionArgs.out_EntryYMaxPos + topMargin; this.m_SelectedEntry.name = nativeProfilerTimeline_GetEntryAtPositionArgs.out_EntryName; this.m_SelectedEntry.callstackInfo = nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_CallstackInfo; this.m_SelectedEntry.metaData = nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_MetaData; } Event.current.Use(); this.UpdateSelectedObject(flag, flag2); } else if (flag3) { this.ClearSelection(); Event.current.Use(); } } } }
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(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); }
void HandleNativeProfilerTimelineInput(Rect threadRect, int frameIndex, int threadIndex, float timeOffset, float topMargin) { // Only let this thread view change mouse state if it contained the mouse pos bool inThreadRect = threadRect.Contains(Event.current.mousePosition); if (!inThreadRect) { return; } bool singleClick = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool doubleClick = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; bool doSelect = (singleClick || doubleClick) && Event.current.button == 0; if (!doSelect) { return; } NativeProfilerTimeline_GetEntryAtPositionArgs posArgs = new NativeProfilerTimeline_GetEntryAtPositionArgs(); posArgs.Reset(); posArgs.frameIndex = frameIndex; posArgs.threadIndex = threadIndex; posArgs.timeOffset = timeOffset; posArgs.threadRect = threadRect; posArgs.shownAreaRect = m_TimeArea.shownArea; posArgs.position = Event.current.mousePosition; NativeProfilerTimeline.GetEntryAtPosition(ref posArgs); int mouseOverIndex = posArgs.out_EntryIndex; if (mouseOverIndex != -1) { bool selectedChanged = !m_SelectedEntry.Equals(frameIndex, threadIndex, mouseOverIndex); if (selectedChanged) { // Read out timing info NativeProfilerTimeline_GetEntryTimingInfoArgs timingInfoArgs = new NativeProfilerTimeline_GetEntryTimingInfoArgs(); timingInfoArgs.Reset(); timingInfoArgs.frameIndex = frameIndex; timingInfoArgs.threadIndex = threadIndex; timingInfoArgs.entryIndex = mouseOverIndex; timingInfoArgs.calculateFrameData = true; NativeProfilerTimeline.GetEntryTimingInfo(ref timingInfoArgs); // Read out instance info for selection NativeProfilerTimeline_GetEntryInstanceInfoArgs instanceInfoArgs = new NativeProfilerTimeline_GetEntryInstanceInfoArgs(); instanceInfoArgs.Reset(); instanceInfoArgs.frameIndex = frameIndex; instanceInfoArgs.threadIndex = threadIndex; instanceInfoArgs.entryIndex = mouseOverIndex; NativeProfilerTimeline.GetEntryInstanceInfo(ref instanceInfoArgs); m_Window.SetSelectedPropertyPath(instanceInfoArgs.out_Path); // Set selected entry info m_SelectedEntry.Reset(); m_SelectedEntry.frameId = frameIndex; m_SelectedEntry.threadId = threadIndex; m_SelectedEntry.nativeIndex = mouseOverIndex; m_SelectedEntry.instanceId = instanceInfoArgs.out_Id; m_SelectedEntry.time = timingInfoArgs.out_LocalStartTime; m_SelectedEntry.duration = timingInfoArgs.out_Duration; m_SelectedEntry.totalDuration = timingInfoArgs.out_TotalDurationForFrame; m_SelectedEntry.instanceCount = timingInfoArgs.out_InstanceCountForFrame; m_SelectedEntry.relativeYPos = posArgs.out_EntryYMaxPos + topMargin; m_SelectedEntry.name = posArgs.out_EntryName; m_SelectedEntry.callstackInfo = instanceInfoArgs.out_CallstackInfo; m_SelectedEntry.metaData = instanceInfoArgs.out_MetaData; } Event.current.Use(); UpdateSelectedObject(singleClick, doubleClick); } else { // click on empty space de-selects if (doSelect) { ClearSelection(); Event.current.Use(); } } }