MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Paint

Method Paint

src/video/win32_v.cpp:1230–1272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1228}
1229
1230void VideoDriver_Win32GDI::Paint()
1231{
1232 PerformanceMeasurer framerate(PFE_VIDEO);
1233
1234 if (IsEmptyRect(this->dirty_rect)) return;
1235
1236 HDC dc = GetDC(this->main_wnd);
1237 HDC dc2 = CreateCompatibleDC(dc);
1238
1239 HBITMAP old_bmp = (HBITMAP)SelectObject(dc2, this->dib_sect);
1240 HPALETTE old_palette = SelectPalette(dc, this->gdi_palette, FALSE);
1241
1242 if (_local_palette.count_dirty != 0) {
1243 Blitter *blitter = BlitterFactory::GetCurrentBlitter();
1244
1245 switch (blitter->UsePaletteAnimation()) {
1246 case Blitter::PaletteAnimation::VideoBackend:
1247 this->UpdatePalette(dc2, _local_palette.first_dirty, _local_palette.count_dirty);
1248 break;
1249
1250 case Blitter::PaletteAnimation::Blitter: {
1251 blitter->PaletteAnimate(_local_palette);
1252 break;
1253 }
1254
1255 case Blitter::PaletteAnimation::None:
1256 break;
1257
1258 default:
1259 NOT_REACHED();
1260 }
1261 _local_palette.count_dirty = 0;
1262 }
1263
1264 BitBlt(dc, 0, 0, this->width, this->height, dc2, 0, 0, SRCCOPY);
1265 SelectPalette(dc, old_palette, TRUE);
1266 SelectObject(dc2, old_bmp);
1267 DeleteDC(dc2);
1268
1269 ReleaseDC(this->main_wnd, dc);
1270
1271 this->dirty_rect = {};
1272}
1273
1274#ifdef _DEBUG
1275/* Keep this function here..

Callers 1

RedrawScreenDebugMethod · 0.45

Calls 6

UpdatePaletteMethod · 0.95
IsEmptyRectFunction · 0.85
NOT_REACHEDFunction · 0.85
DrawMouseCursorMethod · 0.80
UsePaletteAnimationMethod · 0.45
PaletteAnimateMethod · 0.45

Tested by

no test coverage detected