SetRoot() 개인적인 메소드

private SetRoot ( int frame, int threadIdx ) : void
frame int
threadIdx int
리턴 void
예제 #1
0
        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;
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
        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;
                    }
                }
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
 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();
 }
예제 #6
0
        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);
예제 #7
0
        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;
                }
            }
        }
예제 #8
0
        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);
                }
            }
        }
예제 #9
0
        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);
				}
			}
		}
예제 #11
0
        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);
        }
예제 #12
0
        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();
        }
예제 #13
0
        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);
        }
 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 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 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;
     }
   }
 }
예제 #17
0
 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);
     }
 }
예제 #18
0
        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;
            }
        }
예제 #19
0
        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);
                }
            }
        }
예제 #20
0
 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);
         }
     }
 }
예제 #21
0
        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;
            }
        }
예제 #22
0
        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;
        }
예제 #23
0
        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);
        }
		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);
			}
		}