defer dc screen grab until blit

This commit is contained in:
Sean D'Epagnier 2016-08-26 15:02:39 -04:00 committed by Vadim Zeitlin
parent 694decea6e
commit cc01fbc3c0
8 changed files with 27 additions and 8 deletions

View File

@ -111,6 +111,8 @@ public:
virtual void* GetHandle() const { return (void*) m_qtPainter; }
protected:
virtual QImage *GetQImage() { return m_qtImage; }
QPainter *m_qtPainter;
QImage *m_qtImage;

View File

@ -20,9 +20,6 @@ public:
protected:
wxWindow *m_window;
private:
};

View File

@ -24,8 +24,6 @@ public:
virtual const wxBitmap& GetSelectedBitmap() const;
virtual wxBitmap& GetSelectedBitmap();
protected:
private:
wxBitmap m_selected;
};

View File

@ -17,9 +17,11 @@ public:
~wxScreenDCImpl();
protected:
virtual void DoGetSize(int *width, int *height) const wxOVERRIDE;
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
private:
QImage *GetQImage();
wxDECLARE_ABSTRACT_CLASS(wxScreenDCImpl);
};

View File

@ -745,7 +745,7 @@ bool wxQtDCImpl::DoBlit(wxCoord xdest, wxCoord ydest,
{
wxQtDCImpl *implSource = (wxQtDCImpl*)source->GetImpl();
QImage *qtSource = implSource->m_qtImage;
QImage *qtSource = implSource->GetQImage();
// Not a CHECK on purpose
if ( !qtSource )

View File

@ -31,6 +31,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC *owner )
: wxQtDCImpl( owner )
{
m_window = NULL;
m_qtImage = NULL;
m_ok = false;
m_qtPainter = new QPainter();
}
@ -39,6 +40,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *win )
: wxQtDCImpl( owner )
{
m_window = win;
m_qtImage = NULL;
m_qtPainter = m_window->QtGetPainter();
// if we're not inside a Paint event, painter will invalid
m_ok = m_qtPainter != NULL;

View File

@ -35,6 +35,7 @@ wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *WXUNUSED(dc) )
{
m_qtImage = NULL;
m_ok = false;
m_qtPainter = new QPainter();
}
wxMemoryDCImpl::~wxMemoryDCImpl()

View File

@ -21,7 +21,7 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxWindowDCImpl);
wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner )
: wxWindowDCImpl( owner )
{
m_qtImage = new QImage(QApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId()).toImage());
m_qtImage = NULL;
}
wxScreenDCImpl::~wxScreenDCImpl( )
@ -33,3 +33,20 @@ void wxScreenDCImpl::DoGetSize(int *width, int *height) const
{
wxDisplaySize(width, height);
}
bool wxScreenDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
{
// const_cast<wxScreenDCImpl*>(this)->GetQImage();
// return wxQtDCImpl::DoGetPixel(x, y, col);
x = y = 0;
col = 0;
return false;
}
// defered allocation for blit
QImage *wxScreenDCImpl::GetQImage()
{
if(!m_qtImage)
m_qtImage = new QImage(QApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId()).toImage());
return m_qtImage;
}