[libbluray-devel] Simplify dirty rectangle updates

hpi1 git at videolan.org
Sat Mar 30 01:39:08 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Mar 17 10:20:57 2013 +0200| [f39de30848ddd7b76ffb717dd1ce40d2851e5a8f] | committer: hpi1

Simplify dirty rectangle updates

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f39de30848ddd7b76ffb717dd1ce40d2851e5a8f
---

 src/libbluray/bdj/java/java/awt/BDImageBase.java  |   18 +++++++++---------
 src/libbluray/bdj/java/java/awt/BDRootWindow.java |   13 ++++---------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/libbluray/bdj/java/java/awt/BDImageBase.java b/src/libbluray/bdj/java/java/awt/BDImageBase.java
index 5025692..15ff1e0 100644
--- a/src/libbluray/bdj/java/java/awt/BDImageBase.java
+++ b/src/libbluray/bdj/java/java/awt/BDImageBase.java
@@ -77,7 +77,7 @@ class BDImageBase extends Image {
         if (width > 0 && height > 0)
             backBuffer = new int[width * height];
 
-        dirty = new Rectangle(0, 0, width, height);
+        dirty = new Rectangle(width, height);
     }
 
     public void flush() {
@@ -142,6 +142,12 @@ class BDImageBase extends Image {
     public int[] getBdBackBuffer() {
         return backBuffer;
     }
+
+    public int[] getBackBuffer() {
+        System.err.println("**** BDIMAGE GETBACKBUFFER ****");
+        return backBuffer;
+    }
+
     public Rectangle getDirtyRect() {
         return dirty;
     }
@@ -212,10 +218,7 @@ class BDImageBase extends Image {
     public synchronized void setRGB(int x, int y, int rgb) {
         backBuffer[y * width + x] = rgb;
 
-        if (x < dirty.x) dirty.x = x;
-        else if (x > dirty.width) dirty.width = x;
-        if (y < dirty.y) dirty.y = y;
-        else if (y > dirty.height) dirty.height = y;
+        dirty.add(x, y);
     }
 
     public void setRGB(int x, int y, int w, int h, int[] rgbArray, int offset, int scansize) {
@@ -223,10 +226,7 @@ class BDImageBase extends Image {
             System.arraycopy(rgbArray, i * scansize + offset,
                              backBuffer, (y + i) * width + x,
                              w);
-        if (x < dirty.x) dirty.x = x;
-        else if (x + w > dirty.width) dirty.width = x + w;
-        if (y < dirty.y) dirty.y = y;
-        else if (y + h > dirty.height) dirty.height = y + h;
+        dirty.add(new Rectangle(x, y, w, h));
     }
 
     public BufferedImage getSubimage(int x, int y, int w, int h) {
diff --git a/src/libbluray/bdj/java/java/awt/BDRootWindow.java b/src/libbluray/bdj/java/java/awt/BDRootWindow.java
index 21fcfc5..73f8cb3 100644
--- a/src/libbluray/bdj/java/java/awt/BDRootWindow.java
+++ b/src/libbluray/bdj/java/java/awt/BDRootWindow.java
@@ -52,10 +52,7 @@ public class BDRootWindow extends Frame {
 
             Libbluray.updateGraphic(width, height, null);
 
-            dirty.x = 0;
-            dirty.y = 0;
-            dirty.width = width;
-            dirty.height = height;
+            dirty.setBounds(0, 0, width, height);
         }
     }
 
@@ -108,10 +105,8 @@ public class BDRootWindow extends Frame {
             changeCount = 0;
             //Libbluray.updateGraphic(getWidth(), getHeight(), backBuffer, dirty.x, dirty.y, dirty.width, dirty.height);
             Libbluray.updateGraphic(getWidth(), getHeight(), backBuffer);
-            dirty.x = getWidth();
-            dirty.y = getHeight();
-            dirty.width = 0;
-            dirty.height = 0;
+
+            dirty.setBounds(getWidth(), getHeight(), 0, 0);
         }
     }
 
@@ -135,7 +130,7 @@ public class BDRootWindow extends Frame {
     }
 
     private int[] backBuffer = null;
-    private Rectangle dirty;
+    private Rectangle dirty = new Rectangle();
     private int changeCount = 0;
     private Timer timer = new Timer();
     private TimerTask timerTask = null;



More information about the libbluray-devel mailing list