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

Function DrawOverlappedWindow

src/window.cpp:885–937  ·  view source on GitHub ↗

* Generate repaint events for the visible part of window w within the rectangle. * * The function goes recursively upwards in the window stack, and splits the rectangle * into multiple pieces at the window edges, so obscured parts are not redrawn. * * @param w Window that needs to be repainted * @param left Left edge of the rectangle that should be repainted * @param top Top edge of the rec

Source from the content-addressed store, hash-verified

883 * @param bottom Bottom edge of the rectangle that should be repainted
884 */
885static void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom)
886{
887 Window::IteratorToFront it(w);
888 ++it;
889 for (; !it.IsEnd(); ++it) {
890 const Window *v = *it;
891 if (MayBeShown(v) &&
892 right > v->left &&
893 bottom > v->top &&
894 left < v->left + v->width &&
895 top < v->top + v->height) {
896 /* v and rectangle intersect with each other */
897 int x;
898
899 if (left < (x = v->left)) {
900 DrawOverlappedWindow(w, left, top, x, bottom);
901 DrawOverlappedWindow(w, x, top, right, bottom);
902 return;
903 }
904
905 if (right > (x = v->left + v->width)) {
906 DrawOverlappedWindow(w, left, top, x, bottom);
907 DrawOverlappedWindow(w, x, top, right, bottom);
908 return;
909 }
910
911 if (top < (x = v->top)) {
912 DrawOverlappedWindow(w, left, top, right, x);
913 DrawOverlappedWindow(w, left, x, right, bottom);
914 return;
915 }
916
917 if (bottom > (x = v->top + v->height)) {
918 DrawOverlappedWindow(w, left, top, right, x);
919 DrawOverlappedWindow(w, left, x, right, bottom);
920 return;
921 }
922
923 return;
924 }
925 }
926
927 /* Setup blitter, and dispatch a repaint event to window *wz */
928 DrawPixelInfo *dp = _cur_dpi;
929 dp->width = right - left;
930 dp->height = bottom - top;
931 dp->left = left - w->left;
932 dp->top = top - w->top;
933 dp->pitch = _screen.pitch;
934 dp->dst_ptr = BlitterFactory::GetCurrentBlitter()->MoveTo(_screen.dst_ptr, left, top);
935 dp->zoom = ZoomLevel::Min;
936 w->OnPaint();
937}
938
939/**
940 * From a rectangle that needs redrawing, find the windows that intersect with the rectangle.

Callers 1

Calls 4

MayBeShownFunction · 0.85
IsEndMethod · 0.45
MoveToMethod · 0.45
OnPaintMethod · 0.45

Tested by

no test coverage detected