changeset 10450:58c94c872358

8170024: PiscesRenderer.pr.emitAndClearAlphaRow cannot accept a pix_x_from parameter greater than clip.xmin Reviewed-by: flar
author lbourges
date Tue, 18 Apr 2017 17:00:00 -0700
parents 730e6fa7109b
children 5c0428b98f23
files modules/javafx.graphics/src/main/java/com/sun/pisces/PiscesRenderer.java modules/javafx.graphics/src/main/java/com/sun/prism/sw/SWContext.java modules/javafx.graphics/src/main/native-prism-sw/JPiscesRenderer.c
diffstat 3 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/pisces/PiscesRenderer.java	Wed Apr 19 10:13:46 2017 +1200
+++ b/modules/javafx.graphics/src/main/java/com/sun/pisces/PiscesRenderer.java	Tue Apr 18 17:00:00 2017 -0700
@@ -343,14 +343,20 @@
     public void emitAndClearAlphaRow(byte[] alphaMap, int[] alphaDeltas, int pix_y, int pix_x_from, int pix_x_to,
         int rowNum)
     {
-        if ((pix_x_to - pix_x_from) > alphaDeltas.length) {
+        this.emitAndClearAlphaRow(alphaMap, alphaDeltas, pix_y, pix_x_from, pix_x_to, 0, rowNum);
+    }
+    
+    public void emitAndClearAlphaRow(byte[] alphaMap, int[] alphaDeltas, int pix_y, int pix_x_from, int pix_x_to,
+        int pix_x_off, int rowNum)
+    {
+        if (pix_x_off < 0 || (pix_x_off + (pix_x_to - pix_x_from)) > alphaDeltas.length) {
             throw new IllegalArgumentException("rendering range exceeds length of data");
         }
-        this.emitAndClearAlphaRowImpl(alphaMap, alphaDeltas, pix_y, pix_x_from, pix_x_to, rowNum);
+        this.emitAndClearAlphaRowImpl(alphaMap, alphaDeltas, pix_y, pix_x_from, pix_x_to, pix_x_off, rowNum);
     }
 
     private native void emitAndClearAlphaRowImpl(byte[] alphaMap, int[] alphaDeltas, int pix_y, int pix_x_from, int pix_x_to,
-        int rowNum);
+        int pix_x_off, int rowNum);
 
     public void fillAlphaMask(byte[] mask, int x, int y, int width, int height, int offset, int stride) {
         if (mask == null) {
--- a/modules/javafx.graphics/src/main/java/com/sun/prism/sw/SWContext.java	Wed Apr 19 10:13:46 2017 +1200
+++ b/modules/javafx.graphics/src/main/java/com/sun/prism/sw/SWContext.java	Tue Apr 18 17:00:00 2017 -0700
@@ -247,11 +247,8 @@
         public void setAndClearRelativeAlphas(final int[] alphaDeltas, final int pix_y,
                                               final int pix_from, final int pix_to)
         {
-            // use x instead of pix_from as it cause artefacts:
-            // note: it would be more efficient to skip all those empty pixels [x to pix_from[
-            // but the native implementation must be fixed too.
-//                pr.emitAndClearAlphaRow(alpha_map, alphaDeltas, pix_y, pix_from, pix_to, rowNum);
-            pr.emitAndClearAlphaRow(alpha_map, alphaDeltas, pix_y, x, pix_to, rowNum);
+            // pix_from indicates the first alpha coverage != 0 within [x; pix_to[
+            pr.emitAndClearAlphaRow(alpha_map, alphaDeltas, pix_y, pix_from, pix_to, (pix_from - x), rowNum);
             rowNum++;
 
             // clear properly the end of the alphaDeltas:
--- a/modules/javafx.graphics/src/main/native-prism-sw/JPiscesRenderer.c	Wed Apr 19 10:13:46 2017 +1200
+++ b/modules/javafx.graphics/src/main/native-prism-sw/JPiscesRenderer.c	Tue Apr 18 17:00:00 2017 -0700
@@ -582,7 +582,7 @@
  */
 JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_emitAndClearAlphaRowImpl
   (JNIEnv *env, jobject this, jbyteArray jAlphaMap, jintArray jAlphaDeltas, jint y, jint x_from, jint x_to,
-   jint rowNum)
+   jint x_off, jint rowNum)
 {
     Renderer* rdr;
     Surface* surface;
@@ -617,7 +617,7 @@
                 rdr->_rowNum = rowNum;
 
                 rdr->alphaMap = alphaMap;
-                rdr->_rowAAInt = alphaRow;
+                rdr->_rowAAInt = alphaRow + x_off; /* add offset in alpha buffer */
                 rdr->_alphaWidth = x_to - x_from + 1;
 
                 rdr->_currImageOffset = y * surface->width;