0x004CEC50
| 19 | |
| 20 | // 0x004CEC50 |
| 21 | std::optional<RenderTarget> clipRenderTarget(const RenderTarget& src, const Ui::Rect& newRect) |
| 22 | { |
| 23 | const Ui::Rect oldRect = src.getUiRect(); |
| 24 | Ui::Rect intersect = oldRect.intersection(newRect); |
| 25 | const auto stride = oldRect.size.width + src.pitch; |
| 26 | const int16_t newPitch = stride - intersect.size.width; |
| 27 | auto* newBits = src.bits + (stride * (intersect.origin.y - oldRect.origin.y) + (intersect.origin.x - oldRect.origin.x)); |
| 28 | intersect.origin.x = std::max(0, oldRect.origin.x - newRect.origin.x); |
| 29 | intersect.origin.y = std::max(0, oldRect.origin.y - newRect.origin.y); |
| 30 | RenderTarget newRT{ newBits, static_cast<int16_t>(intersect.origin.x), static_cast<int16_t>(intersect.origin.y), static_cast<int16_t>(intersect.size.width), static_cast<int16_t>(intersect.size.height), newPitch, 0 }; |
| 31 | |
| 32 | if (newRT.width <= 0 || newRT.height <= 0) |
| 33 | { |
| 34 | return {}; |
| 35 | } |
| 36 | return { newRT }; |
| 37 | } |
| 38 | } |
no test coverage detected