[gtk+] renderbackground: Minimize style lookups
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] renderbackground: Minimize style lookups
- Date: Fri, 20 Oct 2017 14:27:30 +0000 (UTC)
commit 99026d2df8ceb0989cfb0cafcfe91d73a5ef7f4e
Author: Timm Bäder <mail baedert org>
Date: Thu Oct 19 15:22:00 2017 +0200
renderbackground: Minimize style lookups
Move the early returns up so we don't look up all those css values for
no reason.
gtk/gtkrenderbackground.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index 8e87e9e..0d3f31a 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -334,9 +334,9 @@ gtk_theming_background_paint_layer (GtkThemingBackground *bg,
}
static void
-gtk_theming_background_snapshot_layer (GtkThemingBackground *bg,
- guint idx,
- GtkSnapshot *snapshot)
+gtk_theming_background_snapshot_layer (const GtkThemingBackground *bg,
+ guint idx,
+ GtkSnapshot *snapshot)
{
GtkCssRepeatStyle hrepeat, vrepeat;
const GtkCssValue *pos, *repeat;
@@ -345,32 +345,38 @@ gtk_theming_background_snapshot_layer (GtkThemingBackground *bg,
double image_width, image_height;
double width, height;
- pos = _gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_POSITION), idx);
- repeat = _gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_REPEAT), idx);
- hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
- vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
image = _gtk_css_image_value_get_image (
_gtk_css_array_value_get_nth (
gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE),
idx));
+ if (image == NULL)
+ return;
+
+ pos = _gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_POSITION), idx);
+ repeat = _gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_REPEAT), idx);
+ hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
+ vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
+
+
origin = &bg->boxes[
_gtk_css_area_value_get (
_gtk_css_array_value_get_nth (
gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BACKGROUND_ORIGIN),
idx))];
- clip = &bg->boxes[
- _gtk_css_area_value_get (
- _gtk_css_array_value_get_nth (
- gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_CLIP),
- idx))];
width = origin->bounds.size.width;
height = origin->bounds.size.height;
- if (image == NULL || width <= 0 || height <= 0)
+ if (width <= 0 || height <= 0)
return;
+ clip = &bg->boxes[
+ _gtk_css_area_value_get (
+ _gtk_css_array_value_get_nth (
+ gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_CLIP),
+ idx))];
+
_gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (gtk_css_style_get_value (bg->style,
GTK_CSS_PROPERTY_BACKGROUND_SIZE), idx),
image,
width,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]