summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-05-23 15:06:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-05-24 10:17:03 +0200
commit55cca83ca3544d3ae82d978b017899ced9833cc5 (patch)
tree56aeba96adad7b94800556072aa8bf72a29886c2
parent50ab65a84ade5a14c2e48667ff6629e4907de35f (diff)
speedup drawing toolbars, cache min-width
doing the style lookup for the minWidth is really very slow in gtk Change-Id: Ic7c44edada8d7205586fe569f30d92d4243642a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152182 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx1
-rw-r--r--vcl/unx/gtk3/salnativewidgets-gtk.cxx16
2 files changed, 8 insertions, 9 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index c0a032863ea4..2fc66ace5ece 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -201,6 +201,7 @@ private:
static GtkStyleContext *mpRadioMenuItemRadioStyle;
static GtkStyleContext *mpSeparatorMenuItemStyle;
static GtkStyleContext *mpSeparatorMenuItemSeparatorStyle;
+ static gint mnVerticalSeparatorMinWidth;
#if !GTK_CHECK_VERSION(4, 0, 0)
static tools::Rectangle NWGetScrollButtonRect( ControlPart nPart, tools::Rectangle aAreaRect );
diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index 425c642d45fd..a531a59527db 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -91,6 +91,7 @@ GtkStyleContext* GtkSalGraphics::mpRadioMenuItemStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpRadioMenuItemRadioStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpSeparatorMenuItemStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpSeparatorMenuItemSeparatorStyle = nullptr;
+gint GtkSalGraphics::mnVerticalSeparatorMinWidth = 0;
#if !GTK_CHECK_VERSION(4, 0, 0)
static void style_context_get_margin(GtkStyleContext *pContext, GtkBorder *pMargin)
@@ -1531,17 +1532,11 @@ static gfloat getArrowSize(GtkStyleContext* context)
namespace
{
- void draw_vertical_separator(GtkStyleContext *context, cairo_t *cr, const tools::Rectangle& rControlRegion)
+ void draw_vertical_separator(GtkStyleContext *context, cairo_t *cr, const tools::Rectangle& rControlRegion, gint nSeparatorWidth)
{
tools::Long nX = 0;
tools::Long nY = 0;
- gint nSeparatorWidth = 1;
-
- gtk_style_context_get(context,
- gtk_style_context_get_state(context),
- "min-width", &nSeparatorWidth, nullptr);
-
gint nHalfSeparatorWidth = nSeparatorWidth / 2;
gint nHalfRegionWidth = rControlRegion.GetWidth() / 2;
@@ -1854,14 +1849,14 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
break;
case RenderType::ToolbarSeparator:
{
- draw_vertical_separator(context, cr, rControlRegion);
+ draw_vertical_separator(context, cr, rControlRegion, mnVerticalSeparatorMinWidth);
break;
}
case RenderType::Separator:
if (nPart == ControlPart::SeparatorHorz)
draw_horizontal_separator(context, cr, rControlRegion);
else
- draw_vertical_separator(context, cr, rControlRegion);
+ draw_vertical_separator(context, cr, rControlRegion, mnVerticalSeparatorMinWidth);
break;
case RenderType::Arrow:
gtk_render_arrow(context, cr,
@@ -2920,6 +2915,9 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
GtkToolItem *item = gtk_separator_tool_item_new();
gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), item, -1);
mpToolbarSeparatorStyle = gtk_widget_get_style_context(GTK_WIDGET(item));
+ gtk_style_context_get(mpToolbarSeparatorStyle,
+ gtk_style_context_get_state(mpToolbarSeparatorStyle),
+ "min-width", &mnVerticalSeparatorMinWidth, nullptr);
GtkWidget *pButton = gtk_button_new();
item = gtk_tool_button_new(pButton, nullptr);