@@ -26,18 +26,13 @@ namespace RTE {
26
26
m_MSPDs.clear ();
27
27
m_MSPDAverage = 0 ;
28
28
m_CurrentPing = 0 ;
29
- m_IntermediateDrawBitmap = nullptr ;
30
- m_ColorConversionBitmap = nullptr ;
31
29
}
32
30
33
31
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
34
32
35
33
void PerformanceMan::Initialize () {
36
34
m_SimUpdateTimer = std::make_unique<Timer>();
37
35
38
- m_IntermediateDrawBitmap = create_bitmap_ex (8 , 280 , 380 );
39
- m_ColorConversionBitmap = create_bitmap_ex (FrameMan::c_BPP, 280 , 380 );
40
-
41
36
for (int counter = 0 ; counter < PerformanceCounters::PerfCounterCount; ++counter) {
42
37
m_PerfData[counter].fill (0 );
43
38
m_PerfPercentages[counter].fill (0 );
@@ -46,14 +41,6 @@ namespace RTE {
46
41
m_PerfMeasureStop.fill (0 );
47
42
}
48
43
49
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50
-
51
- void PerformanceMan::Destroy () {
52
- destroy_bitmap (m_IntermediateDrawBitmap);
53
- destroy_bitmap (m_ColorConversionBitmap);
54
- Clear ();
55
- }
56
-
57
44
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58
45
59
46
void PerformanceMan::StartPerformanceMeasurement (PerformanceCounters counter) {
@@ -127,54 +114,51 @@ namespace RTE {
127
114
128
115
void PerformanceMan::Draw (BITMAP *bitmapToDrawTo) {
129
116
if (m_ShowPerfStats) {
130
- clear_to_color (m_IntermediateDrawBitmap, ColorKeys::g_MaskColor);
131
- AllegroBitmap intermediateDrawBitmap (m_IntermediateDrawBitmap);
117
+ AllegroBitmap drawBitmap (bitmapToDrawTo);
132
118
133
- GUIFont *guiFont = g_FrameMan.GetLargeFont ();
119
+ GUIFont *guiFont = g_FrameMan.GetLargeFont (true );
134
120
char str[128 ];
135
121
136
122
float fps = 1 .0F / (m_MSPFAverage / 1000 .0F );
137
123
float ups = 1 .0F / (m_MSPSUAverage / 1000 .0F );
138
124
std::snprintf (str, sizeof (str), " FPS: %.0f | UPS: %.0f" , fps, ups);
139
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight, str, GUIFont::Left);
125
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight, str, GUIFont::Left);
140
126
141
127
std::snprintf (str, sizeof (str), " Frame: %.1fms | Update: %.1fms | Draw: %.1fms" , m_MSPFAverage, m_MSPUAverage, m_MSPDAverage);
142
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 10 , str, GUIFont::Left);
128
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 10 , str, GUIFont::Left);
143
129
144
130
std::snprintf (str, sizeof (str), " Time Scale: x%.2f ([1]-, [2]+, [Ctrl+1]Rst)" , g_TimerMan.IsOneSimUpdatePerFrame () ? g_TimerMan.GetSimSpeed () : g_TimerMan.GetTimeScale ());
145
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 20 , str, GUIFont::Left);
131
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 20 , str, GUIFont::Left);
146
132
147
133
std::snprintf (str, sizeof (str), " Real to Sim Cap: %.2f ms ([3]-, [4]+, [Ctrl+3]Rst)" , g_TimerMan.GetRealToSimCap () * 1000 .0F );
148
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 30 , str, GUIFont::Left);
134
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 30 , str, GUIFont::Left);
149
135
150
136
float deltaTime = g_TimerMan.GetDeltaTimeMS ();
151
137
std::snprintf (str, sizeof (str), " DeltaTime: %.2f ms ([5]-, [6]+, [Ctrl+5]Rst)" , deltaTime);
152
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 40 , str, GUIFont::Left);
138
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 40 , str, GUIFont::Left);
153
139
154
140
std::snprintf (str, sizeof (str), " Particles: %li" , g_MovableMan.GetParticleCount ());
155
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 50 , str, GUIFont::Left);
141
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 50 , str, GUIFont::Left);
156
142
157
143
std::snprintf (str, sizeof (str), " Objects: %i" , g_MovableMan.GetKnownObjectsCount ());
158
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 60 , str, GUIFont::Left);
144
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 60 , str, GUIFont::Left);
159
145
160
146
std::snprintf (str, sizeof (str), " MOIDs: %i" , g_MovableMan.GetMOIDCount ());
161
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 70 , str, GUIFont::Left);
147
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 70 , str, GUIFont::Left);
162
148
163
149
std::snprintf (str, sizeof (str), " Sim Updates Since Last Drawn: %i" , g_TimerMan.SimUpdatesSinceDrawn ());
164
- guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 80 , str, GUIFont::Left);
150
+ guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 80 , str, GUIFont::Left);
165
151
166
- if (g_TimerMan.IsOneSimUpdatePerFrame ()) { guiFont->DrawAligned (&intermediateDrawBitmap , c_StatsOffsetX, c_StatsHeight + 90 , " ONE Sim Update Per Frame!" , GUIFont::Left); }
152
+ if (g_TimerMan.IsOneSimUpdatePerFrame ()) { guiFont->DrawAligned (&drawBitmap , c_StatsOffsetX, c_StatsHeight + 90 , " ONE Sim Update Per Frame!" , GUIFont::Left); }
167
153
168
154
if (int totalPlayingChannelCount = 0 , realPlayingChannelCount = 0 ; g_AudioMan.GetPlayingChannelCount (&totalPlayingChannelCount, &realPlayingChannelCount)) {
169
155
std::snprintf (str, sizeof (str), " Sound Channels: %d / %d Real | %d / %d Virtual" , realPlayingChannelCount, g_AudioMan.GetTotalRealChannelCount (), totalPlayingChannelCount - realPlayingChannelCount, g_AudioMan.GetTotalVirtualChannelCount ());
170
156
}
171
- guiFont->DrawAligned (&intermediateDrawBitmap, c_StatsOffsetX, c_StatsHeight + 100 , str, GUIFont::Left);
172
-
173
- if (m_AdvancedPerfStats) { DrawPeformanceGraphs (intermediateDrawBitmap); }
157
+ guiFont->DrawAligned (&drawBitmap, c_StatsOffsetX, c_StatsHeight + 100 , str, GUIFont::Left);
174
158
175
- // Regular blit performs color conversion from 8bpp to 32bpp, then the converted result is drawn masked to the 32bpp target bitmap.
176
- blit (m_IntermediateDrawBitmap, m_ColorConversionBitmap, 0 , 0 , 0 , 0 , m_IntermediateDrawBitmap-> w , m_IntermediateDrawBitmap-> h );
177
- masked_blit (m_ColorConversionBitmap, bitmapToDrawTo, 0 , 0 , 0 , 0 , m_ColorConversionBitmap-> w , m_ColorConversionBitmap-> h );
159
+ if (m_AdvancedPerfStats) {
160
+ DrawPeformanceGraphs (drawBitmap );
161
+ }
178
162
}
179
163
}
180
164
@@ -183,7 +167,7 @@ namespace RTE {
183
167
void PerformanceMan::DrawPeformanceGraphs (AllegroBitmap &bitmapToDrawTo) {
184
168
CalculateSamplePercentages ();
185
169
186
- GUIFont *guiFont = g_FrameMan.GetLargeFont ();
170
+ GUIFont *guiFont = g_FrameMan.GetLargeFont (true );
187
171
char str[128 ];
188
172
189
173
for (int pc = 0 ; pc < PerformanceCounters::PerfCounterCount; ++pc) {
@@ -202,8 +186,8 @@ namespace RTE {
202
186
int graphStart = blockStart + c_GraphsOffsetX;
203
187
204
188
// Draw graph backgrounds.
205
- bitmapToDrawTo.DrawRectangle (c_StatsOffsetX, graphStart, c_MaxSamples, c_GraphHeight, 240 , true );
206
- bitmapToDrawTo.DrawLine (c_StatsOffsetX, graphStart + c_GraphHeight / 2 , c_StatsOffsetX - 1 + c_MaxSamples, graphStart + c_GraphHeight / 2 , 96 );
189
+ bitmapToDrawTo.DrawRectangle (c_StatsOffsetX, graphStart, c_MaxSamples, c_GraphHeight, makecol32 ( 96 , 19 , 32 ), true ); // Palette index 240.
190
+ bitmapToDrawTo.DrawLine (c_StatsOffsetX, graphStart + c_GraphHeight / 2 , c_StatsOffsetX - 1 + c_MaxSamples, graphStart + c_GraphHeight / 2 , makecol32 ( 200 , 206 , 140 )); // Palette index 96.
207
191
208
192
// Draw sample dots.
209
193
int peak = 0 ;
@@ -213,7 +197,7 @@ namespace RTE {
213
197
int value = std::clamp (static_cast <int >(static_cast <float >(m_PerfData[pc][sample]) / (g_TimerMan.GetRealToSimCap () * 1000000 .0F ) * 100 .0F ), 0 , 100 );
214
198
int dotHeight = static_cast <int >(static_cast <float >(c_GraphHeight) / 100 .0F * static_cast <float >(value));
215
199
216
- bitmapToDrawTo.SetPixel (c_StatsOffsetX - 1 + c_MaxSamples - i, graphStart + c_GraphHeight - dotHeight, 13 );
200
+ bitmapToDrawTo.SetPixel (c_StatsOffsetX - 1 + c_MaxSamples - i, graphStart + c_GraphHeight - dotHeight, makecol32 ( 234 , 21 , 7 )); // Palette index 13.
217
201
218
202
if (peak < m_PerfData[pc][sample]) { peak = static_cast <int >(m_PerfData[pc][sample]); }
219
203
0 commit comments