private Color4 getColour(PerformanceCollectionType type) { switch (type) { default: return(Color4.YellowGreen); case PerformanceCollectionType.SwapBuffer: return(Color4.Red); #if DEBUG case PerformanceCollectionType.Debug: return(Color4.Yellow); #endif case PerformanceCollectionType.Sleep: return(Color4.DarkBlue); case PerformanceCollectionType.Scheduler: return(Color4.HotPink); case PerformanceCollectionType.WndProc: return(Color4.GhostWhite); case PerformanceCollectionType.GLReset: return(Color4.Cyan); } }
private Color4 getColour(PerformanceCollectionType type) { switch (type) { default: case PerformanceCollectionType.Update: return(Color4.YellowGreen); case PerformanceCollectionType.Draw: return(Color4.BlueViolet); case PerformanceCollectionType.SwapBuffer: return(Color4.Red); #if DEBUG case PerformanceCollectionType.Debug: return(Color4.Yellow); #endif case PerformanceCollectionType.Sleep: return(Color4.DarkBlue); case PerformanceCollectionType.Scheduler: return(Color4.HotPink); case PerformanceCollectionType.WndProc: return(Color4.GhostWhite); case PerformanceCollectionType.Empty: return(new Color4(0.1f, 0.1f, 0.1f, 1)); } }
/// <summary> /// End collecting a type of passing time (that was previously started). /// </summary> /// <param name="type"></param> private void endCollecting(PerformanceCollectionType type) { currentCollectionTypeStack.Pop(); if (!currentFrame.CollectedTimes.ContainsKey(type)) { currentFrame.CollectedTimes[type] = 0; } currentFrame.CollectedTimes[type] += consumeStopwatchElapsedTime(); }
private int addArea(FrameStatistics frame, PerformanceCollectionType frameTimeType, int currentHeight, byte[] textureData, int amountSteps) { Trace.Assert(textureData.Length >= HEIGHT * 4, $"textureData is too small ({textureData.Length}) to hold area data."); double elapsedMilliseconds; int drawHeight; if (frameTimeType == PerformanceCollectionType.AmountTypes) { drawHeight = currentHeight; } else if (frame.CollectedTimes.TryGetValue(frameTimeType, out elapsedMilliseconds)) { legendMapping[(int)frameTimeType].Alpha = 1; drawHeight = (int)(elapsedMilliseconds * scale); } else { return(currentHeight); } Color4 col = getColour(frameTimeType); for (int i = currentHeight - 1; i >= 0; --i) { if (drawHeight-- == 0) { break; } bool acceptableRange = (float)currentHeight / HEIGHT > 1 - monitor.FrameAimTime / visible_ms_range; float brightnessAdjust = 1; if (frameTimeType == PerformanceCollectionType.AmountTypes) { int step = amountSteps / HEIGHT; brightnessAdjust *= 1 - i * step / 8f; } else if (acceptableRange) { brightnessAdjust *= 0.8f; } int index = i * 4; textureData[index] = (byte)(255 * col.R * brightnessAdjust); textureData[index + 1] = (byte)(255 * col.G * brightnessAdjust); textureData[index + 2] = (byte)(255 * col.B * brightnessAdjust); textureData[index + 3] = (byte)(255 * col.A); currentHeight--; } return(currentHeight); }
/// <summary> /// Start collecting a type of passing time. /// </summary> public InvokeOnDisposal BeginCollecting(PerformanceCollectionType type) { if (currentCollectionTypeStack.Count > 0) { PerformanceCollectionType t = currentCollectionTypeStack.Peek(); if (!currentFrame.CollectedTimes.ContainsKey(t)) { currentFrame.CollectedTimes[t] = 0; } currentFrame.CollectedTimes[t] += consumeStopwatchElapsedTime(); } currentCollectionTypeStack.Push(type); return(new InvokeOnDisposal(() => endCollecting(type))); }
private Color4 getColour(PerformanceCollectionType type) { Color4 col = default(Color4); switch (type) { default: case PerformanceCollectionType.Update: col = Color4.YellowGreen; break; case PerformanceCollectionType.Draw: col = Color4.BlueViolet; break; case PerformanceCollectionType.SwapBuffer: col = Color4.Red; break; #if DEBUG case PerformanceCollectionType.Debug: col = Color4.Yellow; break; #endif case PerformanceCollectionType.Sleep: col = Color4.DarkBlue; break; case PerformanceCollectionType.Scheduler: col = Color4.HotPink; break; case PerformanceCollectionType.WndProc: col = Color4.GhostWhite; break; case PerformanceCollectionType.Empty: col = new Color4(50, 40, 40, 180); break; } return(col); }
private int addArea(FrameStatistics frame, PerformanceCollectionType frameTimeType, int currentHeight, byte[] textureData) { Debug.Assert(textureData.Length >= HEIGHT * 4, $"textureData is too small ({textureData.Length}) to hold area data."); double elapsedMilliseconds = 0; int drawHeight = 0; if (frameTimeType == PerformanceCollectionType.Empty) { drawHeight = currentHeight; } else if (frame.CollectedTimes.TryGetValue(frameTimeType, out elapsedMilliseconds)) { legendMapping[(int)frameTimeType].Alpha = 1; drawHeight = (int)(elapsedMilliseconds * scale); } else { return(currentHeight); } Color4 col = getColour(frameTimeType); for (int i = currentHeight - 1; i >= 0; --i) { if (drawHeight-- == 0) { break; } int index = i * 4; textureData[index] = (byte)(255 * col.R); textureData[index + 1] = (byte)(255 * col.G); textureData[index + 2] = (byte)(255 * col.B); textureData[index + 3] = (byte)(255 * (frameTimeType == PerformanceCollectionType.Empty ? (col.A * (1 - (int)((i * 4) / HEIGHT) / 8f)) : col.A)); currentHeight--; } return(currentHeight); }