Revision: 4012
          http://vexi.svn.sourceforge.net/vexi/?rev=4012&view=rev
Author:   clrg
Date:     2011-01-31 16:35:30 +0000 (Mon, 31 Jan 2011)

Log Message:
-----------
Only blit once per render cycle -> faster rendering again

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

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java   
2011-01-31 14:40:02 UTC (rev 4011)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java   
2011-01-31 16:35:30 UTC (rev 4012)
@@ -810,25 +810,54 @@
             }
             final int rwidth = root.width;
             final int rheight = root.height;
+            // REMARK: whilst in theory only blitting the dirty areas
+            // would seem more efficient, in practise it results in a
+            // large slowdown due to a delay in processing each blit,
+            // so instead we just blit a single area covering all the
+            // dirty parts (NB: original implementation below)
+            int x = root.width;
+            int y = root.height;
+            int w = 0;
+            int h = 0;
             for (int i = 0; i < numregions; i++) {
                 // consumed dirty areas are marked with a -1
                 if (dirt[4*i]<0) {
                     continue;
                 }
                 // handle confirmed dirty areas
-                int x = dirt[4*i];
-                int y = dirt[4*i+1];
-                int w = dirt[4*i+2];
-                int h = dirt[4*i+3];
-                if (x < 0) x = 0;
-                if (y < 0) y = 0;
-                if (w > rwidth) w = rwidth;
-                if (h > rheight) h = rheight;
-                if (w <= x || h <= y) {
-                    continue;
-                }
-                blit(backbuffer, x, y, x, y, w, h);
+                x = Math.min(x, dirt[4*i]);
+                y = Math.min(y, dirt[4*i+1]);
+                w = Math.max(w, dirt[4*i+2]);
+                h = Math.max(h, dirt[4*i+3]);
             }
+            if (x < 0) x = 0;
+            if (y < 0) y = 0;
+            if (w > rwidth) w = rwidth;
+            if (h > rheight) h = rheight;
+            if (w <= x || h <= y) {
+                return;
+            }
+            blit(backbuffer, x, y, x, y, w, h);
+            // REMARK: the old way
+//            for (int i = 0; i < numregions; i++) {
+//                // consumed dirty areas are marked with a -1
+//                if (dirt[4*i]<0) {
+//                    continue;
+//                }
+//                // handle confirmed dirty areas
+//                int x = dirt[4*i];
+//                int y = dirt[4*i+1];
+//                int w = dirt[4*i+2];
+//                int h = dirt[4*i+3];
+//                if (x < 0) x = 0;
+//                if (y < 0) y = 0;
+//                if (w > rwidth) w = rwidth;
+//                if (h > rheight) h = rheight;
+//                if (w <= x || h <= y) {
+//                    continue;
+//                }
+//                blit(backbuffer, x, y, x, y, w, h);
+//            }
         }
 
         /** This is how subclasses signal a 'shallow dirty', indicating that 
although the backbuffer is valid, the screen is not */


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

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to