Commit ddfa229e authored by ogg.k.ogg.k's avatar ogg.k.ogg.k
Browse files

keep track of when the state of a kate overlay changes, so one may

 decide not to render it again when it is not necessary
parent 6d9ceee6
......@@ -40,6 +40,8 @@ public class Item {
private float region_w;
private float region_h;
private boolean dirty = true;
/**
* Create a new item from a Kate event.
*/
......@@ -55,6 +57,8 @@ public class Item {
text = null;
}
}
dirty = false; /* not dirty yet, inactive */
}
/**
......@@ -81,6 +85,8 @@ public class Item {
width = img_width;
height = img_height;
dirty = true;
}
/**
......@@ -90,13 +96,18 @@ public class Item {
public boolean update(Component c, Image img, double t) {
com.fluendo.jkate.Event ev = kin.ev;
if (ev == null) return false;
if (t >= ev.end_time) return false;
if (t < ev.start_time) {
/* early out if we're not within the lifetime of the event */
if (t < ev.start_time) return true;
if (t >= ev.end_time) {
alive = false;
dirty = true;
return false; /* we're done, and will get destroyed */
}
else {
if (!alive) {
alive = true;
dirty = true;
}
Dimension d = new Dimension(img.getWidth(null), img.getHeight(null));
......@@ -134,6 +145,8 @@ public class Item {
setupRegion(c, img);
renderBackground(c, img);
renderText(img);
dirty = false;
}
/**
......@@ -209,4 +222,8 @@ public class Item {
g.dispose();
}
public boolean isDirty() {
return dirty;
}
}
......@@ -25,12 +25,14 @@ import java.awt.*;
public class Renderer {
private Vector items = new Vector();
private boolean dirty = true;
/**
* Add a new event to the renderer.
*/
public void add(com.fluendo.jkate.Event ev) {
items.addElement(new Item(ev));
dirty = true;
}
/**
......@@ -42,8 +44,14 @@ public class Renderer {
boolean ret = ((Item)items.elementAt(n)).update(c, img, t);
if (!ret) {
items.removeElementAt(n);
dirty = true;
--n;
}
else {
if (((Item)items.elementAt(n)).isDirty()) {
dirty = true;
}
}
}
if (items.size() == 0)
return 1;
......@@ -65,6 +73,12 @@ public class Renderer {
((Item)items.elementAt(n)).render(c, img);
}
dirty = false;
return img;
}
public boolean isDirty() {
return dirty;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment