Revision: 4034
          http://vexi.svn.sourceforge.net/vexi/?rev=4034&view=rev
Author:   clrg
Date:     2011-02-13 22:50:07 +0000 (Sun, 13 Feb 2011)

Log Message:
-----------
Minor tidy up of DirtyList

Modified Paths:
--------------
    trunk/org.vexi-core.main/src/main/java/org/vexi/util/DirtyList.java

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/util/DirtyList.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/util/DirtyList.java 
2011-02-13 22:27:02 UTC (rev 4033)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/util/DirtyList.java 
2011-02-13 22:50:07 UTC (rev 4034)
@@ -25,25 +25,27 @@
 
     public final int num() { return numdirties; }
 
-    /** grows the array */
-    private final void grow() {
-        int[] newdirties = new int[dirties.length * 2];
-        System.arraycopy(dirties, 0, newdirties, 0, numdirties * 4);
-        dirties = newdirties;
+    /** Checks the given size and, if necessary, grows the array */
+    private final void size(int size) {
+        if (size >= dirties.length) {
+            int[] newdirties = new int[dirties.length * 2];
+            System.arraycopy(dirties, 0, newdirties, 0, numdirties * 4);
+            dirties = newdirties;
+        }
     }
 
     /** 
      *  Pseudonym for running a new dirty() request against the entire dirties 
list
      *  (x,y) represents the topleft coordinate and (w,h) the bottomright 
coordinate 
      */
-    public final void dirty(int x, int y, int w, int h) { dirty(x, y, w, h, 
0); }
+    public final synchronized void dirty(int x, int y, int w, int h) { 
dirty(x, y, w, h, 0); }
 
     /** 
      *  Add a new rectangle to the dirty list; returns false if the
      *  region fell completely within an existing rectangle or set of
      *  rectangles (i.e. did not expand the dirty area)
      */
-    private synchronized void dirty(int x, int y, int w, int h, int ind) {
+    private void dirty(int x, int y, int w, int h, int ind) {
         int _n;
         if (w<x || h<y) {
             return;
@@ -59,118 +61,140 @@
             int _y = dirties[_n+1];
             int _w = dirties[_n+2];
             int _h = dirties[_n+3];
+            
+//            if (close(x, _x) && close(w, _w)) {
+//                if (close(h, _y)) {
+//                    Math.min(x, _x), Math.max(w, _w)
+//                }
+//                if (close(y, _h)) {
+//                    
+//                }
+//            }
 
-            // new region is outside of existing region
             if (x >= _w || y >= _h || w <= _x || h <= _y) {
+                // new region is outside of existing region
                 continue;
             }
 
-            // new region starts to the left of existing region
             if (x < _x) {
-                // new region overlaps at least the top-left corner of 
existing region
+                // new region starts to the left of existing region
+                
                 if (y < _y) {
-                    // new region overlaps entire width of existing region
+                    // new region overlaps at least the top-left corner of 
existing region
+                    
                     if (w > _w) {
-                        // new region contains existing region
+                        // new region overlaps entire width of existing region
+                        
                         if (h > _h) {
+                            // new region contains existing region
                             dirties[_n] = -1;
                             continue;
+                        }// else {
                         // new region contains top of existing region
-                        } else {
-                            dirties[_n+1] = h;
-                            continue;
-                        }
-                    // new region overlaps to the left of existing region
+                        dirties[_n+1] = h;
+                        continue;
+                        
                     } else {
-                        // new region contains left of existing region
+                        // new region overlaps to the left of existing region
+                        
                         if (h > _h) {
+                            // new region contains left of existing region
                             dirties[_n] = w;
                             continue;
+                        }// else {
                         // new region overlaps top-left corner of existing 
region
-                        } else {
-                            dirty(x, y, w, _y, i+1);
-                            dirty(x, _y, _x, h, i+1);
-                            return;
-                        }
+                        dirty(x, y, w, _y, i+1);
+                        dirty(x, _y, _x, h, i+1);
+                        return;
+                        
                     }
-                // new region starts within the vertical range of existing 
region
                 } else {
-                    // new region horizontally overlaps existing region
+                    // new region starts within the vertical range of existing 
region
+                    
                     if (w > _w) {
-                        // new region contains bottom of existing region
+                        // new region horizontally overlaps existing region
+                        
                         if (h > _h) {
+                            // new region contains bottom of existing region
                             dirties[_n+3] = y;
                             continue;
+                        }// else {
                         // new region overlaps to the left and right of 
existing region
-                        } else {
-                            dirty(x, y, _x, h, i+1);
-                            dirty(_w, y, w, h, i+1);
-                            return;
-                        }
-                    // new region ends within horizontal range of existing 
region
+                        dirty(x, y, _x, h, i+1);
+                        dirty(_w, y, w, h, i+1);
+                        return;
+                        
                     } else {
-                        // new region overlaps bottom-left corner of existing 
region
+                        // new region ends within horizontal range of existing 
region
+                        
                         if (h > _h) {
+                            // new region overlaps bottom-left corner of 
existing region
                             dirty(x, y, _x, h, i+1);
                             dirty(_x, _h, w, h, i+1);
                             return;
-                        }
+                        }// else {
                         // existing region contains right part of new region
                         w = _x;
                         continue;
                     }
                 }
-            // new region starts within the horizontal range of existing region
             } else {
-                // new region starts above existing region
+                // new region starts within the horizontal range of existing 
region
+                
                 if (y < _y) {
-                    // new region overlaps at least top-right of existing 
region
+                    // new region starts above existing region
+                    
                     if (w > _w) {
-                        // new region contains the right of existing region
+                        // new region overlaps at least top-right of existing 
region
+                        
                         if (h > _h) {
+                            // new region contains the right of existing region
                             dirties[_n+2] = x;
                             continue;
+                        }// else {
                         // new region overlaps top-right of existing region
-                        } else {
-                            dirty(x, y, w, _y, i+1);
-                            dirty(_w, _y, w, h, i+1);
-                            return;
-                        }
-                    // new region is horizontally contained within existing 
region
+                        dirty(x, y, w, _y, i+1);
+                        dirty(_w, _y, w, h, i+1);
+                        return;
+                        
                     } else {
-                        // new region overlaps to the above and below of 
existing region
+                        // new region is horizontally contained within 
existing region
+                        
                         if (h > _h) {
+                            // new region overlaps to the above and below of 
existing region
                             dirty(x, y, w, _y, i+1);
                             dirty(x, _h, w, h, i+1);
                             return;
-                        }
+                        }// else {
                         // existing region contains bottom part of new region
                         h = _y;
                         continue;
                     }
