private void CalculateBars(Rect r, int frameIndex, float time) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int groupCount = profilerFrameDataIterator.GetGroupCount(frameIndex); float num = 0f; profilerFrameDataIterator.SetRoot(frameIndex, 0); int threadCount = profilerFrameDataIterator.GetThreadCount(frameIndex); int i; for (i = 0; i < threadCount; i++) { profilerFrameDataIterator.SetRoot(frameIndex, i); string groupname = profilerFrameDataIterator.GetGroupName(); ProfilerTimelineGUI.GroupInfo groupInfo = this.groups.Find((ProfilerTimelineGUI.GroupInfo g) => g.name == groupname); if (groupInfo == null) { groupInfo = new ProfilerTimelineGUI.GroupInfo(); groupInfo.name = groupname; groupInfo.height = 20f; groupInfo.expanded = false; groupInfo.threads = new List <ProfilerTimelineGUI.ThreadInfo>(); this.groups.Add(groupInfo); if (groupname == string.Empty || groupname == "Unity Job System") { groupInfo.expanded = true; } } List <ProfilerTimelineGUI.ThreadInfo> threads = groupInfo.threads; ProfilerTimelineGUI.ThreadInfo threadInfo = threads.Find((ProfilerTimelineGUI.ThreadInfo t) => t.threadIndex == i); if (threadInfo == null) { threadInfo = new ProfilerTimelineGUI.ThreadInfo(); threadInfo.name = profilerFrameDataIterator.GetThreadName(); threadInfo.height = 0f; threadInfo.weight = (threadInfo.desiredWeight = (float)((!groupInfo.expanded) ? 0 : 1)); threadInfo.threadIndex = i; groupInfo.threads.Add(threadInfo); } if (threadInfo.weight != threadInfo.desiredWeight) { threadInfo.weight = threadInfo.desiredWeight * time + (1f - threadInfo.desiredWeight) * (1f - time); } num += threadInfo.weight; } float num2 = 16f * (float)groupCount; float num3 = r.height - num2; float num4 = num3 / (num + 2f); foreach (ProfilerTimelineGUI.GroupInfo current in this.groups) { foreach (ProfilerTimelineGUI.ThreadInfo current2 in current.threads) { current2.height = num4 * current2.weight; } } this.groups[0].expanded = true; this.groups[0].height = 0f; this.groups[0].threads[0].height = 3f * num4; }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, ref int threadCount, float offset) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int threadCount2 = profilerFrameDataIterator.GetThreadCount(frameIndex); if (ghost && threadCount2 != threadCount) { return; } if (!ghost) { threadCount = threadCount2; } for (int i = 0; i < threadCount; i++) { Rect r = fullRect; r.y = this.GetThreadY(fullRect, i, threadCount); r.height = this.GetThreadY(fullRect, i + 1, threadCount) - r.y; profilerFrameDataIterator.SetRoot(frameIndex, i); if (i == 0 && !ghost) { this.DrawGrid(fullRect, threadCount, profilerFrameDataIterator.frameTimeMS); this.HandleFrameSelected(profilerFrameDataIterator.frameTimeMS); } this.DrawProfilingData(profilerFrameDataIterator, r, i, offset, ghost); } }
public void DoGUI(int frameIndex, float width, float ypos, float height) { Rect position = new Rect(0f, ypos - 1f, width, height + 1f); float num = 169f; if (Event.current.type == EventType.Repaint) { styles.profilerGraphBackground.Draw(position, 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((position.x + num) - 1f, position.y, position.width - num, position.height); this.m_TimeArea.margin = 10f; } ProfilerFrameDataIterator iterator = new ProfilerFrameDataIterator(); iterator.SetRoot(frameIndex, 0); this.m_TimeArea.hBaseRangeMin = 0f; this.m_TimeArea.hBaseRangeMax = iterator.frameTimeMS; if (flag) { this.PerformFrameSelected(iterator.frameTimeMS); } this.m_TimeArea.rect = new Rect(position.x + num, position.y, position.width - num, position.height); this.m_TimeArea.BeginViewGUI(); this.m_TimeArea.EndViewGUI(); position = this.m_TimeArea.drawRect; this.DrawBars(position, frameIndex); GUI.BeginClip(this.m_TimeArea.drawRect); position.x = 0f; position.y = 0f; int threadCount = 0; this.DoProfilerFrame(frameIndex, position, false, ref threadCount, 0f); bool enabled = GUI.enabled; GUI.enabled = false; int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(frameIndex); if (previousFrameIndex != -1) { ProfilerFrameDataIterator iterator2 = new ProfilerFrameDataIterator(); iterator2.SetRoot(previousFrameIndex, 0); this.DoProfilerFrame(previousFrameIndex, position, true, ref threadCount, -iterator2.frameTimeMS); } int nextFrameIndex = ProfilerDriver.GetNextFrameIndex(frameIndex); if (nextFrameIndex != -1) { ProfilerFrameDataIterator iterator3 = new ProfilerFrameDataIterator(); iterator3.SetRoot(frameIndex, 0); this.DoProfilerFrame(nextFrameIndex, position, true, ref threadCount, iterator3.frameTimeMS); } GUI.enabled = enabled; GUI.EndClip(); }
private void CalculateBars(Rect r, int frameIndex, float time) { ProfilerFrameDataIterator iterator = new ProfilerFrameDataIterator(); int groupCount = iterator.GetGroupCount(frameIndex); float num2 = 0f; iterator.SetRoot(frameIndex, 0); int threadCount = iterator.GetThreadCount(frameIndex);
void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, int threadCount, float offset) { var iter = new ProfilerFrameDataIterator(); int myThreadCount = iter.GetThreadCount(frameIndex); if (ghost && myThreadCount != threadCount) { return; } iter.SetRoot(frameIndex, 0); if (!ghost) { HandleFrameSelected(iter.frameTimeMS); } float y = fullRect.y; foreach (var groupInfo in groups) { Rect r = fullRect; var expanded = groupInfo.expanded; if (expanded) { y += groupInfo.height; } var yStart = y; var groupThreadCount = groupInfo.threads.Count; foreach (var threadInfo in groupInfo.threads) { iter.SetRoot(frameIndex, threadInfo.threadIndex); r.y = y; r.height = expanded ? threadInfo.height : Math.Max(groupInfo.height / groupThreadCount - 1, 2); DoNativeProfilerTimeline(r, frameIndex, threadInfo.threadIndex, offset, ghost); // Save the y pos of the selected thread each time we draw, since it can change bool containsSelected = m_SelectedEntry.IsValid() && (m_SelectedEntry.frameId == frameIndex) && (m_SelectedEntry.threadId == threadInfo.threadIndex); if (containsSelected) { m_SelectedThreadY = y; } y += r.height; } if (!expanded) { y = yStart + Math.Max(groupInfo.height, groupThreadCount * 2); } } }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, int threadCount, float offset, bool detailView) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int threadCount2 = profilerFrameDataIterator.GetThreadCount(frameIndex); if (!ghost || threadCount2 == threadCount) { profilerFrameDataIterator.SetRoot(frameIndex, 0); if (!ghost) { this.DrawGrid(fullRect, threadCount, profilerFrameDataIterator.frameTimeMS); this.HandleFrameSelected(profilerFrameDataIterator.frameTimeMS); } float num = fullRect.y; foreach (ProfilerTimelineGUI.GroupInfo current in this.groups) { Rect r = fullRect; bool expanded = current.expanded; if (expanded) { num += current.height; } float num2 = num; int count = current.threads.Count; foreach (ProfilerTimelineGUI.ThreadInfo current2 in current.threads) { profilerFrameDataIterator.SetRoot(frameIndex, current2.threadIndex); r.y = num; r.height = ((!expanded) ? Math.Max(current.height / (float)count - 1f, 2f) : current2.height); if (detailView) { this.DoNativeProfilerTimeline(r, frameIndex, current2.threadIndex, offset, ghost); } else { this.DrawProfilingData(profilerFrameDataIterator, r, frameIndex, current2.threadIndex, offset, ghost, expanded); } bool flag = this.m_SelectedEntry.IsValid() && this.m_SelectedEntry.frameId == frameIndex && this.m_SelectedEntry.threadId == current2.threadIndex; if (flag) { this.m_SelectedThreadY = num; } num += r.height; } if (!expanded) { num = num2 + current.height; } } } }
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); }
private void DrawBars(Rect r, int frameIndex) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); profilerFrameDataIterator.SetRoot(frameIndex, 0); int threadCount = profilerFrameDataIterator.GetThreadCount(frameIndex); if (Event.current.type == EventType.Repaint) { for (int i = 0; i < threadCount; i++) { profilerFrameDataIterator.SetRoot(frameIndex, i); float threadY = this.GetThreadY(r, i, threadCount); float height = this.GetThreadY(r, i + 1, threadCount) - threadY; Rect position = new Rect(r.x - 170f, threadY, 170f, height); Rect position2 = new Rect(r.x, threadY, r.width, height); ProfilerTimelineGUI.styles.rightPane.Draw(position2, false, false, false, false); ProfilerTimelineGUI.styles.leftPane.Draw(position, GUIContent.Temp(profilerFrameDataIterator.GetThreadName()), false, false, false, false); } } }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, ref int threadCount, float offset) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int threadCount2 = profilerFrameDataIterator.GetThreadCount(frameIndex); if (ghost && threadCount2 != threadCount) { return; } profilerFrameDataIterator.SetRoot(frameIndex, 0); if (!ghost) { threadCount = threadCount2; this.DrawGrid(fullRect, threadCount, profilerFrameDataIterator.frameTimeMS); this.HandleFrameSelected(profilerFrameDataIterator.frameTimeMS); } float num = fullRect.y; foreach (ProfilerTimelineGUI.GroupInfo current in this.groups) { Rect r = fullRect; bool expanded = current.expanded; if (expanded) { num += current.height; } float num2 = num; int count = current.threads.Count; foreach (ProfilerTimelineGUI.ThreadInfo current2 in current.threads) { profilerFrameDataIterator.SetRoot(frameIndex, current2.threadIndex); r.y = num; r.height = ((!expanded) ? Math.Max(current.height / (float)count - 1f, 2f) : current2.height); this.DrawProfilingData(profilerFrameDataIterator, r, current2.threadIndex, offset, ghost, expanded); num += r.height; } if (!expanded) { num = num2 + current.height; } } }
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); }
private void DrawBars(Rect r, int frameIndex) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); profilerFrameDataIterator.SetRoot(frameIndex, 0); int threadCount = profilerFrameDataIterator.GetThreadCount(frameIndex); if (Event.current.type == EventType.Repaint) { for (int i = 0; i < threadCount; i++) { profilerFrameDataIterator.SetRoot(frameIndex, i); float threadY = this.GetThreadY(r, i, threadCount); float height = this.GetThreadY(r, i + 1, threadCount) - threadY; Rect position = new Rect(r.x - 170f, threadY, 170f, height); Rect position2 = new Rect(r.x, threadY, r.width, height); ProfilerTimelineGUI.styles.rightPane.Draw(position2, false, false, false, false); ProfilerTimelineGUI.styles.leftPane.Draw(position, GUIContent.Temp(profilerFrameDataIterator.GetThreadName()), false, false, false, false); } } }
private void CalculateBars(Rect r, int frameIndex, float time) { ProfilerFrameDataIterator frameDataIterator = new ProfilerFrameDataIterator(); int groupCount = frameDataIterator.GetGroupCount(frameIndex); float num1 = 0.0f; frameDataIterator.SetRoot(frameIndex, 0); int threadCount = frameDataIterator.GetThreadCount(frameIndex); // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAD barsCAnonStoreyAd = new ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAD(); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field for (barsCAnonStoreyAd.i = 0; barsCAnonStoreyAd.i < threadCount; barsCAnonStoreyAd.i = barsCAnonStoreyAd.i + 1) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAC barsCAnonStoreyAc = new ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAC(); // ISSUE: reference to a compiler-generated field barsCAnonStoreyAc.\u003C\u003Ef__ref\u0024173 = barsCAnonStoreyAd; // ISSUE: reference to a compiler-generated field frameDataIterator.SetRoot(frameIndex, barsCAnonStoreyAd.i); // ISSUE: reference to a compiler-generated field barsCAnonStoreyAc.groupname = frameDataIterator.GetGroupName(); // ISSUE: reference to a compiler-generated method ProfilerTimelineGUI.GroupInfo groupInfo = this.groups.Find(new Predicate<ProfilerTimelineGUI.GroupInfo>(barsCAnonStoreyAc.\u003C\u003Em__1F5)); if (groupInfo == null) { groupInfo = new ProfilerTimelineGUI.GroupInfo(); // ISSUE: reference to a compiler-generated field groupInfo.name = barsCAnonStoreyAc.groupname; groupInfo.height = 20f; groupInfo.expanded = false; groupInfo.threads = new List<ProfilerTimelineGUI.ThreadInfo>(); this.groups.Add(groupInfo); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field if (barsCAnonStoreyAc.groupname == string.Empty || barsCAnonStoreyAc.groupname == "Unity Job System") groupInfo.expanded = true; } // ISSUE: reference to a compiler-generated method ProfilerTimelineGUI.ThreadInfo threadInfo1 = groupInfo.threads.Find(new Predicate<ProfilerTimelineGUI.ThreadInfo>(barsCAnonStoreyAc.\u003C\u003Em__1F6)); if (threadInfo1 == null) { threadInfo1 = new ProfilerTimelineGUI.ThreadInfo(); threadInfo1.name = frameDataIterator.GetThreadName(); threadInfo1.height = 0.0f; ProfilerTimelineGUI.ThreadInfo threadInfo2 = threadInfo1; ProfilerTimelineGUI.ThreadInfo threadInfo3 = threadInfo1; int num2 = !groupInfo.expanded ? 0 : 1; double num3; float num4 = (float) (num3 = (double) num2); threadInfo3.desiredWeight = (float) num3; double num5 = (double) num4; threadInfo2.weight = (float) num5; // ISSUE: reference to a compiler-generated field threadInfo1.threadIndex = barsCAnonStoreyAd.i; groupInfo.threads.Add(threadInfo1); } if ((double) threadInfo1.weight != (double) threadInfo1.desiredWeight) threadInfo1.weight = (float) ((double) threadInfo1.desiredWeight * (double) time + (1.0 - (double) threadInfo1.desiredWeight) * (1.0 - (double) time)); num1 += threadInfo1.weight; } float num6 = 16f * (float) groupCount; float num7 = (r.height - num6) / (num1 + 2f); using (List<ProfilerTimelineGUI.GroupInfo>.Enumerator enumerator1 = this.groups.GetEnumerator()) { while (enumerator1.MoveNext()) { using (List<ProfilerTimelineGUI.ThreadInfo>.Enumerator enumerator2 = enumerator1.Current.threads.GetEnumerator()) { while (enumerator2.MoveNext()) { ProfilerTimelineGUI.ThreadInfo current = enumerator2.Current; current.height = num7 * current.weight; } } } } this.groups[0].expanded = true; this.groups[0].height = 0.0f; this.groups[0].threads[0].height = 3f * num7; }
public void DoGUI(int frameIndex, float width, float ypos, float height) { Rect position = new Rect(0.0f, ypos - 1f, width, height + 1f); float width1 = 169f; if (Event.current.type == EventType.Repaint) { ProfilerTimelineGUI.styles.profilerGraphBackground.Draw(position, false, false, false, false); EditorStyles.toolbar.Draw(new Rect(0.0f, (float) ((double) ypos + (double) height - 15.0), width1, 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((float) ((double) position.x + (double) width1 - 1.0), position.y, position.width - width1, position.height); this.m_TimeArea.margin = 10f; } ProfilerFrameDataIterator frameDataIterator1 = new ProfilerFrameDataIterator(); frameDataIterator1.SetRoot(frameIndex, 0); this.m_TimeArea.hBaseRangeMin = 0.0f; this.m_TimeArea.hBaseRangeMax = frameDataIterator1.frameTimeMS; if (flag) this.PerformFrameSelected(frameDataIterator1.frameTimeMS); this.m_TimeArea.rect = new Rect(position.x + width1, position.y, position.width - width1, position.height); this.m_TimeArea.BeginViewGUI(); this.m_TimeArea.EndViewGUI(); Rect drawRect = this.m_TimeArea.drawRect; this.CalculateBars(drawRect, frameIndex, this.animationTime); this.DrawBars(drawRect, frameIndex); GUI.BeginClip(this.m_TimeArea.drawRect); drawRect.x = 0.0f; drawRect.y = 0.0f; int threadCount = 0; this.DoProfilerFrame(frameIndex, drawRect, false, ref threadCount, 0.0f); bool enabled = GUI.enabled; GUI.enabled = false; int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(frameIndex); if (previousFrameIndex != -1) { ProfilerFrameDataIterator frameDataIterator2 = new ProfilerFrameDataIterator(); frameDataIterator2.SetRoot(previousFrameIndex, 0); this.DoProfilerFrame(previousFrameIndex, drawRect, true, ref threadCount, -frameDataIterator2.frameTimeMS); } int nextFrameIndex = ProfilerDriver.GetNextFrameIndex(frameIndex); if (nextFrameIndex != -1) { ProfilerFrameDataIterator frameDataIterator2 = new ProfilerFrameDataIterator(); frameDataIterator2.SetRoot(frameIndex, 0); this.DoProfilerFrame(nextFrameIndex, drawRect, true, ref threadCount, frameDataIterator2.frameTimeMS); } GUI.enabled = enabled; GUI.EndClip(); }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost, bool includeSubSamples) { float num1 = !ghost ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; Color color1 = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag1 = false; float x1 = -1f; float x2 = -1f; float y1 = -1f; int size = 0; float y2 = -1f; string str = (string) null; float num2 = !includeSubSamples ? r.height : 16f; float num3 = !includeSubSamples ? 0.0f : 1f; float height = num2 - 2f * num3; r.height -= num3; GUI.BeginGroup(r); // ISSUE: explicit reference operation // ISSUE: variable of a reference type Rect& local = @r; float num4 = 0.0f; r.y = num4; double num5 = (double) num4; // ISSUE: explicit reference operation (^local).x = (float) num5; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x3 = r.x; float x4 = shownArea.x; bool enterChildren = true; while (iter.Next(enterChildren)) { enterChildren = includeSubSamples; float time = iter.startTimeMS + timeOffset; float durationMs = iter.durationMS; float num6 = Mathf.Max(durationMs, 0.0003f); float pixelCached = ProfilerTimelineGUI.TimeToPixelCached(time, rectWidthDivShownWidth, x4, x3); float num7 = ProfilerTimelineGUI.TimeToPixelCached(time + num6, rectWidthDivShownWidth, x4, x3) - 1f; float width = num7 - pixelCached; if ((double) pixelCached > (double) r.x + (double) r.width || (double) num7 < (double) r.x) { enterChildren = false; } else { float num8 = (float) (iter.depth - 1); float y3 = r.y + num8 * num2; if (flag1) { bool flag4 = false; if ((double) width >= (double) num1) flag4 = true; if ((double) y1 != (double) y3) flag4 = true; if ((double) pixelCached - (double) x2 > 6.0) flag4 = true; if (flag4) { this.DrawSmallGroup(x1, x2, y1, height, size); flag1 = false; } } if ((double) width < (double) num1) { enterChildren = false; if (!flag1) { flag1 = true; y1 = y3; x1 = pixelCached; size = 0; } x2 = num7; ++size; } else { int id = iter.id; string path = iter.path; bool flag4 = path == selectedPropertyPath && !ghost; if (this.m_SelectedID >= 0) flag4 &= id == this.m_SelectedID; bool flag5 = flag4 & threadIdx == this.m_SelectedThread; Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = !flag5 ? 0.75f : 1f; if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text = iter.name; if (flag5) { str = text; this.m_SelectedTime = time; this.m_SelectedDur = durationMs; y2 = y3 + num2; } if ((double) width < 20.0 || !includeSubSamples) { text = string.Empty; } else { if ((double) width < 50.0 && !flag5) white.a *= (float) (((double) width - 20.0) / 30.0); if ((double) width > 200.0) text += string.Format(" ({0:f2}ms)", (object) durationMs); } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(pixelCached, y3, width, height); GUI.Label(position, text, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object gameObject = EditorUtility.InstanceIDToObject(iter.instanceId); if (gameObject is Component) gameObject = (UnityEngine.Object) ((Component) gameObject).gameObject; if (gameObject != (UnityEngine.Object) null) { if (flag2) EditorGUIUtility.PingObject(gameObject.GetInstanceID()); else if (flag3) Selection.objects = new List<UnityEngine.Object>() { gameObject }.ToArray(); } Event.current.Use(); } flag1 = false; } } } if (flag1) this.DrawSmallGroup(x1, x2, y1, height, size); GUI.color = color1; GUI.contentColor = contentColor; if (str != null && threadIdx == this.m_SelectedThread && includeSubSamples) { GUIContent content = new GUIContent(string.Format((double) this.m_SelectedDur < 1.0 ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", (object) str, (object) this.m_SelectedDur)); GUIStyle tooltip = ProfilerTimelineGUI.styles.tooltip; Vector2 vector2 = tooltip.CalcSize(content); float x5 = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + this.m_SelectedDur * 0.5f, r); if ((double) x5 < (double) r.x) x5 = r.x + 20f; if ((double) x5 > (double) r.xMax) x5 = r.xMax - 20f; Rect position; if ((double) y2 + 6.0 + (double) vector2.y < (double) r.yMax) { position = new Rect(x5 - 32f, y2, 50f, 7f); GUI.Label(position, GUIContent.none, ProfilerTimelineGUI.styles.tooltipArrow); } position = new Rect(x5, y2 + 6f, vector2.x, vector2.y); if ((double) position.xMax > (double) r.xMax + 20.0) position.x = (float) ((double) r.xMax - (double) position.width + 20.0); if ((double) position.yMax > (double) r.yMax) position.y = r.yMax - position.height; if ((double) position.y < (double) r.y) position.y = r.y; GUI.Label(position, content, tooltip); } if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { this.m_Window.ClearSelectedPropertyPath(); this.m_SelectedID = -1; this.m_SelectedThread = threadIdx; Event.current.Use(); } GUI.EndGroup(); }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, ref int threadCount, float offset) { ProfilerFrameDataIterator iter = new ProfilerFrameDataIterator(); int threadCount1 = iter.GetThreadCount(frameIndex); if (ghost && threadCount1 != threadCount) return; iter.SetRoot(frameIndex, 0); if (!ghost) { threadCount = threadCount1; this.DrawGrid(fullRect, threadCount, iter.frameTimeMS); this.HandleFrameSelected(iter.frameTimeMS); } float num1 = fullRect.y; using (List<ProfilerTimelineGUI.GroupInfo>.Enumerator enumerator1 = this.groups.GetEnumerator()) { while (enumerator1.MoveNext()) { ProfilerTimelineGUI.GroupInfo current1 = enumerator1.Current; Rect r = fullRect; bool expanded = current1.expanded; if (expanded) num1 += current1.height; float num2 = num1; int count = current1.threads.Count; using (List<ProfilerTimelineGUI.ThreadInfo>.Enumerator enumerator2 = current1.threads.GetEnumerator()) { while (enumerator2.MoveNext()) { ProfilerTimelineGUI.ThreadInfo current2 = enumerator2.Current; iter.SetRoot(frameIndex, current2.threadIndex); r.y = num1; r.height = !expanded ? Math.Max((float) ((double) current1.height / (double) count - 1.0), 2f) : current2.height; this.DrawProfilingData(iter, r, current2.threadIndex, offset, ghost, expanded); num1 += r.height; } } if (!expanded) num1 = num2 + current1.height; } } }
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); } }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int frameIndex, int threadIndex, float timeOffset, bool ghost, bool includeSubSamples) { float num = (!ghost) ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; Color color = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag = false; float x = -1f; float num2 = -1f; float num3 = -1f; int num4 = 0; float num5 = (!includeSubSamples) ? r.height : 16f; float num6 = (float)((!includeSubSamples) ? 0 : 1); float height = num5 - 2f * num6; r.height -= num6; GUI.BeginGroup(r); float num7 = 0f; r.y = num7; r.x = num7; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x2 = r.x; float x3 = shownArea.x; bool enterChildren = true; while (iter.Next(enterChildren)) { enterChildren = includeSubSamples; float num8 = iter.startTimeMS + timeOffset; float durationMS = iter.durationMS; float num9 = Mathf.Max(durationMS, 0.0003f); float num10 = ProfilerTimelineGUI.TimeToPixelCached(num8, rectWidthDivShownWidth, x3, x2); float num11 = ProfilerTimelineGUI.TimeToPixelCached(num8 + num9, rectWidthDivShownWidth, x3, x2) - 1f; float num12 = num11 - num10; if (num10 > r.x + r.width || num11 < r.x) { enterChildren = false; } else { float num13 = (float)(iter.depth - 1); float num14 = r.y + num13 * num5; if (flag) { bool flag4 = false; if (num12 >= num) { flag4 = true; } if (num3 != num14) { flag4 = true; } if (num10 - num2 > 6f) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x, num2, num3, height, num4); flag = false; } } if (num12 < num) { enterChildren = false; if (!flag) { flag = true; num3 = num14; x = num10; num4 = 0; } num2 = num11; num4++; } else { int instanceId = iter.instanceId; string path = iter.path; bool flag5 = path == selectedPropertyPath && !ghost; if (this.m_SelectedEntry.instanceId >= 0) { flag5 &= (instanceId == this.m_SelectedEntry.instanceId); } flag5 &= (threadIndex == this.m_SelectedEntry.threadId); Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = ((!flag5) ? 0.75f : 1f); if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text = iter.name; if (num12 < 20f || !includeSubSamples) { text = string.Empty; } else { if (num12 < 50f && !flag5) { white.a *= (num12 - 20f) / 30f; } if (num12 > 200f) { text += string.Format(" ({0:f2}ms)", durationMS); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(num10, num14, num12, height); GUI.Label(position, text, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition) && includeSubSamples) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedEntry.Reset(); this.m_SelectedEntry.frameId = frameIndex; this.m_SelectedEntry.threadId = threadIndex; this.m_SelectedEntry.instanceId = instanceId; this.m_SelectedEntry.name = iter.name; if (iter.extraTooltipInfo != null) { this.m_SelectedEntry.metaData = iter.extraTooltipInfo; } this.m_SelectedEntry.time = num8; this.m_SelectedEntry.duration = durationMS; this.m_SelectedEntry.relativeYPos = num14 + num5; this.UpdateSelectedObject(flag2, flag3); Event.current.Use(); } flag = false; } } } if (flag) { this.DrawSmallGroup(x, num2, num3, height, num4); } GUI.color = color; GUI.contentColor = contentColor; if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { this.ClearSelection(); Event.current.Use(); } GUI.EndGroup(); }
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; this.m_TimeArea.OnEnable(); } 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.DrawBars(drawRect, frameIndex); GUI.BeginClip(this.m_TimeArea.drawRect); drawRect.x = 0f; drawRect.y = 0f; int num2 = 0; this.DoProfilerFrame(frameIndex, drawRect, false, ref num2, 0f); bool enabled = GUI.enabled; GUI.enabled = false; int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(frameIndex); if (previousFrameIndex != -1) { ProfilerFrameDataIterator profilerFrameDataIterator2 = new ProfilerFrameDataIterator(); profilerFrameDataIterator2.SetRoot(previousFrameIndex, 0); this.DoProfilerFrame(previousFrameIndex, drawRect, true, ref num2, -profilerFrameDataIterator2.frameTimeMS); } int nextFrameIndex = ProfilerDriver.GetNextFrameIndex(frameIndex); if (nextFrameIndex != -1) { ProfilerFrameDataIterator profilerFrameDataIterator3 = new ProfilerFrameDataIterator(); profilerFrameDataIterator3.SetRoot(frameIndex, 0); this.DoProfilerFrame(nextFrameIndex, drawRect, true, ref num2, profilerFrameDataIterator3.frameTimeMS); } GUI.enabled = enabled; GUI.EndClip(); }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost) { float num = (!ghost) ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; bool enterChildren = true; Color color = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag = false; float x = -1f; float num2 = -1f; float num3 = -1f; int num4 = 0; float num5 = -1f; string text = null; r.height -= 1f; GUI.BeginGroup(r); float num6 = 0f; r.y = num6; r.x = num6; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x2 = r.x; float x3 = shownArea.x; while (iter.Next(enterChildren)) { enterChildren = true; float num7 = iter.startTimeMS + timeOffset; float durationMS = iter.durationMS; float num8 = Mathf.Max(durationMS, 0.0003f); float num9 = ProfilerTimelineGUI.TimeToPixelCached(num7, rectWidthDivShownWidth, x3, x2); float num10 = ProfilerTimelineGUI.TimeToPixelCached(num7 + num8, rectWidthDivShownWidth, x3, x2) - 1f; float num11 = num10 - num9; if (num9 > r.x + r.width || num10 < r.x) { enterChildren = false; } else { float num12 = (float)(iter.depth - 1); float num13 = r.y + num12 * 16f; if (flag) { bool flag4 = false; if (num11 >= num) { flag4 = true; } if (num3 != num13) { flag4 = true; } if (num9 - num2 > 6f) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x, num2, num3, num4); flag = false; } } if (num11 < num) { enterChildren = false; if (!flag) { flag = true; num3 = num13; x = num9; num4 = 0; } num2 = num10; num4++; } else { int id = iter.id; string path = iter.path; bool flag5 = path == selectedPropertyPath && !ghost; if (this.m_SelectedID >= 0) { flag5 &= (id == this.m_SelectedID); } flag5 &= (threadIdx == this.m_SelectedThread); Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = ((!flag5) ? 0.75f : 1f); if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text2 = iter.name; if (flag5) { text = text2; this.m_SelectedTime = num7; this.m_SelectedDur = durationMS; num5 = num13 + 16f; } if (num11 < 20f) { text2 = string.Empty; } else { if (num11 < 50f && !flag5) { white.a *= (num11 - 20f) / 30f; } if (num11 > 200f) { text2 += string.Format(" ({0:f2}ms)", durationMS); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(num9, num13, num11, 14f); GUI.Label(position, text2, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object @object = EditorUtility.InstanceIDToObject(iter.instanceId); if (@object is Component) { @object = ((Component)@object).gameObject; } if (@object != null) { if (flag2) { EditorGUIUtility.PingObject(@object.GetInstanceID()); } else { if (flag3) { Selection.objects = new List<UnityEngine.Object> { @object }.ToArray(); } } } Event.current.Use(); } flag = false; } } } if (flag) { this.DrawSmallGroup(x, num2, num3, num4); } GUI.color = color; GUI.contentColor = contentColor; if (text != null && threadIdx == this.m_SelectedThread) { string text3 = string.Format(((double)this.m_SelectedDur < 1.0) ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", text, this.m_SelectedDur); GUIContent content = new GUIContent(text3); GUIStyle tooltip = ProfilerTimelineGUI.styles.tooltip; Vector2 vector = tooltip.CalcSize(content); float num14 = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + this.m_SelectedDur * 0.5f, r); if (num14 < r.x) { num14 = r.x + 20f; } if (num14 > r.xMax) { num14 = r.xMax - 20f; } Rect position2; if (num5 + 6f + vector.y < r.yMax) { position2 = new Rect(num14 - 32f, num5, 50f, 7f); GUI.Label(position2, GUIContent.none, ProfilerTimelineGUI.styles.tooltipArrow); } position2 = new Rect(num14, num5 + 6f, vector.x, vector.y); if (position2.xMax > r.xMax + 20f) { position2.x = r.xMax - position2.width + 20f; } if (position2.yMax > r.yMax) { position2.y = r.yMax - position2.height; } if (position2.y < r.y) { position2.y = r.y; } GUI.Label(position2, content, tooltip); } if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { this.m_Window.ClearSelectedPropertyPath(); this.m_SelectedID = -1; this.m_SelectedThread = threadIdx; Event.current.Use(); } GUI.EndGroup(); }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, ref int threadCount, float offset) { ProfilerFrameDataIterator iter = new ProfilerFrameDataIterator(); int num = iter.GetThreadCount(frameIndex); if (!ghost || (num == threadCount)) { if (!ghost) { threadCount = num; } for (int i = 0; i < threadCount; i++) { Rect r = fullRect; r.y = this.GetThreadY(fullRect, i, threadCount); r.height = this.GetThreadY(fullRect, i + 1, threadCount) - r.y; iter.SetRoot(frameIndex, i); if ((i == 0) && !ghost) { this.DrawGrid(fullRect, threadCount, iter.frameTimeMS); this.HandleFrameSelected(iter.frameTimeMS); } this.DrawProfilingData(iter, r, i, offset, ghost); } } }
private void CalculateBars(ref ProfilerFrameDataIterator iter, Rect r, int frameIndex, float time) { float visibleThreadCount = 0; iter.SetRoot(frameIndex, 0); int threadCount = iter.GetThreadCount(frameIndex); for (int i = 0; i < threadCount; ++i) { iter.SetRoot(frameIndex, i); string groupname = iter.GetGroupName(); GroupInfo group = groups.Find(g => g.name == groupname); if (group == null) { group = new GroupInfo(); group.name = groupname; group.height = kGroupHeight; group.expanded = false; group.threads = new List <ThreadInfo>(); groups.Add(group); } var threads = group.threads; ThreadInfo thread = threads.Find(t => t.threadIndex == i); if (thread == null) { thread = new ThreadInfo(); thread.name = iter.GetThreadName(); thread.height = 0; thread.weight = thread.desiredWeight = group.expanded ? 1 : 0; thread.threadIndex = i; group.threads.Add(thread); } thread.alive = true; if (thread.weight != thread.desiredWeight) { thread.weight = thread.desiredWeight * time + (1 - thread.desiredWeight) * (1 - time); } visibleThreadCount += thread.weight; } var groupheight = 0.0f; foreach (var group in groups) { if (group.threads.Count > 1) { groupheight += !group.expanded ? group.height : Math.Max(group.height, group.threads.Count * 2.0f); } } var remaining = r.height - groupheight; var heightPerThread = remaining / (visibleThreadCount + 1); // main thread gets 2 times the space foreach (var group in groups) { foreach (var thread in group.threads) { thread.height = heightPerThread * thread.weight; } } groups[0].expanded = true; groups[0].height = 0; if (groups[0].threads.Count > 0) { groups[0].threads[0].height = 2 * heightPerThread; } }
private void CalculateBars(Rect r, int frameIndex, float time) { ProfilerFrameDataIterator frameDataIterator = new ProfilerFrameDataIterator(); int groupCount = frameDataIterator.GetGroupCount(frameIndex); float num1 = 0.0f; frameDataIterator.SetRoot(frameIndex, 0); int threadCount = frameDataIterator.GetThreadCount(frameIndex); // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAD barsCAnonStoreyAd = new ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAD(); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field for (barsCAnonStoreyAd.i = 0; barsCAnonStoreyAd.i < threadCount; barsCAnonStoreyAd.i = barsCAnonStoreyAd.i + 1) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAC barsCAnonStoreyAc = new ProfilerTimelineGUI.\u003CCalculateBars\u003Ec__AnonStoreyAC(); // ISSUE: reference to a compiler-generated field barsCAnonStoreyAc.\u003C\u003Ef__ref\u0024173 = barsCAnonStoreyAd; // ISSUE: reference to a compiler-generated field frameDataIterator.SetRoot(frameIndex, barsCAnonStoreyAd.i); // ISSUE: reference to a compiler-generated field barsCAnonStoreyAc.groupname = frameDataIterator.GetGroupName(); // ISSUE: reference to a compiler-generated method ProfilerTimelineGUI.GroupInfo groupInfo = this.groups.Find(new Predicate <ProfilerTimelineGUI.GroupInfo>(barsCAnonStoreyAc.\u003C\u003Em__1F5)); if (groupInfo == null) { groupInfo = new ProfilerTimelineGUI.GroupInfo(); // ISSUE: reference to a compiler-generated field groupInfo.name = barsCAnonStoreyAc.groupname; groupInfo.height = 20f; groupInfo.expanded = false; groupInfo.threads = new List <ProfilerTimelineGUI.ThreadInfo>(); this.groups.Add(groupInfo); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field if (barsCAnonStoreyAc.groupname == string.Empty || barsCAnonStoreyAc.groupname == "Unity Job System") { groupInfo.expanded = true; } } // ISSUE: reference to a compiler-generated method ProfilerTimelineGUI.ThreadInfo threadInfo1 = groupInfo.threads.Find(new Predicate <ProfilerTimelineGUI.ThreadInfo>(barsCAnonStoreyAc.\u003C\u003Em__1F6)); if (threadInfo1 == null) { threadInfo1 = new ProfilerTimelineGUI.ThreadInfo(); threadInfo1.name = frameDataIterator.GetThreadName(); threadInfo1.height = 0.0f; ProfilerTimelineGUI.ThreadInfo threadInfo2 = threadInfo1; ProfilerTimelineGUI.ThreadInfo threadInfo3 = threadInfo1; int num2 = !groupInfo.expanded ? 0 : 1; double num3; float num4 = (float)(num3 = (double)num2); threadInfo3.desiredWeight = (float)num3; double num5 = (double)num4; threadInfo2.weight = (float)num5; // ISSUE: reference to a compiler-generated field threadInfo1.threadIndex = barsCAnonStoreyAd.i; groupInfo.threads.Add(threadInfo1); } if ((double)threadInfo1.weight != (double)threadInfo1.desiredWeight) { threadInfo1.weight = (float)((double)threadInfo1.desiredWeight * (double)time + (1.0 - (double)threadInfo1.desiredWeight) * (1.0 - (double)time)); } num1 += threadInfo1.weight; } float num6 = 16f * (float)groupCount; float num7 = (r.height - num6) / (num1 + 2f); using (List <ProfilerTimelineGUI.GroupInfo> .Enumerator enumerator1 = this.groups.GetEnumerator()) { while (enumerator1.MoveNext()) { using (List <ProfilerTimelineGUI.ThreadInfo> .Enumerator enumerator2 = enumerator1.Current.threads.GetEnumerator()) { while (enumerator2.MoveNext()) { ProfilerTimelineGUI.ThreadInfo current = enumerator2.Current; current.height = num7 * current.weight; } } } } this.groups[0].expanded = true; this.groups[0].height = 0.0f; this.groups[0].threads[0].height = 3f * num7; }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost, bool includeSubSamples) { float num1 = !ghost ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; Color color1 = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag1 = false; float x1 = -1f; float x2 = -1f; float y1 = -1f; int size = 0; float y2 = -1f; string str = (string)null; float num2 = !includeSubSamples ? r.height : 16f; float num3 = !includeSubSamples ? 0.0f : 1f; float height = num2 - 2f * num3; r.height -= num3; GUI.BeginGroup(r); // ISSUE: explicit reference operation // ISSUE: variable of a reference type Rect& local = @r; float num4 = 0.0f; r.y = num4; double num5 = (double)num4; // ISSUE: explicit reference operation (^ local).x = (float)num5; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x3 = r.x; float x4 = shownArea.x; bool enterChildren = true; while (iter.Next(enterChildren)) { enterChildren = includeSubSamples; float time = iter.startTimeMS + timeOffset; float durationMs = iter.durationMS; float num6 = Mathf.Max(durationMs, 0.0003f); float pixelCached = ProfilerTimelineGUI.TimeToPixelCached(time, rectWidthDivShownWidth, x4, x3); float num7 = ProfilerTimelineGUI.TimeToPixelCached(time + num6, rectWidthDivShownWidth, x4, x3) - 1f; float width = num7 - pixelCached; if ((double)pixelCached > (double)r.x + (double)r.width || (double)num7 < (double)r.x) { enterChildren = false; } else { float num8 = (float)(iter.depth - 1); float y3 = r.y + num8 * num2; if (flag1) { bool flag4 = false; if ((double)width >= (double)num1) { flag4 = true; } if ((double)y1 != (double)y3) { flag4 = true; } if ((double)pixelCached - (double)x2 > 6.0) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x1, x2, y1, height, size); flag1 = false; } } if ((double)width < (double)num1) { enterChildren = false; if (!flag1) { flag1 = true; y1 = y3; x1 = pixelCached; size = 0; } x2 = num7; ++size; } else { int id = iter.id; string path = iter.path; bool flag4 = path == selectedPropertyPath && !ghost; if (this.m_SelectedID >= 0) { flag4 &= id == this.m_SelectedID; } bool flag5 = flag4 & threadIdx == this.m_SelectedThread; Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = !flag5 ? 0.75f : 1f; if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text = iter.name; if (flag5) { str = text; this.m_SelectedTime = time; this.m_SelectedDur = durationMs; y2 = y3 + num2; } if ((double)width < 20.0 || !includeSubSamples) { text = string.Empty; } else { if ((double)width < 50.0 && !flag5) { white.a *= (float)(((double)width - 20.0) / 30.0); } if ((double)width > 200.0) { text += string.Format(" ({0:f2}ms)", (object)durationMs); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(pixelCached, y3, width, height); GUI.Label(position, text, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object gameObject = EditorUtility.InstanceIDToObject(iter.instanceId); if (gameObject is Component) { gameObject = (UnityEngine.Object)((Component)gameObject).gameObject; } if (gameObject != (UnityEngine.Object)null) { if (flag2) { EditorGUIUtility.PingObject(gameObject.GetInstanceID()); } else if (flag3) { Selection.objects = new List <UnityEngine.Object>() { gameObject } }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost) { float num = (!ghost) ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; bool enterChildren = true; Color color = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag = false; float x = -1f; float num2 = -1f; float num3 = -1f; int num4 = 0; float num5 = -1f; string text = null; r.height -= 1f; GUI.BeginGroup(r); float num6 = 0f; r.y = num6; r.x = num6; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x2 = r.x; float x3 = shownArea.x; while (iter.Next(enterChildren)) { enterChildren = true; float num7 = iter.startTimeMS + timeOffset; float durationMS = iter.durationMS; float num8 = Mathf.Max(durationMS, 0.0003f); float num9 = ProfilerTimelineGUI.TimeToPixelCached(num7, rectWidthDivShownWidth, x3, x2); float num10 = ProfilerTimelineGUI.TimeToPixelCached(num7 + num8, rectWidthDivShownWidth, x3, x2) - 1f; float num11 = num10 - num9; if (num9 > r.x + r.width || num10 < r.x) { enterChildren = false; } else { float num12 = (float)(iter.depth - 1); float num13 = r.y + num12 * 16f; if (flag) { bool flag4 = false; if (num11 >= num) { flag4 = true; } if (num3 != num13) { flag4 = true; } if (num9 - num2 > 6f) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x, num2, num3, num4); flag = false; } } if (num11 < num) { enterChildren = false; if (!flag) { flag = true; num3 = num13; x = num9; num4 = 0; } num2 = num10; num4++; } else { int id = iter.id; string path = iter.path; bool flag5 = path == selectedPropertyPath && !ghost; if (this.m_SelectedID >= 0) { flag5 &= (id == this.m_SelectedID); } flag5 &= (threadIdx == this.m_SelectedThread); Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = ((!flag5) ? 0.75f : 1f); if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text2 = iter.name; if (flag5) { text = text2; this.m_SelectedTime = num7; this.m_SelectedDur = durationMS; num5 = num13 + 16f; } if (num11 < 20f) { text2 = string.Empty; } else { if (num11 < 50f && !flag5) { white.a *= (num11 - 20f) / 30f; } if (num11 > 200f) { text2 += string.Format(" ({0:f2}ms)", durationMS); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(num9, num13, num11, 14f); GUI.Label(position, text2, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object @object = EditorUtility.InstanceIDToObject(iter.instanceId); if (@object is Component) { @object = ((Component)@object).gameObject; } if (@object != null) { if (flag2) { EditorGUIUtility.PingObject(@object.GetInstanceID()); } else { if (flag3) { Selection.objects = new List <UnityEngine.Object> { @object }.ToArray(); } } } Event.current.Use(); } flag = false; } } } if (flag) { this.DrawSmallGroup(x, num2, num3, num4); } GUI.color = color; GUI.contentColor = contentColor; if (text != null && threadIdx == this.m_SelectedThread) { string text3 = string.Format(((double)this.m_SelectedDur < 1.0) ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", text, this.m_SelectedDur); GUIContent content = new GUIContent(text3); GUIStyle tooltip = ProfilerTimelineGUI.styles.tooltip; Vector2 vector = tooltip.CalcSize(content); float num14 = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + this.m_SelectedDur * 0.5f, r); if (num14 < r.x) { num14 = r.x + 20f; } if (num14 > r.xMax) { num14 = r.xMax - 20f; } Rect position2; if (num5 + 6f + vector.y < r.yMax) { position2 = new Rect(num14 - 32f, num5, 50f, 7f); GUI.Label(position2, GUIContent.none, ProfilerTimelineGUI.styles.tooltipArrow); } position2 = new Rect(num14, num5 + 6f, vector.x, vector.y); if (position2.xMax > r.xMax + 20f) { position2.x = r.xMax - position2.width + 20f; } if (position2.yMax > r.yMax) { position2.y = r.yMax - position2.height; } if (position2.y < r.y) { position2.y = r.y; } GUI.Label(position2, content, tooltip); } if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { this.m_Window.ClearSelectedPropertyPath(); this.m_SelectedID = -1; this.m_SelectedThread = threadIdx; Event.current.Use(); } GUI.EndGroup(); }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, int threadCount, float offset, bool detailView) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int threadCount2 = profilerFrameDataIterator.GetThreadCount(frameIndex); if (!ghost || threadCount2 == threadCount) { profilerFrameDataIterator.SetRoot(frameIndex, 0); if (!ghost) { this.DrawGrid(fullRect, threadCount, profilerFrameDataIterator.frameTimeMS); this.HandleFrameSelected(profilerFrameDataIterator.frameTimeMS); } float num = fullRect.y; foreach (ProfilerTimelineGUI.GroupInfo current in this.groups) { Rect r = fullRect; bool expanded = current.expanded; if (expanded) { num += current.height; } float num2 = num; int count = current.threads.Count; foreach (ProfilerTimelineGUI.ThreadInfo current2 in current.threads) { profilerFrameDataIterator.SetRoot(frameIndex, current2.threadIndex); r.y = num; r.height = ((!expanded) ? Math.Max(current.height / (float)count - 1f, 2f) : current2.height); if (detailView) { this.DrawProfilingDataDetailNative(r, frameIndex, current2.threadIndex, offset); } else { this.DrawProfilingData(profilerFrameDataIterator, r, frameIndex, current2.threadIndex, offset, ghost, expanded); } num += r.height; } if (!expanded) { num = num2 + current.height; } } if (this.m_SelectedName.Length > 0 && this.m_SelectedFrameId == frameIndex && !ghost) { string text = string.Format(((double)this.m_SelectedDur < 1.0) ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", this.m_SelectedName, this.m_SelectedDur); GUIContent content = new GUIContent(text); GUIStyle tooltip = ProfilerTimelineGUI.styles.tooltip; Vector2 vector = tooltip.CalcSize(content); float num3 = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + this.m_SelectedDur * 0.5f, this.m_SelectedRect); if (num3 > this.m_SelectedRect.xMax) { num3 = this.m_SelectedRect.xMax - 20f; } if (num3 < this.m_SelectedRect.x) { num3 = this.m_SelectedRect.x + 20f; } Rect position = new Rect(num3 - 32f, this.m_SelectedY, 50f, 7f); Rect position2 = new Rect(num3, this.m_SelectedY + 6f, vector.x, vector.y); if (position2.xMax > this.m_SelectedRect.xMax + 20f) { position2.x = this.m_SelectedRect.xMax - position2.width + 20f; } if (position2.xMin < this.m_SelectedRect.xMin + 30f) { position2.x = this.m_SelectedRect.xMin + 30f; } GUI.Label(position, GUIContent.none, ProfilerTimelineGUI.styles.tooltipArrow); GUI.Label(position2, content, tooltip); } } }
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); }
private void CalculateBars(ref ProfilerFrameDataIterator iter, Rect r, int frameIndex, float time) { float num = 0f; iter.SetRoot(frameIndex, 0); int threadCount = iter.GetThreadCount(frameIndex); int i; for (i = 0; i < threadCount; i++) { iter.SetRoot(frameIndex, i); string groupname = iter.GetGroupName(); ProfilerTimelineGUI.GroupInfo groupInfo = this.groups.Find((ProfilerTimelineGUI.GroupInfo g) => g.name == groupname); if (groupInfo == null) { groupInfo = new ProfilerTimelineGUI.GroupInfo(); groupInfo.name = groupname; groupInfo.height = 20f; groupInfo.expanded = false; groupInfo.threads = new List <ProfilerTimelineGUI.ThreadInfo>(); this.groups.Add(groupInfo); } List <ProfilerTimelineGUI.ThreadInfo> threads = groupInfo.threads; ProfilerTimelineGUI.ThreadInfo threadInfo = threads.Find((ProfilerTimelineGUI.ThreadInfo t) => t.threadIndex == i); if (threadInfo == null) { threadInfo = new ProfilerTimelineGUI.ThreadInfo(); threadInfo.name = iter.GetThreadName(); threadInfo.height = 0f; threadInfo.weight = (threadInfo.desiredWeight = (float)((!groupInfo.expanded) ? 0 : 1)); threadInfo.threadIndex = i; groupInfo.threads.Add(threadInfo); } threadInfo.alive = true; if (threadInfo.weight != threadInfo.desiredWeight) { threadInfo.weight = threadInfo.desiredWeight * time + (1f - threadInfo.desiredWeight) * (1f - time); } num += threadInfo.weight; } float num2 = 0f; foreach (ProfilerTimelineGUI.GroupInfo current in this.groups) { if (current.threads.Count > 1) { num2 += (current.expanded ? Math.Max(current.height, (float)current.threads.Count * 2f) : current.height); } } float num3 = r.height - num2; float num4 = num3 / (num + 1f); foreach (ProfilerTimelineGUI.GroupInfo current2 in this.groups) { foreach (ProfilerTimelineGUI.ThreadInfo current3 in current2.threads) { current3.height = num4 * current3.weight; } } this.groups[0].expanded = true; this.groups[0].height = 0f; if (this.groups[0].threads.Count > 0) { this.groups[0].threads[0].height = 2f * num4; } }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost) { float num = !ghost ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; bool enterChildren = true; Color color = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag2 = false; float num2 = -1f; float num3 = -1f; float y = -1f; int size = 0; float num6 = -1f; string str2 = null; r.height--; GUI.BeginGroup(r); float num20 = 0f; r.y = num20; r.x = num20; bool flag3 = (Event.current.clickCount == 1) && (Event.current.type == EventType.MouseDown); bool flag4 = (Event.current.clickCount == 2) && (Event.current.type == EventType.MouseDown); Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x = r.x; float shownX = shownArea.x; while (iter.Next(enterChildren)) { enterChildren = true; float time = iter.startTimeMS + timeOffset; float durationMS = iter.durationMS; float num12 = Mathf.Max(durationMS, 0.0003f); float num13 = TimeToPixelCached(time, rectWidthDivShownWidth, shownX, x); float num14 = TimeToPixelCached(time + num12, rectWidthDivShownWidth, shownX, x) - 1f; float width = num14 - num13; if ((num13 > (r.x + r.width)) || (num14 < r.x)) { enterChildren = false; } else { float num16 = iter.depth - 1; float num17 = r.y + (num16 * 16f); if (flag2) { bool flag5 = false; if (width >= num) { flag5 = true; } if (y != num17) { flag5 = true; } if ((num13 - num3) > 6f) { flag5 = true; } if (flag5) { this.DrawSmallGroup(num2, num3, y, size); flag2 = false; } } if (width < num) { enterChildren = false; if (!flag2) { flag2 = true; y = num17; num2 = num13; size = 0; } num3 = num14; size++; continue; } int id = iter.id; string path = iter.path; bool flag6 = (path == selectedPropertyPath) && !ghost; if (this.m_SelectedID >= 0) { flag6 &= id == this.m_SelectedID; } flag6 &= threadIdx == this.m_SelectedThread; Color white = Color.white; Color color4 = colors[iter.group % colors.Length]; color4.a = !flag6 ? 0.75f : 1f; if (ghost) { color4.a = 0.4f; white.a = 0.5f; } string name = iter.name; if (flag6) { str2 = name; this.m_SelectedTime = time; this.m_SelectedDur = durationMS; num6 = num17 + 16f; } if (width < 20f) { name = string.Empty; } else { if ((width < 50f) && !flag6) { white.a *= (width - 20f) / 30f; } if (width > 200f) { name = name + string.Format(" ({0:f2}ms)", durationMS); } } GUI.color = color4; GUI.contentColor = white; Rect position = new Rect(num13, num17, width, 14f); GUI.Label(position, name, styles.bar); if ((flag3 || flag4) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object gameObject = EditorUtility.InstanceIDToObject(iter.instanceId); if (gameObject is Component) { gameObject = ((Component) gameObject).gameObject; } if (gameObject != null) { if (flag3) { EditorGUIUtility.PingObject(gameObject.GetInstanceID()); } else if (flag4) { Selection.objects = new List<UnityEngine.Object> { gameObject }.ToArray(); } } Event.current.Use(); } flag2 = false; } } if (flag2) { this.DrawSmallGroup(num2, num3, y, size); } GUI.color = color; GUI.contentColor = contentColor; if ((str2 != null) && (threadIdx == this.m_SelectedThread)) { Rect rect3; GUIContent content = new GUIContent(string.Format((this.m_SelectedDur < 1.0) ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", str2, this.m_SelectedDur)); GUIStyle tooltip = styles.tooltip; Vector2 vector = tooltip.CalcSize(content); float num19 = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + (this.m_SelectedDur * 0.5f), r); if (num19 < r.x) { num19 = r.x + 20f; } if (num19 > r.xMax) { num19 = r.xMax - 20f; } if (((num6 + 6f) + vector.y) < r.yMax) { rect3 = new Rect(num19 - 32f, num6, 50f, 7f); GUI.Label(rect3, GUIContent.none, styles.tooltipArrow); } rect3 = new Rect(num19, num6 + 6f, vector.x, vector.y); if (rect3.xMax > (r.xMax + 20f)) { rect3.x = (r.xMax - rect3.width) + 20f; } if (rect3.yMax > r.yMax) { rect3.y = r.yMax - rect3.height; } if (rect3.y < r.y) { rect3.y = r.y; } GUI.Label(rect3, content, tooltip); } if ((Event.current.type == EventType.MouseDown) && r.Contains(Event.current.mousePosition)) { this.m_Window.ClearSelectedPropertyPath(); this.m_SelectedID = -1; this.m_SelectedThread = threadIdx; Event.current.Use(); } GUI.EndGroup(); }
private void DoProfilerFrame(int frameIndex, Rect fullRect, bool ghost, ref int threadCount, float offset) { ProfilerFrameDataIterator profilerFrameDataIterator = new ProfilerFrameDataIterator(); int threadCount2 = profilerFrameDataIterator.GetThreadCount(frameIndex); if (ghost && threadCount2 != threadCount) { return; } if (!ghost) { threadCount = threadCount2; } for (int i = 0; i < threadCount; i++) { Rect r = fullRect; r.y = this.GetThreadY(fullRect, i, threadCount); r.height = this.GetThreadY(fullRect, i + 1, threadCount) - r.y; profilerFrameDataIterator.SetRoot(frameIndex, i); if (i == 0 && !ghost) { this.DrawGrid(fullRect, threadCount, profilerFrameDataIterator.frameTimeMS); this.HandleFrameSelected(profilerFrameDataIterator.frameTimeMS); } this.DrawProfilingData(profilerFrameDataIterator, r, i, offset, ghost); } }