Cache HDC used for painting for the entire duration of WM_PAINT processing.

This fixes a long standing problem with 2 wxPaintDC created one after another
(and not with nested lifetimes, which was handled by the caching mechanism
previously used) not working correctly. And as this was exactly what happened
when handling wxEVT_PAINT for wxScrolled, it also fixes drawing artefacts when
using scrolled windows.

Closes #14757.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72938 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-11-10 00:52:54 +00:00
parent 80791c37b5
commit ddc8faa9e1
3 changed files with 139 additions and 142 deletions

View File

@@ -19,16 +19,8 @@
#include "wx/dc.h"
#include "wx/msw/dc.h"
#include "wx/dcclient.h"
#include "wx/dynarray.h"
// ----------------------------------------------------------------------------
// array types
// ----------------------------------------------------------------------------
// this one if used by wxPaintDC only
struct WXDLLIMPEXP_FWD_CORE wxPaintDCInfo;
WX_DECLARE_EXPORTED_OBJARRAY(wxPaintDCInfo, wxArrayDCInfo);
class wxPaintDCInfo;
// ----------------------------------------------------------------------------
// DC classes
@@ -86,11 +78,13 @@ public:
// find the entry for this DC in the cache (keyed by the window)
static WXHDC FindDCInCache(wxWindow* win);
protected:
static wxArrayDCInfo ms_cache;
// This must be called by the code handling WM_PAINT to remove the DC
// cached for this window for the duration of this message processing.
static void EndPaint(wxWindow *win);
// find the entry for this DC in the cache (keyed by the window)
wxPaintDCInfo *FindInCache(size_t *index = NULL) const;
protected:
// Find the DC for this window in the cache, return NULL if not found.
static wxPaintDCInfo *FindInCache(wxWindow* win);
DECLARE_CLASS(wxPaintDCImpl)
wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl);