Avoid using double buffering unnecessarily in wxAuiNotebook

We don't need to do double buffering on our own if the underlying
platform always does it anyhow, as macOS and GTK 3 do.
This commit is contained in:
Vadim Zeitlin
2022-02-12 15:09:02 +00:00
parent 0401fe21f7
commit d00aeb5813

View File

@@ -21,6 +21,7 @@
#ifndef WX_PRECOMP
#include "wx/settings.h"
#include "wx/dcbuffer.h" // just for wxALWAYS_NATIVE_DOUBLE_BUFFER
#include "wx/dcclient.h"
#include "wx/dcmemory.h"
#include "wx/frame.h"
@@ -414,6 +415,13 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
if (m_rect.IsEmpty())
return;
size_t i;
size_t page_count = m_pages.GetCount();
size_t button_count = m_buttons.GetCount();
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
wxDC& dc = *raw_dc;
#else
wxMemoryDC dc;
// use the same layout direction as the window DC uses to ensure that the
@@ -421,16 +429,13 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
dc.SetLayoutDirection(raw_dc->GetLayoutDirection());
wxBitmap bmp;
size_t i;
size_t page_count = m_pages.GetCount();
size_t button_count = m_buttons.GetCount();
// create off-screen bitmap
bmp.Create(m_rect.GetWidth(), m_rect.GetHeight(),*raw_dc);
dc.SelectObject(bmp);
if (!dc.IsOk())
return;
#endif
// ensure we show as many tabs as possible
while (m_tabOffset > 0 && IsTabVisible(page_count-1, m_tabOffset-1, &dc, wnd))
@@ -707,9 +712,11 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
}
#if !wxALWAYS_NATIVE_DOUBLE_BUFFER
raw_dc->Blit(m_rect.x, m_rect.y,
m_rect.GetWidth(), m_rect.GetHeight(),
&dc, 0, 0);
#endif
}
// Is the tab visible?