Commit ff65ab1
committed
gdi: present bmp_menu via SetDIBitsToDevice instead of BitBlt
The bmp_menu present path was creating a temporary DC, selecting
the DIB section into it, BitBlt-ing through that DC to the
window DC, then tearing the temporary DC down — every frame:
HDC menu_dc = CreateCompatibleDC(gdi->winDC);
if (menu_dc) {
HBITMAP menu_old = (HBITMAP)SelectObject(menu_dc, gdi->bmp_menu);
GdiFlush();
BitBlt(gdi->winDC, ..., menu_dc, ..., SRCCOPY);
SelectObject(menu_dc, menu_old);
DeleteDC(menu_dc);
}
SetDIBitsToDevice does the same thing — copy a DIB to a window
DC at 1:1 scale — but takes the raw pixel pointer directly,
skipping the temporary DC framework entirely. We already keep a
uint32_t* into the DIB pixels (gdi->menu_pixels, populated by
gdi_ensure_menu_surface) so the substitution is straightforward:
GdiFlush();
SetDIBitsToDevice(gdi->winDC,
0, 0, surface_width, surface_height,
0, 0, 0, surface_height,
gdi->menu_pixels, &bmi, DIB_RGB_COLORS);
Per frame this saves a CreateCompatibleDC, two SelectObjects,
and a DeleteDC syscall. The pixel-copy bandwidth is unchanged
(the GDI implementation still has to move surface_width *
surface_height * 4 bytes from system RAM to the window's
displayable surface), but the API path is shorter and avoids
some of GDI's DC-based source-routing overhead.
bmp_menu is allocated at exactly the window surface size so
there's no scaling involved, which is the key precondition for
SetDIBitsToDevice (the no-scaling, simpler cousin of
StretchDIBits). The DIB is top-down (biHeight is negative in
gdi_ensure_menu_surface) and SetDIBitsToDevice supports
top-down DIBs natively, so the bit layout matches without
needing to flip rows.
Compatibility: SetDIBitsToDevice is part of the original Win32
API. Same availability surface as BitBlt itself — Win95, NT
3.5+, Win32s. No regression vs the previous path.
The legacy bmp + WM_PAINT + StretchBlt route (used when no
widgets, no textured menu, no OSD/stats) is untouched — that
path actually does scale (small core frame to window-sized
viewport), so SetDIBitsToDevice doesn't fit there.1 parent b984124 commit ff65ab1
2 files changed
Lines changed: 41 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3106 | 3106 | | |
3107 | 3107 | | |
3108 | 3108 | | |
3109 | | - | |
| 3109 | + | |
| 3110 | + | |
3110 | 3111 | | |
3111 | 3112 | | |
3112 | 3113 | | |
3113 | 3114 | | |
3114 | 3115 | | |
3115 | 3116 | | |
3116 | 3117 | | |
3117 | | - | |
| 3118 | + | |
3118 | 3119 | | |
3119 | | - | |
3120 | | - | |
3121 | | - | |
3122 | | - | |
3123 | | - | |
3124 | | - | |
3125 | | - | |
3126 | | - | |
3127 | | - | |
3128 | | - | |
3129 | | - | |
3130 | | - | |
3131 | | - | |
3132 | | - | |
3133 | | - | |
3134 | | - | |
3135 | | - | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
3136 | 3157 | | |
3137 | 3158 | | |
3138 | 3159 | | |
| |||
0 commit comments