From e2022449d9a94c84a1224a53dc776a02fc357fbf Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 1 Jul 2013 21:34:37 -0700 Subject: [PATCH] Use gil in ColourButton rather than wxMemoryDC Basic drawing with wxMemoryDC is relatively slow. --- aegisub/src/colour_button.cpp | 9 ++++----- aegisub/src/colour_button.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/aegisub/src/colour_button.cpp b/aegisub/src/colour_button.cpp index 7483aa1d7..60925454b 100644 --- a/aegisub/src/colour_button.cpp +++ b/aegisub/src/colour_button.cpp @@ -21,7 +21,7 @@ #include "compat.h" #include "dialog_colorpicker.h" -#include +#include wxDEFINE_EVENT(EVT_COLOR, wxThreadEvent); @@ -45,9 +45,8 @@ ColourButton::ColourButton(wxWindow *parent, wxSize const& size, bool alpha, agi } void ColourButton::UpdateBitmap() { - wxMemoryDC dc; - dc.SelectObject(bmp); - dc.SetBrush(wxBrush(to_wx(colour))); - dc.DrawRectangle(0, 0, bmp.GetWidth(), bmp.GetHeight()); + using namespace boost::gil; + fill_pixels(interleaved_view(bmp.GetWidth(), bmp.GetHeight(), (bgr8_pixel_t*)bmp.GetData(), 3 * bmp.GetWidth()), + bgr8_pixel_t(colour.r, colour.g, colour.b)); SetBitmapLabel(bmp); } diff --git a/aegisub/src/colour_button.h b/aegisub/src/colour_button.h index 2a334352d..a35a9821a 100644 --- a/aegisub/src/colour_button.h +++ b/aegisub/src/colour_button.h @@ -25,7 +25,7 @@ wxDECLARE_EVENT(EVT_COLOR, wxThreadEvent); /// A button which displays a currently-selected color and lets the user pick /// a new color when clicked class ColourButton: public wxButton { - wxBitmap bmp; ///< The button's bitmap label + wxImage bmp; ///< The button's bitmap label agi::Color colour; ///< The current colour /// Update the bitmap label after the color is changed