use wxBitmap object as m_buffer and not a pointer to it (replaces patch 1582878)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42309 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e3cec970d7
commit
1a9a3ce9a3
@ -43,7 +43,6 @@ public:
|
|||||||
// Default ctor, must subsequently call Init for two stage construction.
|
// Default ctor, must subsequently call Init for two stage construction.
|
||||||
wxBufferedDC()
|
wxBufferedDC()
|
||||||
: m_dc(NULL),
|
: m_dc(NULL),
|
||||||
m_buffer(NULL),
|
|
||||||
m_style(0)
|
m_style(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -52,8 +51,7 @@ public:
|
|||||||
wxBufferedDC(wxDC *dc,
|
wxBufferedDC(wxDC *dc,
|
||||||
const wxBitmap& buffer = wxNullBitmap,
|
const wxBitmap& buffer = wxNullBitmap,
|
||||||
int style = wxBUFFER_CLIENT_AREA)
|
int style = wxBUFFER_CLIENT_AREA)
|
||||||
: m_dc(NULL),
|
: m_dc(NULL)
|
||||||
m_buffer(NULL)
|
|
||||||
{
|
{
|
||||||
Init(dc, buffer, style);
|
Init(dc, buffer, style);
|
||||||
}
|
}
|
||||||
@ -62,9 +60,7 @@ public:
|
|||||||
// (where area is usually something like the size of the window
|
// (where area is usually something like the size of the window
|
||||||
// being buffered)
|
// being buffered)
|
||||||
wxBufferedDC(wxDC *dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA)
|
wxBufferedDC(wxDC *dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA)
|
||||||
: m_dc(NULL),
|
: m_dc(NULL)
|
||||||
m_buffer(NULL)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Init(dc, area, style);
|
Init(dc, area, style);
|
||||||
}
|
}
|
||||||
@ -83,7 +79,7 @@ public:
|
|||||||
{
|
{
|
||||||
InitCommon(dc, style);
|
InitCommon(dc, style);
|
||||||
|
|
||||||
m_buffer = &buffer;
|
m_buffer = buffer;
|
||||||
|
|
||||||
UseBuffer();
|
UseBuffer();
|
||||||
}
|
}
|
||||||
@ -103,7 +99,8 @@ public:
|
|||||||
// blitting to) is destroyed.
|
// blitting to) is destroyed.
|
||||||
void UnMask()
|
void UnMask()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_dc, _T("No underlying DC in wxBufferedDC") );
|
wxCHECK_RET( m_dc, _T("no underlying wxDC?") );
|
||||||
|
wxASSERT_MSG( m_buffer.IsOk(), _T("invalid backing store") );
|
||||||
|
|
||||||
wxCoord x = 0,
|
wxCoord x = 0,
|
||||||
y = 0;
|
y = 0;
|
||||||
@ -111,7 +108,7 @@ public:
|
|||||||
if ( m_style & wxBUFFER_CLIENT_AREA )
|
if ( m_style & wxBUFFER_CLIENT_AREA )
|
||||||
GetDeviceOrigin(&x, &y);
|
GetDeviceOrigin(&x, &y);
|
||||||
|
|
||||||
m_dc->Blit(0, 0, m_buffer->GetWidth(), m_buffer->GetHeight(),
|
m_dc->Blit(0, 0, m_buffer.GetWidth(), m_buffer.GetHeight(),
|
||||||
this, -x, -y );
|
this, -x, -y );
|
||||||
m_dc = NULL;
|
m_dc = NULL;
|
||||||
}
|
}
|
||||||
@ -124,7 +121,7 @@ private:
|
|||||||
// common part of Init()s
|
// common part of Init()s
|
||||||
void InitCommon(wxDC *dc, int style)
|
void InitCommon(wxDC *dc, int style)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !m_dc && !m_buffer, _T("wxBufferedDC already initialised") );
|
wxASSERT_MSG( !m_dc, _T("wxBufferedDC already initialised") );
|
||||||
wxCHECK_RET( dc, _T("can't associate NULL DC with wxBufferedDC") );
|
wxCHECK_RET( dc, _T("can't associate NULL DC with wxBufferedDC") );
|
||||||
|
|
||||||
m_dc = dc;
|
m_dc = dc;
|
||||||
@ -144,8 +141,8 @@ private:
|
|||||||
// could probably be a reference.
|
// could probably be a reference.
|
||||||
wxDC *m_dc;
|
wxDC *m_dc;
|
||||||
|
|
||||||
// the buffer (selected in this DC)
|
// the buffer (selected in this DC), initially invalid
|
||||||
const wxBitmap *m_buffer;
|
wxBitmap m_buffer;
|
||||||
|
|
||||||
// the buffering style
|
// the buffering style
|
||||||
int m_style;
|
int m_style;
|
||||||
|
@ -29,25 +29,21 @@
|
|||||||
|
|
||||||
#include "wx/dcbuffer.h"
|
#include "wx/dcbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// ============================================================================
|
// ----------------------------------------------------------------------------
|
||||||
// wxSharedDCBufferManager
|
// wxSharedDCBufferManager: helper class maintaining backing store bitmap
|
||||||
// Helper class to free shared buffer when the app exists.
|
// ----------------------------------------------------------------------------
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
class wxSharedDCBufferManager
|
class wxSharedDCBufferManager
|
||||||
{
|
{
|
||||||
friend class wxBufferedDC;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
wxSharedDCBufferManager() { }
|
wxSharedDCBufferManager() { }
|
||||||
~wxSharedDCBufferManager() { }
|
~wxSharedDCBufferManager() { }
|
||||||
|
|
||||||
wxBitmap* GetBuffer(int w, int h)
|
wxBitmap GetBuffer(int w, int h)
|
||||||
{
|
{
|
||||||
if ( !m_buffer.IsOk() ||
|
if ( !m_buffer.IsOk() ||
|
||||||
w > m_buffer.GetWidth() ||
|
w > m_buffer.GetWidth() ||
|
||||||
@ -59,11 +55,11 @@ public:
|
|||||||
m_buffer = wxBitmap(w, h);
|
m_buffer = wxBitmap(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
return &m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxBitmap m_buffer;
|
wxBitmap m_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
static wxSharedDCBufferManager gs_sharedDCBufferManager;
|
static wxSharedDCBufferManager gs_sharedDCBufferManager;
|
||||||
@ -75,7 +71,7 @@ static wxSharedDCBufferManager gs_sharedDCBufferManager;
|
|||||||
|
|
||||||
void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h)
|
void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h)
|
||||||
{
|
{
|
||||||
if ( !m_buffer )
|
if ( !m_buffer.IsOk() )
|
||||||
{
|
{
|
||||||
if ( w == -1 || h == -1 )
|
if ( w == -1 || h == -1 )
|
||||||
m_dc->GetSize(&w, &h);
|
m_dc->GetSize(&w, &h);
|
||||||
@ -83,6 +79,6 @@ void wxBufferedDC::UseBuffer(wxCoord w, wxCoord h)
|
|||||||
m_buffer = gs_sharedDCBufferManager.GetBuffer(w, h);
|
m_buffer = gs_sharedDCBufferManager.GetBuffer(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectObject(*m_buffer);
|
SelectObject(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user