[baobab] chart: Do not use an offscreen surface anymore



commit 17f4463b9519c3dda158579f9483843dbd9789fa
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Tue Feb 17 16:45:57 2015 +0100

    chart: Do not use an offscreen surface anymore
    
    It's causing problems when hidpi scale factor is bigger than 1.
    As for the background color, we can fetch it from the toplevel window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742394

 src/baobab-chart.vala      |   14 +-------------
 src/baobab-ringschart.vala |    9 +++++----
 2 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/src/baobab-chart.vala b/src/baobab-chart.vala
index 21d20c6..d2d8d46 100644
--- a/src/baobab-chart.vala
+++ b/src/baobab-chart.vala
@@ -426,19 +426,7 @@ namespace Baobab {
                     }
                 }
 
-                // Here we use an intermediate offscreen surface because in this way draw_chart()
-                // can obtain transparent pixels just by painting with CAIRO_OPERATOR_CLEAR,
-                // instead of relying on the knowledge of the background color as defined by the theme.
-                Gtk.Allocation allocation;
-                get_allocation (out allocation);
-
-                var source = new Cairo.ImageSurface (Cairo.Format.ARGB32, allocation.width, 
allocation.height);
-                var source_cr = new Cairo.Context (source);
-
-                draw_chart (source_cr);
-
-                cr.set_source_surface (source, 0, 0);
-                cr.paint ();
+                draw_chart (cr);
             }
 
             return false;
diff --git a/src/baobab-ringschart.vala b/src/baobab-ringschart.vala
index 7d00c3b..c87de29 100644
--- a/src/baobab-ringschart.vala
+++ b/src/baobab-ringschart.vala
@@ -235,8 +235,10 @@ namespace Baobab {
             get_allocation (out allocation);
 
             var context = get_style_context ();
+            context.save ();
 
             var border_color = context.get_border_color (Gtk.StateFlags.NORMAL);
+            var bg_color = get_toplevel ().get_style_context ().get_background_color (Gtk.StateFlags.NORMAL);
 
             var center_x = allocation.width / 2;
             var center_y = allocation.height / 2;
@@ -273,12 +275,9 @@ namespace Baobab {
 
                 Gdk.cairo_set_source_rgba (cr, fill_color);
                 cr.fill_preserve ();
-
-                cr.set_operator (Cairo.Operator.CLEAR);
+                Gdk.cairo_set_source_rgba (cr, bg_color);
                 cr.stroke ();
 
-                cr.set_operator (Cairo.Operator.OVER);
-
                 if (ringsitem.continued) {
                     Gdk.cairo_set_source_rgba (cr, border_color);
                     cr.set_line_width (3);
@@ -286,6 +285,8 @@ namespace Baobab {
                     cr.stroke ();
                 }
             }
+
+            context.restore ();
         }
 
         protected override void calculate_item_geometry (ChartItem item) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]