As discussed in the thread
Extension API: Link LICE bitmap to REAPER window, for seamless integration into UI, I am trying to find a *reliable* way for scripts and extensions to draw graphics inside REAPER's windows.
The ReaScriptAPI achieves this by subclassing the target window with a new WindowProc callback function that checks for WM_PAINT messages. If a WM_PAINT is received, the message is first passed to the original window procedure (to re-draw the window) and then an HDC for the window is obtained and the linked LICE bitmap is blitted onto the window:
Code:
// Something along the lines of:
InvalidateRect(hwnd, &clientRect, true); // Make sure that entire window gets redrawn
w.origProc(hwnd, uMsg, wParam, lParam); // Call original window process
HDC windowDC = GetDC(hwnd);
StretchBlt(windowDC, r.left, r.top, r.right, r.bottom, bitmapDC, i.srcx, i.srcy, i.srcw, i.srch, SRCCOPY_USEALPHACHAN); // Blit LICE bitmap onto window
ReleaseDC(hwnd, windowDC);
Unfortunately, some (but not all) macOS have reported that
this doesn't work if "optimized drawing" with GPU acceleration is enabled in REAPER's Preferences -> Advanced UI tweaks, and that the blitted image doesn't appear at all. If optimized drawing is disabled, everything seems to work fine.
Does anyone know what goes on "under the hood" when GPU acceleration is enabled? Is there a clever trick that I can use to get subclassing and LICE_blitting to work reliably with GPU acceleration?