From b34d2c547f4c1082fd719b0268cc7b224f396070 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 31 Jan 2012 00:42:58 +0000 Subject: [PATCH] Use wxAutoBufferedPaintDC rather than manual double-buffering in BaseGrid, as it's simpler and slightly faster Originally committed to SVN as r6389. --- aegisub/src/base_grid.cpp | 23 +++++------------------ aegisub/src/base_grid.h | 1 - 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/aegisub/src/base_grid.cpp b/aegisub/src/base_grid.cpp index 0954b8354..ea7c9b852 100644 --- a/aegisub/src/base_grid.cpp +++ b/aegisub/src/base_grid.cpp @@ -42,8 +42,7 @@ #include #include -#include -#include +#include #include #include #include @@ -91,7 +90,6 @@ BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, , lineHeight(1) // non-zero to avoid div by 0 , holding(false) , scrollBar(new wxScrollBar(this, GRID_SCROLLBAR, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL)) -, bmp(0) , byFrame(false) , extendRow(-1) , active_line(0) @@ -110,6 +108,8 @@ BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, SetSizerAndFit(scrollbarpositioner); + SetBackgroundStyle(wxBG_STYLE_PAINT); + UpdateStyle(); OnHighlightVisibleChange(*OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame")); @@ -140,7 +140,6 @@ BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, BaseGrid::~BaseGrid() { ClearMaps(); - delete bmp; delete context_menu; } @@ -445,13 +444,6 @@ void BaseGrid::OnPaint(wxPaintEvent &) { wxSize cs = GetClientSize(); cs.SetWidth(cs.GetWidth() - scrollBar->GetSize().GetWidth()); - // Prepare bitmap - if (bmp && (bmp->GetWidth() < cs.GetWidth() || bmp->GetHeight() < cs.GetHeight())) { - delete bmp; - bmp = 0; - } - if (!bmp) bmp = new wxBitmap(cs); - // Find which columns need to be repainted bool paint_columns[11]; memset(paint_columns, 0, sizeof paint_columns); @@ -466,13 +458,8 @@ void BaseGrid::OnPaint(wxPaintEvent &) { } } - // Draw bitmap - wxMemoryDC bmpDC; - bmpDC.SelectObject(*bmp); - DrawImage(bmpDC, paint_columns); - - wxPaintDC dc(this); - dc.Blit(wxPoint(0, 0), cs, &bmpDC, wxPoint(0, 0)); + wxAutoBufferedPaintDC dc(this); + DrawImage(dc, paint_columns); } void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) { diff --git a/aegisub/src/base_grid.h b/aegisub/src/base_grid.h index 4e24309a8..07992e38a 100644 --- a/aegisub/src/base_grid.h +++ b/aegisub/src/base_grid.h @@ -69,7 +69,6 @@ class BaseGrid : public wxWindow, public BaseSelectionController { bool holding; ///< Is a drag selection in process? wxFont font; ///< Current grid font wxScrollBar *scrollBar; ///< The grid's scrollbar - wxBitmap *bmp; ///< Back buffer which the grid is rendered into bool byFrame; ///< Should times be displayed as frame numbers /// Row from which the selection shrinks/grows from when selecting via the