| 1547 | } |
| 1548 | |
| 1549 | function contentEndDamageRegion( |
| 1550 | prev: Screen, |
| 1551 | next: Screen, |
| 1552 | ): Rectangle | undefined { |
| 1553 | const sharedHeight = Math.min(prev.height, next.height) |
| 1554 | let region: Rectangle | undefined |
| 1555 | |
| 1556 | for (let y = 0; y < sharedHeight; y += 1) { |
| 1557 | const prevEnd = Math.min(prev.contentEnd[y] ?? 0, prev.width) |
| 1558 | const nextEnd = Math.min(next.contentEnd[y] ?? 0, next.width) |
| 1559 | if (prevEnd === nextEnd) { |
| 1560 | continue |
| 1561 | } |
| 1562 | |
| 1563 | const x = Math.min(prevEnd, nextEnd) |
| 1564 | const right = Math.max(prevEnd, nextEnd) |
| 1565 | if (right <= x) { |
| 1566 | continue |
| 1567 | } |
| 1568 | |
| 1569 | const rowRegion = { x, y, width: right - x, height: 1 } |
| 1570 | region = region ? unionRect(region, rowRegion) : rowRegion |
| 1571 | } |
| 1572 | |
| 1573 | return region |
| 1574 | } |
| 1575 | |
| 1576 | /** |
| 1577 | * Scan for the next cell that differs between two Int32Arrays. |