picker flickers during ambience rain redraws — needs double-buffering #3

Open
opened 2026-04-20 11:49:06 -07:00 by nelsong6 · 0 comments
nelsong6 commented 2026-04-20 11:49:06 -07:00 (Migrated from github.com)

Summary

With the GDI ambience rain layer active (added to frontend/cgo/picker.go), the picker window exhibits mild flicker on each 10 Hz repaint. Nelson can tolerate the current level but it should be smoothed out.

Cause

paintWindow paints directly to the window DC in a single-buffered fashion each WM_PAINT:

  1. FillRect(client, baseBg) — wipes the whole frame
  2. For each filled rain cell: FillRect(cellRect, dropColor) — stamps drops
  3. For each text run: optional bg FillRect (for highlights) + ExtTextOut in transparent mode

At 10 Hz, the visible window briefly shows intermediate states between steps 1–3 before all draws complete. That's the perceptible flicker.

Fix

Double-buffer via a compatible DC + bitmap:

  1. CreateCompatibleDC(hdc) + CreateCompatibleBitmap(hdc, clientW, clientH)
  2. SelectObject(memDC, bmp)
  3. Do all rain + text painting to memDC (no visible flicker because offscreen)
  4. BitBlt(hdc, 0, 0, w, h, memDC, 0, 0, SRCCOPY) — single atomic blit to window
  5. Clean up

Alternative: paint only the dirty region (per invalidated rect) rather than the full client. Useful if rain updates are per-drop deltas instead of full-grid repaints. Current sim returns a full grid from GridCopy() so per-cell dirty tracking would need extra state.

Files

  • frontend/cgo/picker.go — paintWindow function (single biggest change)

Context

Part of the ambience-in-picker feature (GDI rain layer). Flicker is tolerable — filing now so the follow-up is tracked; don't block the main feature landing on this.

## Summary With the GDI ambience rain layer active (added to `frontend/cgo/picker.go`), the picker window exhibits mild flicker on each 10 Hz repaint. Nelson can tolerate the current level but it should be smoothed out. ## Cause `paintWindow` paints directly to the window DC in a single-buffered fashion each WM_PAINT: 1. `FillRect(client, baseBg)` — wipes the whole frame 2. For each filled rain cell: `FillRect(cellRect, dropColor)` — stamps drops 3. For each text run: optional bg `FillRect` (for highlights) + `ExtTextOut` in transparent mode At 10 Hz, the visible window briefly shows intermediate states between steps 1–3 before all draws complete. That's the perceptible flicker. ## Fix Double-buffer via a compatible DC + bitmap: 1. `CreateCompatibleDC(hdc)` + `CreateCompatibleBitmap(hdc, clientW, clientH)` 2. `SelectObject(memDC, bmp)` 3. Do all rain + text painting to `memDC` (no visible flicker because offscreen) 4. `BitBlt(hdc, 0, 0, w, h, memDC, 0, 0, SRCCOPY)` — single atomic blit to window 5. Clean up Alternative: paint only the dirty region (per invalidated rect) rather than the full client. Useful if rain updates are per-drop deltas instead of full-grid repaints. Current sim returns a full grid from `GridCopy()` so per-cell dirty tracking would need extra state. ## Files - `frontend/cgo/picker.go` — `paintWindow` function (single biggest change) ## Context Part of the ambience-in-picker feature (GDI rain layer). Flicker is tolerable — filing now so the follow-up is tracked; don't block the main feature landing on this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/fzt-picker#3
No description provided.