banshee r4667 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView src/Libraries/Hyena.Gui/Hyena.Gui
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4667 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView src/Libraries/Hyena.Gui/Hyena.Gui
- Date: Wed, 8 Oct 2008 18:15:58 +0000 (UTC)
Author: abock
Date: Wed Oct 8 18:15:57 2008
New Revision: 4667
URL: http://svn.gnome.org/viewvc/banshee?rev=4667&view=rev
Log:
* banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/LargeTrackInfoDisplay.cs:
* banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs:
Like I fixed for the ListView yesterday, do not recreate the pango
layouts on each expose; this is a sligh perf improvement, but mostly,
it stops a huge leak (BGO #555365). Thanks to Michael Monreal for
helping to track this one down!
* banshee/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs: Always
create a new layout and return it instead of accepting it as a ref
parameter; dispose the context after we request it from
PangoCairoHelper
* banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
Updated to reflect API change of CairoExtensions.CreateLayout
* banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs:
Added a virtual OnThemeChanged to simplify things for sub classes so
they don't have to worry about awkward logic often necessary with
OnStyleSet
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/LargeTrackInfoDisplay.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs Wed Oct 8 18:15:57 2008
@@ -45,6 +45,8 @@
private uint popup_timeout_id;
private bool in_popup;
private bool in_thumbnail_region;
+ private Pango.Layout first_line_layout;
+ private Pango.Layout second_line_layout;
public ClassicTrackInfoDisplay () : base ()
{
@@ -132,6 +134,19 @@
layout.Dispose ();
return 2 * height;
}
+
+ protected override void OnThemeChanged ()
+ {
+ if (first_line_layout != null) {
+ first_line_layout.Dispose ();
+ first_line_layout = null;
+ }
+
+ if (second_line_layout != null) {
+ second_line_layout.Dispose ();
+ second_line_layout = null;
+ }
+ }
#endregion
@@ -147,14 +162,21 @@
double x = Allocation.X + offset;
double width = Allocation.Width - offset;
int fl_width, fl_height, sl_width, sl_height;
+ int pango_width = (int)(width * Pango.Scale.PangoScale);
+
+ if (first_line_layout == null) {
+ first_line_layout = CairoExtensions.CreateLayout (this, cr);
+ first_line_layout.Ellipsize = Pango.EllipsizeMode.End;
+ }
+
+ if (second_line_layout == null) {
+ second_line_layout = CairoExtensions.CreateLayout (this, cr);
+ second_line_layout.Ellipsize = Pango.EllipsizeMode.End;
+ }
// Set up the text layouts
- Pango.Layout first_line_layout = null;
- CairoExtensions.CreateLayout (this, cr, ref first_line_layout);
- first_line_layout.Width = (int)(width * Pango.Scale.PangoScale);
- first_line_layout.Ellipsize = Pango.EllipsizeMode.End;
-
- Pango.Layout second_line_layout = first_line_layout.Copy ();
+ first_line_layout.Width = pango_width;
+ second_line_layout.Width = pango_width;
// Compute the layout coordinates
first_line_layout.SetMarkup (GetFirstLineText (track));
@@ -178,16 +200,11 @@
}
if (!renderArtistAlbum) {
- first_line_layout.Dispose ();
- second_line_layout.Dispose ();
return;
}
cr.MoveTo (x, y + fl_height);
PangoCairoHelper.ShowLayout (cr, second_line_layout);
-
- first_line_layout.Dispose ();
- second_line_layout.Dispose ();
}
#endregion
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/LargeTrackInfoDisplay.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/LargeTrackInfoDisplay.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/LargeTrackInfoDisplay.cs Wed Oct 8 18:15:57 2008
@@ -42,6 +42,9 @@
{
private Gdk.Rectangle text_alloc;
private Dictionary<ImageSurface, Surface> surfaces = new Dictionary<ImageSurface, Surface> ();
+ private Pango.Layout first_line_layout;
+ private Pango.Layout second_line_layout;
+ private Pango.Layout third_line_layout;
public LargeTrackInfoDisplay ()
{
@@ -82,6 +85,24 @@
base.OnSizeAllocated (allocation);
QueueDraw ();
}
+
+ protected override void OnThemeChanged ()
+ {
+ if (first_line_layout != null) {
+ first_line_layout.Dispose ();
+ first_line_layout = null;
+ }
+
+ if (second_line_layout != null) {
+ second_line_layout.Dispose ();
+ second_line_layout = null;
+ }
+
+ if (third_line_layout != null) {
+ third_line_layout.Dispose ();
+ third_line_layout = null;
+ }
+ }
protected override void RenderCoverArt (Cairo.Context cr, ImageSurface image)
{
@@ -162,6 +183,7 @@
Gdk.Rectangle alloc = RenderAllocation;
int width = ArtworkSizeRequest;
int fl_width, fl_height, sl_width, sl_height, tl_width, tl_height;
+ int pango_width = (int)(width * Pango.Scale.PangoScale);
string first_line = GetFirstLineText (track);
@@ -177,19 +199,31 @@
line.Substring (split_pos, line.Length - split_pos));
}
- // Set up the text layouts
- Pango.Layout first_line_layout = null;
- CairoExtensions.CreateLayout (this, cr, ref first_line_layout);
- first_line_layout.Width = (int)(width * Pango.Scale.PangoScale);
- first_line_layout.Ellipsize = Pango.EllipsizeMode.End;
- first_line_layout.Alignment = Pango.Alignment.Right;
-
- int base_size = first_line_layout.FontDescription.Size;
-
- Pango.Layout second_line_layout = first_line_layout.Copy ();
- Pango.Layout third_line_layout = first_line_layout.Copy ();
+ if (first_line_layout == null) {
+ first_line_layout = CairoExtensions.CreateLayout (this, cr);
+ first_line_layout.Ellipsize = Pango.EllipsizeMode.End;
+ first_line_layout.Alignment = Pango.Alignment.Right;
+
+ int base_size = first_line_layout.FontDescription.Size;
+ first_line_layout.FontDescription.Size = (int)(base_size * Pango.Scale.XLarge);
+ }
+
+ if (second_line_layout == null) {
+ second_line_layout = CairoExtensions.CreateLayout (this, cr);
+ second_line_layout.Ellipsize = Pango.EllipsizeMode.End;
+ second_line_layout.Alignment = Pango.Alignment.Right;
+ }
+
+ if (third_line_layout == null) {
+ third_line_layout = CairoExtensions.CreateLayout (this, cr);
+ third_line_layout.Ellipsize = Pango.EllipsizeMode.End;
+ third_line_layout.Alignment = Pango.Alignment.Right;
+ }
- first_line_layout.FontDescription.Size = (int)(base_size * Pango.Scale.XLarge);
+ // Set up the text layouts
+ first_line_layout.Width = pango_width;
+ second_line_layout.Width = pango_width;
+ third_line_layout.Width = pango_width;
// Compute the layout coordinates
first_line_layout.SetMarkup (first_line);
@@ -214,9 +248,6 @@
}
if (!renderArtistAlbum) {
- first_line_layout.Dispose ();
- second_line_layout.Dispose ();
- third_line_layout.Dispose ();
return;
}
@@ -225,10 +256,6 @@
cr.MoveTo (text_alloc.X, text_alloc.Y + fl_height + sl_height);
PangoCairoHelper.ShowLayout (cr, third_line_layout);
-
- first_line_layout.Dispose ();
- second_line_layout.Dispose ();
- third_line_layout.Dispose ();
}
protected override void Invalidate ()
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs Wed Oct 8 18:15:57 2008
@@ -181,6 +181,12 @@
missing_video_image.Destroy ();
missing_video_image = null;
}
+
+ OnThemeChanged ();
+ }
+
+ protected virtual void OnThemeChanged ()
+ {
}
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs Wed Oct 8 18:15:57 2008
@@ -92,8 +92,9 @@
cairo_context = CairoHelper.Create (evnt.Window);
if (pango_layout == null) {
- CairoExtensions.CreateLayout (this, cairo_context, ref pango_layout);
+ pango_layout = CairoExtensions.CreateLayout (this, cairo_context);
}
+
cell_context.Context = cairo_context;
cell_context.Layout = pango_layout;
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs Wed Oct 8 18:15:57 2008
@@ -48,20 +48,21 @@
public static class CairoExtensions
{
- public static void CreateLayout (Gtk.Widget widget, Cairo.Context cairo_context, ref Pango.Layout layout)
+ public static Pango.Layout CreateLayout (Gtk.Widget widget, Cairo.Context cairo_context)
{
- if (layout != null) {
- layout.Dispose ();
- }
-
- layout = PangoCairoHelper.CreateLayout (cairo_context);
+ Pango.Layout layout = PangoCairoHelper.CreateLayout (cairo_context);
layout.FontDescription = widget.PangoContext.FontDescription.Copy ();
double resolution = widget.Screen.Resolution;
if (resolution != -1) {
Pango.Context context = PangoCairoHelper.LayoutGetContext (layout);
PangoCairoHelper.ContextSetResolution (context, resolution);
+ context.Dispose ();
}
+
+ Log.Debug ("Creating Pango.Layout, configuring Cairo.Context");
+
+ return layout;
}
public static Surface CreateSurfaceForPixbuf (Cairo.Context cr, Gdk.Pixbuf pixbuf)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]