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; } virtual void* GetHandle() const { return (void*) m_qtPainter; }
protected: protected:
virtual QImage *GetQImage() { return m_qtImage; }
QPainter *m_qtPainter; QPainter *m_qtPainter;
QImage *m_qtImage; QImage *m_qtImage;

View File

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

View File

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

View File

@ -17,9 +17,11 @@ public:
~wxScreenDCImpl(); ~wxScreenDCImpl();
protected:
virtual void DoGetSize(int *width, int *height) const wxOVERRIDE; 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); wxDECLARE_ABSTRACT_CLASS(wxScreenDCImpl);
}; };

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxWindowDCImpl);
wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner ) wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner )
: wxWindowDCImpl( owner ) : wxWindowDCImpl( owner )
{ {
m_qtImage = new QImage(QApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId()).toImage()); m_qtImage = NULL;
} }
wxScreenDCImpl::~wxScreenDCImpl( ) wxScreenDCImpl::~wxScreenDCImpl( )
@ -33,3 +33,20 @@ void wxScreenDCImpl::DoGetSize(int *width, int *height) const
{ {
wxDisplaySize(width, height); 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;
}