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

Function FillDrawPixelInfo

src/gfx.cpp:1568–1612  ·  view source on GitHub ↗

* Set up a clipping area for only drawing into a certain area. To do this, * Fill a DrawPixelInfo object with the supplied relative rectangle, backup * the original (calling) _cur_dpi and assign the just returned DrawPixelInfo * _cur_dpi. When you are done, give restore _cur_dpi's original value * @param *n the DrawPixelInfo that will be the clipping rectangle box allowed * for drawing * @pa

Source from the content-addressed store, hash-verified

1566 * get some nasty results
1567 */
1568bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
1569{
1570 Blitter *blitter = BlitterFactory::GetCurrentBlitter();
1571 const DrawPixelInfo *o = _cur_dpi;
1572
1573 n->zoom = ZoomLevel::Min;
1574
1575 assert(width > 0);
1576 assert(height > 0);
1577
1578 if ((left -= o->left) < 0) {
1579 width += left;
1580 if (width <= 0) return false;
1581 n->left = -left;
1582 left = 0;
1583 } else {
1584 n->left = 0;
1585 }
1586
1587 if (width > o->width - left) {
1588 width = o->width - left;
1589 if (width <= 0) return false;
1590 }
1591 n->width = width;
1592
1593 if ((top -= o->top) < 0) {
1594 height += top;
1595 if (height <= 0) return false;
1596 n->top = -top;
1597 top = 0;
1598 } else {
1599 n->top = 0;
1600 }
1601
1602 n->dst_ptr = blitter->MoveTo(o->dst_ptr, left, top);
1603 n->pitch = o->pitch;
1604
1605 if (height > o->height - top) {
1606 height = o->height - top;
1607 if (height <= 0) return false;
1608 }
1609 n->height = height;
1610
1611 return true;
1612}
1613
1614/**
1615 * Update cursor dimension.

Callers 15

DrawWidgetMethod · 0.70
DrawScrollingStatusTextFunction · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawEditBoxMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawWidgetMethod · 0.70
DrawRoadVehImageFunction · 0.70
DrawWidgetMethod · 0.70

Calls 1

MoveToMethod · 0.45

Tested by

no test coverage detected