r5414 dsilvers - /branches/vince/netsurf-fb/framebuffer/fb_plotters.c

netsurf at semichrome.net netsurf at semichrome.net
Tue Sep 23 11:31:31 BST 2008


Author: dsilvers
Date: Tue Sep 23 05:31:31 2008
New Revision: 5414

URL: http://source.netsurf-browser.org?rev=5414&view=rev
Log:
Tidy the region clipping slightly

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_plotters.c

Modified: branches/vince/netsurf-fb/framebuffer/fb_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_plotters.c?rev=5414&r1=5413&r2=5414&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_plotters.c Tue Sep 23 05:31:31 2008
@@ -36,10 +36,17 @@
 /* Current plotting context */
 bbox_t fb_plot_ctx;
 
-#define REGION(x,y,cx1,cx2,cy1,cy2) ( ( (y) > (cy2) ? 8 : 0) |  \
-                                      ( (y) < (cy1) ? 4 : 0) |  \
-                                      ( (x) > (cx2) ? 2 : 0) |  \
-                                      ( (x) < (cx1) ? 1 : 0) )
+enum {
+        POINT_LEFTOF_REGION = 1,
+        POINT_RIGHTOF_REGION = 2,
+        POINT_ABOVE_REGION = 4,
+        POINT_BELOW_REGION = 8,
+};
+
+#define REGION(x,y,cx1,cx2,cy1,cy2) ( ( (y) > (cy2) ? POINT_BELOW_REGION : 0) |  \
+                                      ( (y) < (cy1) ? POINT_ABOVE_REGION : 0) |  \
+                                      ( (x) > (cx2) ? POINT_RIGHTOF_REGION : 0) |  \
+                                      ( (x) < (cx1) ? POINT_LEFTOF_REGION : 0) )
 
 #define SWAP(a, b) do { int t; t=(a); (a)=(b); (b)=t;  } while(0) 
 
@@ -107,24 +114,24 @@
 
                 if (region1) {
                         /* first point */
-                        if (region1 & 8) { 
+                        if (region1 & POINT_BELOW_REGION) { 
                                 /* divide line at bottom */
-                                *x0 = (*x0 + (*x1-*x0) *
+                                *x0 = (*x0 + (*x1 - *x0) *
                                        (clip->y1 - 1 - *y0) / (*y1-*y0));
                                 *y0 = clip->y1 - 1;
-                        } else if (region1 & 4) { 
+                        } else if (region1 & POINT_ABOVE_REGION) { 
                                 /* divide line at top */
-                                *x0 = (*x0 + (*x1-*x0) *
+                                *x0 = (*x0 + (*x1 - *x0) *
                                        (clip->y0 - *y0) / (*y1-*y0));
                                 *y0 = clip->y0;
-                        } else if (region1 & 2) { 
+                        } else if (region1 & POINT_RIGHTOF_REGION) { 
                                 /* divide line at right */
-                                *y0 = (*y0 +(*y1-*y0) *
+                                *y0 = (*y0 + (*y1 - *y0) *
                                        (clip->x1  - 1 - *x0) / (*x1-*x0));
                                 *x0 = clip->x1 - 1;
-                        } else if (region1 & 1) { 
+                        } else if (region1 & POINT_LEFTOF_REGION) { 
                                 /* divide line at right */
-                                *y0 = (*y0 +(*y1-*y0) *
+                                *y0 = (*y0 + (*y1 - *y0) *
                                        (clip->x0 - *x0) / (*x1-*x0));
                                 *x0 = clip->x0;
                         }
@@ -133,24 +140,24 @@
                                          clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);
                 } else {
                         /* second point */
-                        if (region2 & 8) {  
+                        if (region2 & POINT_BELOW_REGION) {  
                                 /* divide line at bottom*/
-                                *x1 = (*x0 + (*x1-*x0) *
+                                *x1 = (*x0 + (*x1 - *x0) *
                                        (clip->y1  - 1 - *y0) / (*y1-*y0));
                                 *y1 = clip->y1 - 1;
-                        } else if (region2 & 4) { 
+                        } else if (region2 & POINT_ABOVE_REGION) { 
                                 /* divide line at top*/
-                                *x1 = (*x0 +(*x1-*x0) *
+                                *x1 = (*x0 + (*x1 - *x0) *
                                        (clip->y0 - *y0) / (*y1-*y0));
                                 *y1 = clip->y0;
-                        } else if (region2 & 2) { 
+                        } else if (region2 & POINT_RIGHTOF_REGION) { 
                                 /* divide line at right*/
-                                *y1 = (*y0 +(*y1-*y0) *
+                                *y1 = (*y0 + (*y1 - *y0) *
                                        (clip->x1  - 1 - *x0) / (*x1 - *x0));
                                 *x1 = clip->x1 - 1;
-                        } else if (region2 & 1) { 
+                        } else if (region2 & POINT_LEFTOF_REGION) { 
                                 /* divide line at right*/
-                                *y1 = (*y0 +(*y1-*y0) *
+                                *y1 = (*y0 + (*y1 - *y0) *
                                        (clip->x0 - *x0) / (*x1 - *x0));
                                 *x1 = clip->x0;
                         }
@@ -176,7 +183,7 @@
 
         g = window_list;
 
-        //LOG(("x0 %d, y0 %d, x1 %d, y1 %d", x0, y0, x1, y1));
+        /* LOG(("x0 %d, y0 %d, x1 %d, y1 %d", x0, y0, x1, y1)); */
 
 	if (x1 < x0) SWAP(x0, x1);
 	if (y1 < y0) SWAP(y0, y1);




More information about the netsurf-commits mailing list