fix: track Black BG changes in background segments for correct DH backfill
This commit is contained in:
@@ -252,6 +252,9 @@ class TeletextCanvas(QWidget):
|
||||
held_char = 0x20 # Space
|
||||
double_height = False
|
||||
|
||||
last_visible_idx = -1
|
||||
bg_segments = [(0, bg)] # Track BG changes: (index, color)
|
||||
|
||||
y = row * self.cell_h
|
||||
|
||||
data = b''
|
||||
@@ -311,12 +314,33 @@ class TeletextCanvas(QWidget):
|
||||
graphics_mode = True
|
||||
elif byte_val == 0x1C: # Black BG
|
||||
bg = COLORS[0]
|
||||
bg_segments.append((c, bg))
|
||||
elif byte_val == 0x1D: # New BG
|
||||
bg = fg
|
||||
bg_segments.append((c, bg))
|
||||
|
||||
elif byte_val == 0x0C: # Normal Height
|
||||
double_height = False
|
||||
elif byte_val == 0x0D: # Double Height
|
||||
double_height = True
|
||||
# Backfill Height if we are in leading controls
|
||||
if last_visible_idx == -1:
|
||||
# Update occlusion mask for 0..c-1
|
||||
for k in range(c):
|
||||
next_occlusion_mask[k] = True
|
||||
|
||||
# Repaint 0..c-1 with DH
|
||||
if draw_bg:
|
||||
# Repaint each cell with its historical BG
|
||||
for k in range(c):
|
||||
# Resolve BG for k
|
||||
cell_bg = bg_segments[0][1]
|
||||
for idx, color in reversed(bg_segments):
|
||||
if idx <= k:
|
||||
cell_bg = color
|
||||
break
|
||||
painter.fillRect(k * self.cell_w, y, self.cell_w, self.cell_h * 2, cell_bg)
|
||||
|
||||
elif byte_val == 0x19: # Contiguous Graphics
|
||||
contiguous = True
|
||||
elif byte_val == 0x1A: # Separated Graphics
|
||||
@@ -326,6 +350,23 @@ class TeletextCanvas(QWidget):
|
||||
elif byte_val == 0x1F: # Release Graphics
|
||||
hold_graphics = False
|
||||
|
||||
# Update visibility tracker
|
||||
# If it's a control code, it's "invisible" (space) UNLESS Held Graphics draws something
|
||||
visible_content = False
|
||||
if is_control:
|
||||
if hold_graphics and graphics_mode:
|
||||
visible_content = True
|
||||
else:
|
||||
# Treat Space (0x20) as "invisible" for backfill purposes
|
||||
# This allows backfilling height over leading spaces in banners
|
||||
if byte_val > 0x20:
|
||||
visible_content = True
|
||||
|
||||
if visible_content:
|
||||
# If this is the first visible char, mark it
|
||||
if last_visible_idx == -1:
|
||||
last_visible_idx = c
|
||||
|
||||
# Record Double Height for next row
|
||||
if double_height and not is_occluded:
|
||||
next_occlusion_mask[c] = True
|
||||
|
||||
Reference in New Issue
Block a user