| 444 | } |
| 445 | |
| 446 | static void ViewportMove(const ScreenCoordsXY& coords, WindowBase* w, Viewport* viewport) |
| 447 | { |
| 448 | // Note: do not do the subtraction and then divide! |
| 449 | // Note: Due to arithmetic shift != /zoom a shift will have to be used |
| 450 | // hopefully when 0x006E7FF3 is finished this can be converted to /zoom. |
| 451 | auto x_diff = viewport->zoom.ApplyInversedTo(viewport->viewPos.x) - viewport->zoom.ApplyInversedTo(coords.x); |
| 452 | auto y_diff = viewport->zoom.ApplyInversedTo(viewport->viewPos.y) - viewport->zoom.ApplyInversedTo(coords.y); |
| 453 | |
| 454 | viewport->viewPos = coords; |
| 455 | |
| 456 | // If no change in viewing area |
| 457 | if ((!x_diff) && (!y_diff)) |
| 458 | return; |
| 459 | |
| 460 | const int32_t left = std::max(viewport->pos.x, 0); |
| 461 | const int32_t top = std::max(viewport->pos.y, 0); |
| 462 | const int32_t right = std::min(left + viewport->width + std::min(viewport->pos.x, 0), ContextGetWidth()); |
| 463 | const int32_t bottom = std::min(top + viewport->height + std::min(viewport->pos.y, 0), ContextGetHeight()); |
| 464 | |
| 465 | if (left >= right || top >= bottom) |
| 466 | return; |
| 467 | |
| 468 | if (DrawingEngineHasDirtyOptimisations()) |
| 469 | { |
| 470 | RenderTarget& rt = DrawingEngineGetRT(); |
| 471 | ViewportShiftPixels(rt, w, { left, top, right, bottom }, { x_diff, y_diff }); |
| 472 | } |
| 473 | else |
| 474 | { |
| 475 | GfxInvalidateScreen(); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | // rct2: 0x006E7A15 |
| 480 | static void ViewportSetUndergroundFlag(int32_t underground, WindowBase* window, Viewport* viewport) |
no test coverage detected