diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-28 11:03:32 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-28 11:03:32 -0400 |
| commit | b32573a4fe30fc23b1867ebb1ef473546dfcd4f0 (patch) | |
| tree | 7467914a60cdd569d7e9b0b742319bf279136371 | |
| parent | ff4f0ec25e180301db396c201fd2b91ce52622fe (diff) | |
Fixed up Area on Windows to always draw the background regardless of the size of the clipping rectangle on the Go side and to not send extraneous WM_ERASEBKGND. This will be needed for having Areas draw the background.
| -rw-r--r-- | redo/area_windows.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/redo/area_windows.c b/redo/area_windows.c index 4793138..80ba2e6 100644 --- a/redo/area_windows.c +++ b/redo/area_windows.c @@ -42,19 +42,12 @@ static void paintArea(HWND hwnd, void *data) intptr_t dx, dy; int hscroll, vscroll; - // TRUE here indicates a - if (GetUpdateRect(hwnd, &xrect, TRUE) == 0) + // FALSE here indicates don't send WM_ERASEBKGND + if (GetUpdateRect(hwnd, &xrect, FALSE) == 0) return; // no update rect; do nothing getScrollPos(hwnd, &hscroll, &vscroll); - i = doPaint(&xrect, hscroll, vscroll, data, &dx, &dy); - if (i == NULL) // cliprect empty - return; - // don't convert to BRGA just yet; see below - - // TODO don't do the above, but always draw the background color? - hdc = BeginPaint(hwnd, &ps); if (hdc == NULL) xpanic("error beginning Area repaint", GetLastError()); @@ -82,6 +75,10 @@ static void paintArea(HWND hwnd, void *data) if (FillRect(rdc, &rrect, areaBackgroundBrush) == 0) xpanic("error filling off-screen rendering bitmap with the system background color", GetLastError()); + i = doPaint(&xrect, hscroll, vscroll, data, &dx, &dy); + if (i == NULL) // cliprect empty + goto nobitmap; // we need to blit the background no matter what + // now we need to shove realbits into a bitmap // technically bitmaps don't know about alpha; they just ignore the alpha byte // AlphaBlend(), however, sees it - see http://msdn.microsoft.com/en-us/library/windows/desktop/dd183352%28v=vs.85%29.aspx @@ -125,6 +122,15 @@ static void paintArea(HWND hwnd, void *data) blendfunc) == FALSE) xpanic("error alpha-blending image returned by AreaHandler.Paint() onto background", GetLastError()); + // clean up after idc/ibitmap here because of the goto nobitmap + if (SelectObject(idc, previbitmap) != ibitmap) + xpanic("error reverting HDC for image returned by AreaHandler.Paint() to original HBITMAP", GetLastError()); + if (DeleteObject(ibitmap) == 0) + xpanic("error deleting HBITMAP for image returned by AreaHandler.Paint()", GetLastError()); + if (DeleteDC(idc) == 0) + xpanic("error deleting HDC for image returned by AreaHandler.Paint()", GetLastError()); + +nobitmap: // and finally we can just blit that into the window if (BitBlt(hdc, xrect.left, xrect.top, xrect.right - xrect.left, xrect.bottom - xrect.top, rdc, 0, 0, // from the rdc's origin @@ -132,16 +138,10 @@ static void paintArea(HWND hwnd, void *data) xpanic("error blitting Area image to Area", GetLastError()); // now to clean up - if (SelectObject(idc, previbitmap) != ibitmap) - xpanic("error reverting HDC for image returned by AreaHandler.Paint() to original HBITMAP", GetLastError()); if (SelectObject(rdc, prevrbitmap) != rbitmap) xpanic("error reverting HDC for off-screen rendering to original HBITMAP", GetLastError()); - if (DeleteObject(ibitmap) == 0) - xpanic("error deleting HBITMAP for image returned by AreaHandler.Paint()", GetLastError()); if (DeleteObject(rbitmap) == 0) xpanic("error deleting HBITMAP for off-screen rendering", GetLastError()); - if (DeleteDC(idc) == 0) - xpanic("error deleting HDC for image returned by AreaHandler.Paint()", GetLastError()); if (DeleteDC(rdc) == 0) xpanic("error deleting HDC for off-screen rendering", GetLastError()); |
