COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 04-25-2020, 10:10 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default macOS: Subclassing REAPER windows, WM_PAINT: How to deal with GPU acceleration?

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?
juliansader is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.