- int base_x = p->x; int base_y = p->y;
- for (int dr = max2(0, 0-p->y); dr < v->height; dr++)
+ // FIXME:
+ // if e.g. granularity is 2, p->x = 2.4 and v->width = 4
+ // then <2, 2.5> will be marked as occupied while <4, 4.5> won't be,
+ // though the variant occupies <2.4, 4,4> and therefore occupies much
+ // more of <4, 4.5> than of <2, 2.5>
+ int base_x = p->x * bitmap_granularity;
+ int base_y = p->y * bitmap_granularity;
+ int max_dr = min2(v->height - 1, (page_height - p->y) * bitmap_granularity);
+ int max_dc = min2(v->width - 1, (page_width - p->x) * bitmap_granularity);
+ for (int dr = max2(0, 0-p->y); dr < max_dr; dr++)