vcl/inc/unx/gtk/gtkgdi.hxx            |    1 +
 vcl/unx/gtk3/salnativewidgets-gtk.cxx |   16 +++++++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 55cca83ca3544d3ae82d978b017899ced9833cc5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue May 23 15:06:07 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 24 10:17:03 2023 +0200

    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.gran...@collabora.co.uk>

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);

Reply via email to