Skip to content

Commit

Permalink
Rely on native double buffering by default in wxSTC
Browse files Browse the repository at this point in the history
To avoid unnecessary buffering, turn off Scintilla buffered drawing
by default on platforms which have native double-buffering already.
  • Loading branch information
a-wi committed Oct 16, 2017
1 parent 2c69d27 commit cb79948
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 8 additions & 7 deletions src/stc/stc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
#include "wx/file.h"
#endif

#ifdef __WXGTK__
#include "wx/dcbuffer.h"
#endif
#include "wx/dcbuffer.h"

#include "ScintillaWX.h"

Expand Down Expand Up @@ -226,6 +224,13 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
// STC doesn't support RTL languages at all
SetLayoutDirection(wxLayout_LeftToRight);

// Rely on native double buffering by default.
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
SetBufferedDraw(false);
#else
SetBufferedDraw(true);
#endif

return true;
}

Expand Down Expand Up @@ -5164,11 +5169,7 @@ void wxStyledTextCtrl::StartStyling(int start, int unused)
// Event handlers

void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
#ifdef __WXGTK__
wxBufferedPaintDC dc(this);
#else
wxPaintDC dc(this);
#endif
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
}

Expand Down
15 changes: 8 additions & 7 deletions src/stc/stc.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
#include "wx/file.h"
#endif

#ifdef __WXGTK__
#include "wx/dcbuffer.h"
#endif
#include "wx/dcbuffer.h"

#include "ScintillaWX.h"

Expand Down Expand Up @@ -226,6 +224,13 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
// STC doesn't support RTL languages at all
SetLayoutDirection(wxLayout_LeftToRight);

// Rely on native double buffering by default.
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
SetBufferedDraw(false);
#else
SetBufferedDraw(true);
#endif

return true;
}

Expand Down Expand Up @@ -679,11 +684,7 @@ void wxStyledTextCtrl::StartStyling(int start, int unused)
// Event handlers

void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
#ifdef __WXGTK__
wxBufferedPaintDC dc(this);
#else
wxPaintDC dc(this);
#endif
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
}

Expand Down

0 comments on commit cb79948

Please sign in to comment.