MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / clipRenderTarget

Function clipRenderTarget

src/OpenLoco/src/Graphics/RenderTarget.cpp:21–37  ·  view source on GitHub ↗

0x004CEC50

Source from the content-addressed store, hash-verified

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}

Callers 15

drawBackgroundMethod · 0.85
drawFunction · 0.85
drawScrollFunction · 0.85
drawPreviewImageFunction · 0.85
drawDescriptionFunction · 0.85
drawDatDetailsFunction · 0.85
drawSearchBoxFunction · 0.85
drawScrollFunction · 0.85
drawSearchBoxFunction · 0.85
drawFunction · 0.85
drawScrollFunction · 0.85
drawFunction · 0.85

Calls 2

intersectionMethod · 0.80
getUiRectMethod · 0.45

Tested by

no test coverage detected