< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 126         boolean adjust = (bs != null &&
 127                           sg.strokeHint != SunHints.INTVAL_STROKE_PURE);
 128         boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED);
 129 
 130         Region clip = sg.getCompClip();
 131         final TileState ts = tileStateThreadLocal.get();
 132         final int[] abox = ts.abox;
 133 
 134         AATileGenerator aatg =
 135             renderengine.getAATileGenerator(s, sg.transform, clip,
 136                                             bs, thin, adjust, abox);
 137         if (aatg == null) {
 138             // Nothing to render
 139             return;
 140         }
 141 
 142         renderTiles(sg, s, aatg, abox, ts);
 143     }
 144 
 145     public void renderTiles(SunGraphics2D sg, Shape s,
 146                             AATileGenerator aatg, int abox[], TileState ts)

 147     {
 148         Object context = null;
 149         try {







 150             context = outpipe.startSequence(sg, s,
 151                                             ts.computeDevBox(abox),
 152                                             abox);
 153 
 154             final int tw = aatg.getTileWidth();
 155             final int th = aatg.getTileHeight();
 156 
 157             // get tile from thread local storage:
 158             final byte[] alpha = ts.getAlphaTile(tw * th);
 159             byte[] atile;
 160 
 161             for (int y = abox[1]; y < abox[3]; y += th) {
 162                 int h = Math.min(th, abox[3] - y);



 163 
 164                 for (int x = abox[0]; x < abox[2]; x += tw) {
 165                     int w = Math.min(tw, abox[2] - x);
 166 
 167                     int a = aatg.getTypicalAlpha();
 168                     if (a == 0x00 ||
 169                         outpipe.needTile(context, x, y, w, h) == false)
 170                     {
 171                         aatg.nextTile();
 172                         outpipe.skipTile(context, x, y);
 173                         continue;
 174                     }
 175                     if (a == 0xff) {
 176                         atile = null;
 177                         aatg.nextTile();
 178                     } else {
 179                         atile = alpha;
 180                         aatg.getAlpha(alpha, 0, tw);
 181                     }
 182 
 183                     outpipe.renderPathTile(context, atile, 0, tw,
 184                                            x, y, w, h);
 185                 }
 186             }
 187         } finally {
 188             aatg.dispose();
 189             if (context != null) {
 190                 outpipe.endSequence(context);
 191             }
 192         }
 193     }
 194 
 195     // Tile state used by AAShapePipe
 196     static final class TileState {
 197         // cached tile (32 x 32 tile by default)
 198         private byte[] theTile = new byte[32 * 32];
 199         // dirty aabox array
 200         final int[] abox = new int[4];
 201         // dirty bbox rectangle
 202         private final Rectangle dev = new Rectangle();
 203         // dirty bbox rectangle2D.Double
 204         private final Rectangle2D.Double bbox2D = new Rectangle2D.Double();


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 126         boolean adjust = (bs != null &&
 127                           sg.strokeHint != SunHints.INTVAL_STROKE_PURE);
 128         boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED);
 129 
 130         Region clip = sg.getCompClip();
 131         final TileState ts = tileStateThreadLocal.get();
 132         final int[] abox = ts.abox;
 133 
 134         AATileGenerator aatg =
 135             renderengine.getAATileGenerator(s, sg.transform, clip,
 136                                             bs, thin, adjust, abox);
 137         if (aatg == null) {
 138             // Nothing to render
 139             return;
 140         }
 141 
 142         renderTiles(sg, s, aatg, abox, ts);
 143     }
 144 
 145     public void renderTiles(SunGraphics2D sg, Shape s,
 146                             final AATileGenerator aatg,
 147                             final int[] abox, final TileState ts)
 148     {
 149         Object context = null;
 150         try {
 151             // defensive copy of int[] abox as local variables:
 152             final int bx = abox[0];
 153             final int by = abox[1];
 154             final int bw = abox[2];
 155             final int bh = abox[3];
 156 
 157             // reentrance: outpipe may also use AAShapePipe:
 158             context = outpipe.startSequence(sg, s,
 159                                             ts.computeDevBox(abox),
 160                                             abox);
 161 
 162             final int tw = aatg.getTileWidth();
 163             final int th = aatg.getTileHeight();
 164 
 165             // get tile from thread local storage:
 166             final byte[] alpha = ts.getAlphaTile(tw * th);
 167             byte[] atile;
 168 
 169             for (int y = by; y < bh; y += th) {
 170                 final int h = Math.min(th, bh - y);
 171 
 172                 for (int x = bx; x < bw; x += tw) {
 173                     final int w = Math.min(tw, bw - x);
 174 
 175                     final int a = aatg.getTypicalAlpha();

 176 
 177                     if (a == 0x00 || !outpipe.needTile(context, x, y, w, h)) {



 178                         aatg.nextTile();
 179                         outpipe.skipTile(context, x, y);
 180                         continue;
 181                     }
 182                     if (a == 0xff) {
 183                         atile = null;
 184                         aatg.nextTile();
 185                     } else {
 186                         atile = alpha;
 187                         aatg.getAlpha(alpha, 0, tw);
 188                     }
 189 
 190                     // TODO: check reentrance issue ? on byte[] alpha ?
 191                     outpipe.renderPathTile(context, atile, 0, tw, x, y, w, h);
 192                 }
 193             }
 194         } finally {
 195             aatg.dispose();
 196             if (context != null) {
 197                 outpipe.endSequence(context);
 198             }
 199         }
 200     }
 201 
 202     // Tile state used by AAShapePipe
 203     static final class TileState {
 204         // cached tile (32 x 32 tile by default)
 205         private byte[] theTile = new byte[32 * 32];
 206         // dirty aabox array
 207         final int[] abox = new int[4];
 208         // dirty bbox rectangle
 209         private final Rectangle dev = new Rectangle();
 210         // dirty bbox rectangle2D.Double
 211         private final Rectangle2D.Double bbox2D = new Rectangle2D.Double();


< prev index next >