[murrine] Fixed progressbar rendering bug on smal rounded sizes. Performance boost
- From: Andrea Cimitan <acimitan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [murrine] Fixed progressbar rendering bug on smal rounded sizes. Performance boost
- Date: Thu, 5 Aug 2010 10:48:55 +0000 (UTC)
commit 6500a82b52b0aa73f7a83ee22180e37925832bf0
Author: Andrea Cimitan <andrea cimitan gmail com>
Date: Thu Aug 5 11:48:07 2010 +0100
Fixed progressbar rendering bug on smal rounded sizes. Performance boost
src/murrine_draw.c | 28 ++++++++++++++--------------
src/murrine_draw_rgba.c | 28 ++++++++++++++--------------
src/murrine_style.c | 11 -----------
3 files changed, 28 insertions(+), 39 deletions(-)
---
diff --git a/src/murrine_draw.c b/src/murrine_draw.c
index 9468c70..bac84e3 100644
--- a/src/murrine_draw.c
+++ b/src/murrine_draw.c
@@ -874,24 +874,28 @@ murrine_draw_progressbar_fill (cairo_t *cr,
rotate_mirror_translate (cr, M_PI/2, x, y+width, TRUE, FALSE);
}
- roundness = MIN (widget->roundness-widget->xthickness, (height-2.0)/2.0);
+ roundness = MIN (widget->roundness-widget->xthickness, height/2.0);
+ int yos = 0;
+ if ((2*roundness > width) && roundness > 0)
+ {
+ int h = height*sin((M_PI*(width))/(4*roundness));
+ roundness = round(width/2.0);
+ yos = 0.5+(height-h)/2.0;
+ height = h;
+ }
stroke_width = height*2;
x_step = (((float)stroke_width/10)*offset);
cairo_save (cr);
- murrine_rounded_rectangle_closed (cr, 2, 1, width-4+roundness, height-2,
- roundness-1, MRN_CORNER_TOPLEFT | MRN_CORNER_BOTTOMLEFT);
- cairo_clip (cr);
- murrine_rounded_rectangle_closed (cr, 2-roundness, 1, width-4+roundness, height-2,
- roundness-1, MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMRIGHT);
+ murrine_rounded_rectangle_closed (cr, 2, 1+yos, width-4, height-2, roundness-1, widget->corners);
cairo_clip (cr);
- cairo_rectangle (cr, 2, 1, width-4, height-2);
+ cairo_rectangle (cr, 2, 1+yos, width-4, height-2);
murrine_draw_glaze (cr, &fill,
widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
- widget->mrn_gradient, widget, 2, 1, width-4, height-2,
+ widget->mrn_gradient, widget, 2, 1+yos, width-4, height-2,
roundness, widget->corners, TRUE);
switch (progressbar->style)
@@ -945,17 +949,13 @@ murrine_draw_progressbar_fill (cairo_t *cr,
cairo_save (cr);
- murrine_rounded_rectangle_closed (cr, 1, 0, width-2+roundness, height,
- roundness-1, MRN_CORNER_TOPLEFT | MRN_CORNER_BOTTOMLEFT);
- cairo_clip (cr);
- murrine_rounded_rectangle_closed (cr, 1-roundness, 0, width-2+roundness, height,
- roundness-1, MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMRIGHT);
+ murrine_rounded_rectangle_closed (cr, 0.5, -0.5+yos, width-1, height+1, roundness-1, widget->corners);
cairo_clip (cr);
/* Draw border */
murrine_mix_color (&border, &fill, 0.28, &border);
murrine_draw_border (cr, &border,
- 1.5, 0.5, width-3, height-1,
+ 1.5, 0.5+yos, width-3, height-1,
roundness, widget->corners,
widget->mrn_gradient, 1.0);
diff --git a/src/murrine_draw_rgba.c b/src/murrine_draw_rgba.c
index 4bf9b96..04e20dc 100644
--- a/src/murrine_draw_rgba.c
+++ b/src/murrine_draw_rgba.c
@@ -701,7 +701,15 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
rotate_mirror_translate (cr, M_PI/2, x, y+width, TRUE, FALSE);
}
- roundness = MIN (widget->roundness-widget->xthickness, (height-2.0)/2.0);
+ roundness = MIN (widget->roundness-widget->xthickness, height/2.0);
+ int yos = 0;
+ if ((2*roundness > width) && roundness > 0)
+ {
+ int h = height*sin((M_PI*(width))/(4*roundness));
+ roundness = round(width/2.0);
+ yos = 0.5+(height-h)/2.0;
+ height = h;
+ }
stroke_width = height*2;
x_step = (((float)stroke_width/10)*offset);
@@ -709,18 +717,14 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- murrine_rounded_rectangle_closed (cr, 2, 1, width-4+roundness, height-2,
- roundness, MRN_CORNER_TOPLEFT | MRN_CORNER_BOTTOMLEFT);
- cairo_clip (cr);
- murrine_rounded_rectangle_closed (cr, 2-roundness, 1, width-4+roundness, height-2,
- roundness, MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMRIGHT);
+ murrine_rounded_rectangle_closed (cr, 2, 1+yos, width-4, height-2, roundness-1, widget->corners);
cairo_clip (cr);
- cairo_rectangle (cr, 2, 1, width-4, height-2);
+ cairo_rectangle (cr, 2, 1+yos, width-4, height-2);
murrine_draw_glaze (cr, &fill,
widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
- widget->mrn_gradient, widget, 2, 1, width-4, height-2,
+ widget->mrn_gradient, widget, 2, 1+yos, width-4, height-2,
roundness, widget->corners, TRUE);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
@@ -778,17 +782,13 @@ murrine_rgba_draw_progressbar_fill (cairo_t *cr,
cairo_save (cr);
- murrine_rounded_rectangle_closed (cr, 1, 0, width-2+roundness, height,
- roundness, MRN_CORNER_TOPLEFT | MRN_CORNER_BOTTOMLEFT);
- cairo_clip (cr);
- murrine_rounded_rectangle_closed (cr, 1-roundness, 0, width-2+roundness, height,
- roundness, MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMRIGHT);
+ murrine_rounded_rectangle_closed (cr, 0.5, -0.5+yos, width-1, height+1, roundness-1, widget->corners);
cairo_clip (cr);
/* Draw border */
murrine_mix_color (&border, &fill, 0.28, &border);
murrine_draw_border (cr, &border,
- 1.5, 0.5, width-3, height-1,
+ 1.5, 0.5+yos, width-3, height-1,
roundness, widget->corners,
widget->mrn_gradient, 1.0);
cairo_restore (cr);
diff --git a/src/murrine_style.c b/src/murrine_style.c
index fc290a4..6d7beb5 100644
--- a/src/murrine_style.c
+++ b/src/murrine_style.c
@@ -1131,17 +1131,6 @@ murrine_style_draw_box (DRAW_ARGS)
else
progressbar.orientation = MRN_ORIENTATION_LEFT_TO_RIGHT;
-/* if (gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget)) > 0.98)*/
-/* {*/
-/* colors->spot[1].r = 0.5;*/
-/* colors->spot[1].g = 1.0;*/
-/* colors->spot[1].b = 0.5;*/
-
-/* colors->spot[2].r = 0.2;*/
-/* colors->spot[2].g = 0.5;*/
-/* colors->spot[2].b = 0.2;*/
-/* }*/
-
if (!params.ltr)
{
if (progressbar.orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]