Skip to content

Commit 4a50c5c

Browse files
committed
scripts: dbgbmap[d3].py: Adopted slightly different row prioritization
This still forces the block_rows_ <= height invariant, but also prevents ceiling errors from introducing blank rows. I guess the simplest solution is the best one, eh?
1 parent de7564e commit 4a50c5c

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

scripts/dbgbmap.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4715,19 +4715,21 @@ def writeln(s=''):
47154715
block_cols_ = block_cols
47164716
block_rows_ = mt.ceil(len(bmap) / block_cols)
47174717
else:
4718-
# prioritize rows at low resolution
4719-
block_rows_ = min(len(bmap), max(canvas.height, 1)) # was len(bmap)
4720-
block_cols_ = mt.ceil(len(bmap) / block_rows_) # was 1
47214718
# divide by 2 until we hit our target ratio, this works
47224719
# well for things that are often powers-of-two
4723-
while (abs(((canvas.width/(block_cols_*2))
4724-
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
4725-
- block_ratio)
4726-
< abs(((canvas.width/block_cols_)
4727-
/ max(canvas.height/block_rows_, 1)))
4728-
- block_ratio):
4729-
block_rows_ = mt.ceil(block_rows_ / 2)
4720+
#
4721+
# also prioritize rows at low resolution
4722+
block_cols_ = 1
4723+
block_rows_ = len(bmap)
4724+
while (block_rows_ > canvas.height
4725+
or abs(((canvas.width/(block_cols_*2))
4726+
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
4727+
- block_ratio)
4728+
< abs(((canvas.width/block_cols_)
4729+
/ max(canvas.height/block_rows_, 1)))
4730+
- block_ratio):
47304731
block_cols_ *= 2
4732+
block_rows_ = mt.ceil(block_rows_ / 2)
47314733

47324734
block_width_ = canvas.width / block_cols_
47334735
block_height_ = canvas.height / block_rows_

scripts/dbgbmapd3.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4438,19 +4438,21 @@ def main(disk, output, mroots=None, *,
44384438
block_cols_ = block_cols
44394439
block_rows_ = mt.ceil(len(bmap) / block_cols)
44404440
else:
4441-
# prioritize rows at low resolution
4442-
block_rows_ = min(len(bmap), max(height__, 1)) # was len(bmap)
4443-
block_cols_ = mt.ceil(len(bmap) / block_rows_) # was 1
44444441
# divide by 2 until we hit our target ratio, this works
44454442
# well for things that are often powers-of-two
4446-
while (abs(((width__/(block_cols_*2))
4447-
/ max(height__/mt.ceil(block_rows_/2), 1))
4448-
- block_ratio)
4449-
< abs(((width__/block_cols_)
4450-
/ max(height__/block_rows_, 1)))
4451-
- block_ratio):
4452-
block_rows_ = mt.ceil(block_rows_ / 2)
4443+
#
4444+
# also prioritize rows at low resolution
4445+
block_cols_ = 1
4446+
block_rows_ = len(bmap)
4447+
while (block_rows_ > height__
4448+
or abs(((width__/(block_cols_*2))
4449+
/ max(height__/mt.ceil(block_rows_/2), 1))
4450+
- block_ratio)
4451+
< abs(((width__/block_cols_)
4452+
/ max(height__/block_rows_, 1)))
4453+
- block_ratio):
44534454
block_cols_ *= 2
4455+
block_rows_ = mt.ceil(block_rows_ / 2)
44544456

44554457
block_width_ = width__ / block_cols_
44564458
block_height_ = height__ / block_rows_

0 commit comments

Comments
 (0)