[ease] [editor] Greatly improve slide redraw performance.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [editor] Greatly improve slide redraw performance.
- Date: Sun, 25 Jul 2010 00:29:11 +0000 (UTC)
commit eb05dd589ddd75f904e81b6c34225d3add444333
Author: Nate Stedman <natesm gmail com>
Date: Sat Jul 24 20:28:47 2010 -0400
[editor] Greatly improve slide redraw performance.
src/ease-color.vala | 16 +++++++++++++
src/ease-gradient.vala | 56 +++++++++++++++++++++++++++++++++++++++++++-
src/ease-slide-actor.vala | 3 +-
src/ease-slide.vala | 53 ++++++++++++++++++++++++++++++++++++++++--
4 files changed, 121 insertions(+), 7 deletions(-)
---
diff --git a/src/ease-color.vala b/src/ease-color.vala
index 0ac068f..4355918 100644
--- a/src/ease-color.vala
+++ b/src/ease-color.vala
@@ -65,6 +65,7 @@ public class Ease.Color : GLib.Object
red_priv = 1;
}
else red_priv = value;
+ if (!silence_changed) changed(this);
}
}
private double red_priv;
@@ -88,6 +89,7 @@ public class Ease.Color : GLib.Object
green_priv = 1;
}
else green_priv = value;
+ if (!silence_changed) changed(this);
}
}
private double green_priv;
@@ -111,6 +113,7 @@ public class Ease.Color : GLib.Object
blue_priv = 1;
}
else blue_priv = value;
+ if (!silence_changed) changed(this);
}
}
private double blue_priv;
@@ -134,6 +137,7 @@ public class Ease.Color : GLib.Object
alpha_priv = 1;
}
else alpha_priv = value;
+ if (!silence_changed) changed(this);
}
}
private double alpha_priv;
@@ -153,10 +157,13 @@ public class Ease.Color : GLib.Object
}
set
{
+ silence_changed = true;
red = value.red / 255f;
green = value.green / 255f;
blue = value.blue / 255f;
alpha = value.alpha / 255f;
+ silence_changed = false;
+ changed(this);
}
}
@@ -177,14 +184,23 @@ public class Ease.Color : GLib.Object
}
set
{
+ silence_changed = true;
red = value.red / 65535f;
green = value.green / 65535f;
blue = value.blue / 65535f;
alpha = 1;
+ silence_changed = false;
+ changed(this);
}
}
/**
+ * Emitted when any of the color's properties is changed.
+ */
+ public signal void changed(Color self);
+ private bool silence_changed;
+
+ /**
* Creates an opaque color.
*/
public Color.rgb(double r, double g, double b)
diff --git a/src/ease-gradient.vala b/src/ease-gradient.vala
index 2a0bee0..7655531 100644
--- a/src/ease-gradient.vala
+++ b/src/ease-gradient.vala
@@ -33,12 +33,42 @@ public class Ease.Gradient : GLib.Object
/**
* The starting { link Color} of the gradient.
*/
- public Color start { get; set; }
+ public Color start
+ {
+ get { return start_priv; }
+ set
+ {
+ if (start_priv != null)
+ {
+ start_priv.changed.disconnect(color_changed);
+ }
+
+ start_priv = value;
+ start_priv.changed.connect(color_changed);
+ changed(this);
+ }
+ }
+ private Color start_priv;
/**
* The ending { link Color} of the gradient.
*/
- public Color end { get; set; }
+ public Color end
+ {
+ get { return end_priv; }
+ set
+ {
+ if (end_priv != null)
+ {
+ end_priv.changed.disconnect(color_changed);
+ }
+
+ end_priv = value;
+ end_priv.changed.connect(color_changed);
+ changed(this);
+ }
+ }
+ private Color end_priv;
/**
* The { link GradientType} of the gradient.
@@ -51,6 +81,11 @@ public class Ease.Gradient : GLib.Object
public double angle { get; set; }
/**
+ * Emitted when the gradient's appearance is changed in any way.
+ */
+ public signal void changed(Gradient self);
+
+ /**
* Returns a copy of the default background gradient.
*/
public static Gradient default_background
@@ -67,6 +102,9 @@ public class Ease.Gradient : GLib.Object
end = end_color;
mode = GradientType.LINEAR;
angle = 0;
+
+ notify["mode"].connect((a, b) => changed(this));
+ notify["angle"].connect((a, b) => changed(this));
}
/**
@@ -77,6 +115,9 @@ public class Ease.Gradient : GLib.Object
this(start_color, end_color);
mode = GradientType.LINEAR_MIRRORED;
angle = 0;
+
+ notify["mode"].connect((a, b) => changed(this));
+ notify["angle"].connect((a, b) => changed(this));
}
/**
@@ -87,6 +128,9 @@ public class Ease.Gradient : GLib.Object
this(start_color, end_color);
mode = GradientType.RADIAL;
angle = 0;
+
+ notify["mode"].connect((a, b) => changed(this));
+ notify["angle"].connect((a, b) => changed(this));
}
/**
@@ -180,6 +224,14 @@ public class Ease.Gradient : GLib.Object
cr.restore();
}
+
+ /**
+ * Signal handler for { link Color.changed} signals.
+ */
+ private void color_changed(Color change)
+ {
+ changed(this);
+ }
}
/**
diff --git a/src/ease-slide-actor.vala b/src/ease-slide-actor.vala
index b2c7704..2afe905 100644
--- a/src/ease-slide-actor.vala
+++ b/src/ease-slide-actor.vala
@@ -173,8 +173,7 @@ public class Ease.SlideActor : Clutter.Group
add_actor(contents);
- // TODO: this completely _destroys_ performance.
- slide.changed.connect((s) => set_background());
+ slide.background_changed.connect((s) => set_background());
}
/**
diff --git a/src/ease-slide.vala b/src/ease-slide.vala
index 79d7f21..8a2d8ad 100644
--- a/src/ease-slide.vala
+++ b/src/ease-slide.vala
@@ -74,7 +74,22 @@ public class Ease.Slide : GLib.Object
* To use this property, { link background_type} must also be set to
* { link BackgroundType.COLOR}.
*/
- public Color? background_color { get; set; }
+ public Color background_color
+ {
+ get { return background_color_priv; }
+ set
+ {
+ if (background_color_priv != null)
+ {
+ background_color_priv.changed.disconnect(bg_changed);
+ }
+
+ background_color_priv = value;
+ background_color_priv.changed.connect(bg_changed);
+ changed(this);
+ }
+ }
+ private Color background_color_priv;
/**
* The background gradient, if this slide uses a gradient for a background.
@@ -82,7 +97,22 @@ public class Ease.Slide : GLib.Object
* To use this property, { link background_type} must also be set to
* { link BackgroundType.GRADIENT}.
*/
- public Gradient? background_gradient { get; set; }
+ public Gradient background_gradient
+ {
+ get { return background_gradient_priv; }
+ set
+ {
+ if (background_gradient_priv != null)
+ {
+ background_gradient_priv.changed.disconnect(bg_changed);
+ }
+
+ background_gradient_priv = value;
+ background_gradient_priv.changed.connect(bg_changed);
+ changed(this);
+ }
+ }
+ private Gradient background_gradient_priv;
/**
* The background image, if this slide uses an image for a background.
@@ -171,9 +201,18 @@ public class Ease.Slide : GLib.Object
public signal void changed(Slide self);
/**
+ * Emitted when the background of this Slide is altered in any way.
+ */
+ public signal void background_changed(Slide self);
+
+ /**
* Create a new Slide.
*/
- public Slide() {}
+ public Slide()
+ {
+ notify["background-type"].connect((a, b) => background_changed(this));
+ notify["background-image"].connect((a, b) => background_changed(this));
+ }
/**
* Create a new Slide assigned to a { link Document}.
@@ -184,6 +223,7 @@ public class Ease.Slide : GLib.Object
*/
public Slide.with_owner(Document owner)
{
+ base();
parent = owner;
}
@@ -203,6 +243,8 @@ public class Ease.Slide : GLib.Object
public Slide.from_master(Slide master, Document? document,
int width, int height, bool is_new)
{
+ base();
+
// set basic properties
transition = master.transition;
transition_time = master.transition_time;
@@ -367,6 +409,11 @@ public class Ease.Slide : GLib.Object
html += "</div>\n";
}
+
+ private void bg_changed(GLib.Object sender)
+ {
+ background_changed(this);
+ }
}
public enum Ease.BackgroundType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]