-                // new region starts within existing region
                 } else {
-                    // new region overlaps at least to the right of existing 
region
+                    // new region starts within existing region
+                    
                     if (w > _w) {
-                        // new region overlaps bottom-right corner of existing 
region
+                        // new region overlaps at least to the right of 
existing region
+                        
                         if (h > _h) {
+                            // new region overlaps bottom-right corner of 
existing region
                             dirty(x, _h, w, h, i+1);
                             dirty(_w, y, w, _h, i+1);
                             return;
-                        }
+                        }// else {
                         // existing region contains left part of new region
                         x = _w;
                         continue;
-                    // new region is horizontally contained within existing 
region
                     } else {
-                        // existing region contains top part of new region
+                        // new region is horizontally contained within 
existing region
+                        
                         if (h > _h) {
+                            // existing region contains top part of new region
                             y = _h;
                             continue;
+                        }// else {
                         // new region is contained within existing region
-                        } else {
-                            return;
-                        }
+                        return;
                     }
                 }
             }
@@ -178,9 +202,7 @@
 
         // region is valid; store it for rendering
         _n = numdirties*4;
-        if (_n == dirties.length) {
-            grow();
-        }
+        size(_n);
         dirties[_n] = x;
         dirties[_n+1] = y;
         dirties[_n+2] = w;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to