avoid creating and immediately destroying a wxGraphicsContext when creating a wxDC with wxGTK3
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
04b2b47a4e
commit
f30b9eed38
@ -201,6 +201,10 @@ public:
|
||||
#endif // __WXMSW__
|
||||
|
||||
protected:
|
||||
// unused int parameter distinguishes this version, which does not create a
|
||||
// wxGraphicsContext, in the expectation that the derived class will do it
|
||||
wxGCDCImpl(wxDC* owner, int);
|
||||
|
||||
// scaling variables
|
||||
bool m_logicalFunctionSupported;
|
||||
wxGraphicsMatrix m_matrixOriginal;
|
||||
|
@ -19,7 +19,9 @@ class wxGTKCairoDCImpl: public wxGCDCImpl
|
||||
typedef wxGCDCImpl base_type;
|
||||
public:
|
||||
wxGTKCairoDCImpl(wxDC* owner);
|
||||
wxGTKCairoDCImpl(wxDC* owner, int);
|
||||
wxGTKCairoDCImpl(wxDC* owner, wxWindow* window);
|
||||
|
||||
virtual void DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask);
|
||||
virtual void DoDrawIcon(const wxIcon& icon, int x, int y);
|
||||
#if wxUSE_IMAGE
|
||||
|
@ -205,6 +205,13 @@ wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc)
|
||||
}
|
||||
#endif
|
||||
|
||||
wxGCDCImpl::wxGCDCImpl(wxDC* owner, int)
|
||||
: wxDCImpl(owner)
|
||||
{
|
||||
// derived class will set a context
|
||||
Init(NULL);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::Init(wxGraphicsContext* ctx)
|
||||
{
|
||||
m_ok = false;
|
||||
|
@ -28,8 +28,15 @@ wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner)
|
||||
m_height = 0;
|
||||
}
|
||||
|
||||
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, int)
|
||||
: base_type(owner, 0)
|
||||
{
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
}
|
||||
|
||||
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
|
||||
: base_type(owner)
|
||||
: base_type(owner, 0)
|
||||
{
|
||||
m_window = window;
|
||||
m_font = window->GetFont();
|
||||
@ -219,6 +226,8 @@ wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window)
|
||||
if (x || y)
|
||||
SetDeviceLocalOrigin(x, y);
|
||||
}
|
||||
else
|
||||
SetGraphicsContext(wxGraphicsContext::Create());
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -255,13 +264,7 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create something that can be used for measuring, but not drawing
|
||||
cairo_t* cr = gdk_cairo_create(gdk_get_default_root_window());
|
||||
cairo_rectangle(cr, 0, 0, 0, 0);
|
||||
cairo_clip(cr);
|
||||
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
|
||||
}
|
||||
SetGraphicsContext(wxGraphicsContext::Create());
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -279,7 +282,7 @@ wxPaintDCImpl::wxPaintDCImpl(wxPaintDC* owner, wxWindow* window)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC* owner)
|
||||
: base_type(owner)
|
||||
: base_type(owner, 0)
|
||||
{
|
||||
GdkWindow* window = gdk_get_default_root_window();
|
||||
m_width = gdk_window_get_width(window);
|
||||
@ -296,7 +299,7 @@ wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner)
|
||||
}
|
||||
|
||||
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner, wxBitmap& bitmap)
|
||||
: base_type(owner)
|
||||
: base_type(owner, 0)
|
||||
, m_bitmap(bitmap)
|
||||
{
|
||||
Setup();
|
||||
@ -345,7 +348,7 @@ void wxMemoryDCImpl::Setup()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxGTKCairoDC::wxGTKCairoDC(cairo_t* cr)
|
||||
: base_type(new wxGTKCairoDCImpl(this))
|
||||
: base_type(new wxGTKCairoDCImpl(this, 0))
|
||||
{
|
||||
cairo_reference(cr);
|
||||
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
|
||||
|
Loading…
Reference in New Issue
Block a user