]> git.saurik.com Git - wxWidgets.git/commitdiff
avoid creating and immediately destroying a wxGraphicsContext when creating a wxDC...
authorPaul Cornett <paulcor@bullseye.com>
Fri, 13 Jul 2012 16:58:37 +0000 (16:58 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Fri, 13 Jul 2012 16:58:37 +0000 (16:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dcgraph.h
include/wx/gtk/dc.h
src/common/dcgraph.cpp
src/gtk/dc.cpp

index afe88c83d829030f67575e24c3c9896da56fae0f..9f6c178fd367cbbc1da94de03b1d5ac443080a89 100644 (file)
@@ -201,6 +201,10 @@ public:
 #endif // __WXMSW__
 
 protected:
 #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;
     // scaling variables
     bool m_logicalFunctionSupported;
     wxGraphicsMatrix m_matrixOriginal;
index 65944e6a70fbf05050a310a8368698e241abeff9..aa97ecb326658bfb825d55d5dbe4470f5f9ea2ee 100644 (file)
@@ -19,7 +19,9 @@ class wxGTKCairoDCImpl: public wxGCDCImpl
     typedef wxGCDCImpl base_type;
 public:
     wxGTKCairoDCImpl(wxDC* owner);
     typedef wxGCDCImpl base_type;
 public:
     wxGTKCairoDCImpl(wxDC* owner);
+    wxGTKCairoDCImpl(wxDC* owner, int);
     wxGTKCairoDCImpl(wxDC* owner, wxWindow* window);
     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
     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
index 19b8124b77b8d49169facb3bf83278a2ba50caf8..3b49dce031cac84073b59f4d6c920eba148ad99b 100644 (file)
@@ -205,6 +205,13 @@ wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc)
 }
 #endif
 
 }
 #endif
 
+wxGCDCImpl::wxGCDCImpl(wxDC* owner, int)
+   : wxDCImpl(owner)
+{
+    // derived class will set a context
+    Init(NULL);
+}
+
 void wxGCDCImpl::Init(wxGraphicsContext* ctx)
 {
     m_ok = false;
 void wxGCDCImpl::Init(wxGraphicsContext* ctx)
 {
     m_ok = false;
index de3eb8005d55db63d7cd22eb573d0e6eb3fc9145..791961499cb692d5dea1710dce660cf40b1bb84e 100644 (file)
@@ -28,8 +28,15 @@ wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner)
     m_height = 0;
 }
 
     m_height = 0;
 }
 
+wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, int)
+    : base_type(owner, 0)
+{
+    m_width = 0;
+    m_height = 0;
+}
+
 wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
 wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
-    : base_type(owner)
+    : base_type(owner, 0)
 {
     m_window = window;
     m_font = window->GetFont();
 {
     m_window = window;
     m_font = window->GetFont();
@@ -219,6 +226,8 @@ wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window)
         if (x || y)
             SetDeviceLocalOrigin(x, y);
     }
         if (x || y)
             SetDeviceLocalOrigin(x, y);
     }
+    else
+        SetGraphicsContext(wxGraphicsContext::Create());
 }
 //-----------------------------------------------------------------------------
 
 }
 //-----------------------------------------------------------------------------
 
@@ -255,13 +264,7 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
         }
     }
     else
         }
     }
     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)
 //-----------------------------------------------------------------------------
 
 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);
 {
     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)
 }
 
 wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner, wxBitmap& bitmap)
-    : base_type(owner)
+    : base_type(owner, 0)
     , m_bitmap(bitmap)
 {
     Setup();
     , m_bitmap(bitmap)
 {
     Setup();
@@ -345,7 +348,7 @@ void wxMemoryDCImpl::Setup()
 //-----------------------------------------------------------------------------
 
 wxGTKCairoDC::wxGTKCairoDC(cairo_t* cr)
 //-----------------------------------------------------------------------------
 
 wxGTKCairoDC::wxGTKCairoDC(cairo_t* cr)
-    : base_type(new wxGTKCairoDCImpl(this))
+    : base_type(new wxGTKCairoDCImpl(this, 0))
 {
     cairo_reference(cr);
     SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
 {
     cairo_reference(cr);
     SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));