[MSPAINT] Add CachedBufferDIB function and use it

We do caching on buffering paint.
This will improve performance a little.
CORE-18867
This commit is contained in:
Katayama Hirofumi MZ 2023-06-16 08:05:23 +09:00
parent c706222f3f
commit 2f856f6f0d
8 changed files with 73 additions and 9 deletions

View file

@ -17,10 +17,17 @@ CCanvasWindow::CCanvasWindow()
, m_hitSelection(HIT_NONE)
, m_whereHit(HIT_NONE)
, m_ptOrig { -1, -1 }
, m_hbmCached(NULL)
{
::SetRectEmpty(&m_rcNew);
}
CCanvasWindow::~CCanvasWindow()
{
if (m_hbmCached)
::DeleteObject(m_hbmCached);
}
VOID CCanvasWindow::drawZoomFrame(INT mouseX, INT mouseY)
{
// FIXME: Draw the border of the area that is to be zoomed in
@ -95,8 +102,8 @@ VOID CCanvasWindow::DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint)
{
// We use a memory bitmap to reduce flickering
HDC hdcMem = ::CreateCompatibleDC(hDC);
HBITMAP hbm = ::CreateCompatibleBitmap(hDC, rcClient.right, rcClient.bottom);
HGDIOBJ hbmOld = ::SelectObject(hdcMem, hbm);
m_hbmCached = CachedBufferDIB(m_hbmCached, rcClient.right, rcClient.bottom);
HGDIOBJ hbmOld = ::SelectObject(hdcMem, m_hbmCached);
// Fill the background
::FillRect(hdcMem, &rcPaint, (HBRUSH)(COLOR_APPWORKSPACE + 1));
@ -164,7 +171,7 @@ VOID CCanvasWindow::DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint)
rcPaint.right - rcPaint.left, rcPaint.bottom - rcPaint.top,
hdcMem, rcPaint.left, rcPaint.top, SRCCOPY);
::DeleteObject(::SelectObject(hdcMem, hbmOld));
::SelectObject(hdcMem, hbmOld);
::DeleteDC(hdcMem);
}