| 193 | } |
| 194 | |
| 195 | void EndConsoleUpdate() |
| 196 | { |
| 197 | HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); |
| 198 | |
| 199 | CONSOLE_SCREEN_BUFFER_INFO info = {}; |
| 200 | GetConsoleScreenBufferInfo(console, &info); |
| 201 | |
| 202 | COORD dstPos; |
| 203 | dstPos.X = 0; |
| 204 | dstPos.Y = 0; |
| 205 | |
| 206 | COORD dstSize; |
| 207 | dstSize.X = info.dwSize.X; |
| 208 | dstSize.Y = 4; // 2 should be enough to catch any presentmon stats line, but 4 is more robust |
| 209 | // to printing with concurrent resizing of the console. |
| 210 | |
| 211 | CHAR_INFO* buffer = new CHAR_INFO [dstSize.X * dstSize.Y]; |
| 212 | |
| 213 | COORD srcPos; |
| 214 | srcPos.X = 0; |
| 215 | srcPos.Y = gWritePosition.Y; |
| 216 | |
| 217 | SMALL_RECT rect; |
| 218 | for ( ; srcPos.Y < info.dwSize.Y; srcPos.Y += dstSize.Y) { |
| 219 | rect.Left = 0; |
| 220 | rect.Top = srcPos.Y; |
| 221 | rect.Right = dstSize.X - 1; |
| 222 | rect.Bottom = srcPos.Y + dstSize.Y - 1; |
| 223 | ReadConsoleOutputW(console, buffer, dstSize, dstPos, &rect); |
| 224 | |
| 225 | uint32_t numChars = (uint32_t) (rect.Bottom - rect.Top + 1) * (rect.Right - rect.Left + 1); |
| 226 | |
| 227 | bool clear = false; |
| 228 | for (uint32_t i = 0; i < numChars; ++i) { |
| 229 | if (buffer[i].Char.UnicodeChar != L' ') { |
| 230 | clear = true; |
| 231 | break; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | if (clear) { |
| 236 | DWORD numCharsWritten; |
| 237 | FillConsoleOutputCharacterW(console, L' ', numChars, srcPos, &numCharsWritten); |
| 238 | assert(numChars == numCharsWritten); |
| 239 | } else { |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | delete[] buffer; |
| 245 | } |
| 246 | |
| 247 | static float CalculateFPSForPrintf(float duration) |
| 248 | { |
no outgoing calls
no test coverage detected