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

Function drawRectImpl

src/OpenLoco/src/Graphics/SoftwareDrawingContext.cpp:593–716  ·  view source on GitHub ↗

0x004474BA ax: left bx: right bp: width cx: top dx: bottom ebp: colour | enumValue(flags) edi: rt

Source from the content-addressed store, hash-verified

591 // ebp: colour | enumValue(flags)
592 // edi: rt
593 static void drawRectImpl(const RenderTarget& rt, int16_t left, int16_t top, int16_t right, int16_t bottom, uint8_t colour, RectFlags flags)
594 {
595 if (left > right)
596 {
597 return;
598 }
599 if (top > bottom)
600 {
601 return;
602 }
603 if (right < rt.x)
604 {
605 return;
606 }
607 if (left >= (rt.x + rt.width))
608 {
609 return;
610 }
611 if (bottom < rt.y)
612 {
613 return;
614 }
615 if (top >= rt.y + rt.height)
616 {
617 return;
618 }
619
620 uint32_t crossPattern = 0;
621
622 auto leftX = left - rt.x;
623 if (leftX < 0)
624 {
625 crossPattern ^= leftX;
626 leftX = 0;
627 }
628
629 auto rightX = right - rt.x + 1;
630 if (rightX > rt.width)
631 {
632 rightX = rt.width;
633 }
634
635 auto topY = top - rt.y;
636 if (topY < 0)
637 {
638 crossPattern ^= topY;
639 topY = 0;
640 }
641
642 auto bottomY = bottom - rt.y + 1;
643 if (bottomY > rt.height)
644 {
645 bottomY = rt.height;
646 }
647
648 auto drawRect = Rect::fromLTRB(leftX, topY, rightX, bottomY);
649
650 if (flags == RectFlags::none) // Regular fill

Callers 3

fillRectFunction · 0.85
drawRectFunction · 0.85
fillRectInsetFunction · 0.85

Calls 8

getForColourFunction · 0.85
topMethod · 0.80
leftMethod · 0.80
valueMethod · 0.80
rightMethod · 0.80
bottomMethod · 0.80
heightMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected