Use wxAutoBufferedPaintDC rather than manual double-buffering in BaseGrid, as it's simpler and slightly faster
Originally committed to SVN as r6389.
This commit is contained in:
parent
e5f1719d8f
commit
b34d2c547f
2 changed files with 5 additions and 19 deletions
|
@ -42,8 +42,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
#include <wx/dcclient.h>
|
#include <wx/dcbuffer.h>
|
||||||
#include <wx/dcmemory.h>
|
|
||||||
#include <wx/kbdstate.h>
|
#include <wx/kbdstate.h>
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
@ -91,7 +90,6 @@ BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size,
|
||||||
, lineHeight(1) // non-zero to avoid div by 0
|
, lineHeight(1) // non-zero to avoid div by 0
|
||||||
, holding(false)
|
, holding(false)
|
||||||
, scrollBar(new wxScrollBar(this, GRID_SCROLLBAR, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL))
|
, scrollBar(new wxScrollBar(this, GRID_SCROLLBAR, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL))
|
||||||
, bmp(0)
|
|
||||||
, byFrame(false)
|
, byFrame(false)
|
||||||
, extendRow(-1)
|
, extendRow(-1)
|
||||||
, active_line(0)
|
, active_line(0)
|
||||||
|
@ -110,6 +108,8 @@ BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size,
|
||||||
|
|
||||||
SetSizerAndFit(scrollbarpositioner);
|
SetSizerAndFit(scrollbarpositioner);
|
||||||
|
|
||||||
|
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
|
|
||||||
UpdateStyle();
|
UpdateStyle();
|
||||||
OnHighlightVisibleChange(*OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame"));
|
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() {
|
BaseGrid::~BaseGrid() {
|
||||||
ClearMaps();
|
ClearMaps();
|
||||||
delete bmp;
|
|
||||||
delete context_menu;
|
delete context_menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,13 +444,6 @@ void BaseGrid::OnPaint(wxPaintEvent &) {
|
||||||
wxSize cs = GetClientSize();
|
wxSize cs = GetClientSize();
|
||||||
cs.SetWidth(cs.GetWidth() - scrollBar->GetSize().GetWidth());
|
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
|
// Find which columns need to be repainted
|
||||||
bool paint_columns[11];
|
bool paint_columns[11];
|
||||||
memset(paint_columns, 0, sizeof paint_columns);
|
memset(paint_columns, 0, sizeof paint_columns);
|
||||||
|
@ -466,13 +458,8 @@ void BaseGrid::OnPaint(wxPaintEvent &) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw bitmap
|
wxAutoBufferedPaintDC dc(this);
|
||||||
wxMemoryDC bmpDC;
|
DrawImage(dc, paint_columns);
|
||||||
bmpDC.SelectObject(*bmp);
|
|
||||||
DrawImage(bmpDC, paint_columns);
|
|
||||||
|
|
||||||
wxPaintDC dc(this);
|
|
||||||
dc.Blit(wxPoint(0, 0), cs, &bmpDC, wxPoint(0, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
|
|
|
@ -69,7 +69,6 @@ class BaseGrid : public wxWindow, public BaseSelectionController<AssDialogue> {
|
||||||
bool holding; ///< Is a drag selection in process?
|
bool holding; ///< Is a drag selection in process?
|
||||||
wxFont font; ///< Current grid font
|
wxFont font; ///< Current grid font
|
||||||
wxScrollBar *scrollBar; ///< The grid's scrollbar
|
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
|
bool byFrame; ///< Should times be displayed as frame numbers
|
||||||
|
|
||||||
/// Row from which the selection shrinks/grows from when selecting via the
|
/// Row from which the selection shrinks/grows from when selecting via the
|
||||||
|
|
Loading…
Reference in a new issue