From 29e5fe229921088667d0460004d6409dfdd73b9f Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Tue, 5 Jul 2011 10:15:09 +0000 Subject: [PATCH] [uxtheme] - Use double buffering when painting the caption svn path=/branches/GSoC_2011/ThemesSupport/; revision=52544 --- dll/win32/uxtheme/nonclient.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index 8e9947d7e0b..fc85c834652 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -26,6 +26,10 @@ typedef struct _DRAW_CONTEXT BOOL Active; /* wi.dwWindowStatus isn't correct for mdi child windows */ HRGN hRgn; int CaptionHeight; + + /* for double buffering */ + HDC hDCScreen; + HBITMAP hbmpOld; } DRAW_CONTEXT, *PDRAW_CONTEXT; typedef enum @@ -59,6 +63,7 @@ typedef enum { #define BUTTON_GAP_SIZE 2 +#define MENU_BAR_ITEMS_SPACE (12) HFONT hMenuFont = NULL; HFONT hMenuFontBold = NULL; @@ -234,6 +239,29 @@ ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext) } } +static void +ThemeStartBufferedPaint(PDRAW_CONTEXT pcontext, int cx, int cy) +{ + HBITMAP hbmp; + + pcontext->hDCScreen = pcontext->hDC; + pcontext->hDC = CreateCompatibleDC(pcontext->hDCScreen); + hbmp = CreateCompatibleBitmap(pcontext->hDCScreen, cx, cy); + pcontext->hbmpOld = (HBITMAP)SelectObject(pcontext->hDC, hbmp); +} + +static void +ThemeEndBufferedPaint(PDRAW_CONTEXT pcontext, int x, int y, int cx, int cy) +{ + HBITMAP hbmp; + BitBlt(pcontext->hDCScreen, 0, 0, cx, cy, pcontext->hDC, x, y, SRCCOPY); + hbmp = (HBITMAP) SelectObject(pcontext->hDC, pcontext->hbmpOld); + DeleteObject(pcontext->hDC); + DeleteObject(hbmp); + + pcontext->hDC = pcontext->hDCScreen; +} + static void ThemeDrawCaptionButton(PDRAW_CONTEXT pcontext, RECT* prcCurrent, @@ -663,7 +691,9 @@ ThemePaintWindow(PDRAW_CONTEXT pcontext, RECT* prcCurrent) if((pcontext->wi.dwStyle & WS_CAPTION)==WS_CAPTION) { + ThemeStartBufferedPaint(pcontext, prcCurrent->right, pcontext->CaptionHeight); ThemeDrawCaption(pcontext, prcCurrent); + ThemeEndBufferedPaint(pcontext, 0, 0, prcCurrent->right, pcontext->CaptionHeight); ThemeDrawBorders(pcontext, prcCurrent); } else