< prev index next >

src/java.desktop/share/classes/sun/java2d/pipe/AAShapePipe.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -141,14 +141,22 @@
 
         renderTiles(sg, s, aatg, abox, ts);
     }
 
     public void renderTiles(SunGraphics2D sg, Shape s,
-                            AATileGenerator aatg, int abox[], TileState ts)
+                            final AATileGenerator aatg,
+                            final int[] abox, final TileState ts)
     {
         Object context = null;
         try {
+            // defensive copy of int[] abox as local variables:
+            final int bx = abox[0];
+            final int by = abox[1];
+            final int bw = abox[2];
+            final int bh = abox[3];
+
+            // reentrance: outpipe may also use AAShapePipe:
             context = outpipe.startSequence(sg, s,
                                             ts.computeDevBox(abox),
                                             abox);
 
             final int tw = aatg.getTileWidth();

@@ -156,20 +164,19 @@
 
             // get tile from thread local storage:
             final byte[] alpha = ts.getAlphaTile(tw * th);
             byte[] atile;
 
-            for (int y = abox[1]; y < abox[3]; y += th) {
-                int h = Math.min(th, abox[3] - y);
+            for (int y = by; y < bh; y += th) {
+                final int h = Math.min(th, bh - y);
+
+                for (int x = bx; x < bw; x += tw) {
+                    final int w = Math.min(tw, bw - x);
 
-                for (int x = abox[0]; x < abox[2]; x += tw) {
-                    int w = Math.min(tw, abox[2] - x);
+                    final int a = aatg.getTypicalAlpha();
 
-                    int a = aatg.getTypicalAlpha();
-                    if (a == 0x00 ||
-                        outpipe.needTile(context, x, y, w, h) == false)
-                    {
+                    if (a == 0x00 || !outpipe.needTile(context, x, y, w, h)) {
                         aatg.nextTile();
                         outpipe.skipTile(context, x, y);
                         continue;
                     }
                     if (a == 0xff) {

@@ -178,12 +185,12 @@
                     } else {
                         atile = alpha;
                         aatg.getAlpha(alpha, 0, tw);
                     }
 
-                    outpipe.renderPathTile(context, atile, 0, tw,
-                                           x, y, w, h);
+                    // TODO: check reentrance issue ? on byte[] alpha ?
+                    outpipe.renderPathTile(context, atile, 0, tw, x, y, w, h);
                 }
             }
         } finally {
             aatg.dispose();
             if (context != null) {
< prev index next >