changeset 8515:d094365ab0c5 8u40-b16

Fix RT-39424: non-AA rendering should sample at centers of pixels Reviewed by: kcr, chien
author flar <James.Graham@oracle.com>
date Sun, 23 Nov 2014 21:19:59 -0800
parents c09b3130bb01
children 8a210ee0890b 35958dda3857 a8c1304a3151
files modules/graphics/src/main/java/com/sun/openpisces/Renderer.java modules/graphics/src/main/native-prism/Renderer.c
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/openpisces/Renderer.java	Mon Nov 24 11:19:56 2014 +1300
+++ b/modules/graphics/src/main/java/com/sun/openpisces/Renderer.java	Sun Nov 23 21:19:59 2014 -0800
@@ -98,7 +98,7 @@
             for (int i = 0; i < count; i++) {
                 int ecur = ptrs[i];
                 float curx = edges[ecur+CURX];
-                int cross = ((int) curx) << 1;
+                int cross = ((int) Math.ceil(curx - 0.5f)) << 1;
                 edges[ecur+CURX] = curx + edges[ecur+SLOPE];
                 if (edges[ecur+OR] > 0) {
                     cross |= 1;
@@ -279,8 +279,8 @@
             x1 = or;
             or = 0;
         }
-        final int firstCrossing = Math.max((int)Math.ceil(y1), boundsMinY);
-        final int lastCrossing = Math.min((int)Math.ceil(y2), boundsMaxY);
+        final int firstCrossing = Math.max((int) Math.ceil(y1 - 0.5f), boundsMinY);
+        final int lastCrossing = Math.min((int) Math.ceil(y2 - 0.5f), boundsMaxY);
         if (firstCrossing >= lastCrossing) {
             return;
         }
@@ -301,7 +301,7 @@
         edges = Helpers.widenArray(edges, ptr, SIZEOF_EDGE);
         numEdges++;
         edges[ptr+OR] = or;
-        edges[ptr+CURX] = x1 + (firstCrossing - y1) * slope;
+        edges[ptr+CURX] = x1 + (firstCrossing + 0.5f - y1) * slope;
         edges[ptr+SLOPE] = slope;
         edges[ptr+YMAX] = lastCrossing;
         final int bucketIdx = firstCrossing - boundsMinY;
@@ -551,13 +551,13 @@
     }
 
     public int getSubpixMinX() {
-        int sampleColMin = (int) Math.ceil(edgeMinX);
+        int sampleColMin = (int) Math.ceil(edgeMinX - 0.5f);
         if (sampleColMin < boundsMinX) sampleColMin = boundsMinX;
 	return sampleColMin;
     }
 
     public int getSubpixMaxX() {
-        int sampleColMax = (int) Math.ceil(edgeMaxX);
+        int sampleColMax = (int) Math.ceil(edgeMaxX - 0.5f);
         if (sampleColMax > boundsMaxX) sampleColMax = boundsMaxX;
 	return sampleColMax;
     }
--- a/modules/graphics/src/main/native-prism/Renderer.c	Mon Nov 24 11:19:56 2014 +1300
+++ b/modules/graphics/src/main/native-prism/Renderer.c	Sun Nov 23 21:19:59 2014 -0800
@@ -122,7 +122,7 @@
     for (i = 0; i < count; i++) {
         jint ecur = ptrs[i];
         jfloat curx = edges[ecur+CURX];
-        jint cross = ((jint) curx) << 1;
+        jint cross = ((jint) ceil(curx - 0.5f)) << 1;
         jint j;
         edges[ecur+CURX] = curx + edges[ecur+SLOPE];
         if (edges[ecur+OR] > 0) {
@@ -296,8 +296,8 @@
         x1 = or;
         or = 0;
     }
-    firstCrossing = Math_max((jint) ceil(y1), this.boundsMinY);
-    lastCrossing = Math_min((jint) ceil(y2), this.boundsMaxY);
+    firstCrossing = Math_max((jint) ceil(y1 - 0.5f), this.boundsMinY);
+    lastCrossing = Math_min((jint) ceil(y2 - 0.5f), this.boundsMaxY);
     if (firstCrossing >= lastCrossing) {
         return;
     }
@@ -325,7 +325,7 @@
     }
     this.numEdges++;
     this.edges[ptr+OR] = or;
-    this.edges[ptr+CURX] = x1 + (firstCrossing - y1) * slope;
+    this.edges[ptr+CURX] = x1 + (firstCrossing + 0.5f - y1) * slope;
     this.edges[ptr+SLOPE] = slope;
     this.edges[ptr+YMAX] = (jfloat) lastCrossing;
     bucketIdx = firstCrossing - this.boundsMinY;
@@ -635,13 +635,13 @@
 }
 
 static jint getSubpixMinX(Renderer *pRenderer) {
-    jint sampleColMin = (jint) ceil(this.edgeMinX);
+    jint sampleColMin = (jint) ceil(this.edgeMinX - 0.5f);
     if (sampleColMin < this.boundsMinX) sampleColMin = this.boundsMinX;
     return sampleColMin;
 }
 
 static jint getSubpixMaxX(Renderer *pRenderer) {
-    jint sampleColMax = (jint) ceil(this.edgeMaxX);
+    jint sampleColMax = (jint) ceil(this.edgeMaxX - 0.5f);
     if (sampleColMax > this.boundsMaxX) sampleColMax = this.boundsMaxX;
     return sampleColMax;
 }