< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1999, 2017, 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


  62     // The cursors that track the progress through the region
  63     RegionIterator resetState;
  64     RegionIterator lwm;
  65     RegionIterator row;
  66     RegionIterator box;
  67 
  68     // The bounds of the current span iterator span
  69     int spanlox, spanhix, spanloy, spanhiy;
  70 
  71     // The extent of the region band marking the low water mark
  72     int lwmloy, lwmhiy;
  73 
  74     // The bounds of the current region box
  75     int rgnlox, rgnloy, rgnhix, rgnhiy;
  76 
  77     // The bounding box of the input Region. Used for click
  78     // rejection of iterator spans
  79     int rgnbndslox, rgnbndsloy, rgnbndshix, rgnbndshiy;
  80 
  81     // The array used to hold coordinates from the region iterator
  82     int rgnbox[] = new int[4];
  83 
  84     // The array used to hold coordinates from the span iterator
  85     int spanbox[] = new int[4];
  86 
  87     // True if the next iterator span should be read on the next
  88     // iteration of the main nextSpan() loop
  89     boolean doNextSpan;
  90 
  91     // True if the next region box should be read on the next
  92     // iteration of the main nextSpan() loop
  93     boolean doNextBox;
  94 
  95     // True if there are no more spans or the Region is empty
  96     boolean done = false;
  97 
  98     /*
  99      * Creates an instance that filters the spans generated by
 100      * spanIter through the region described by rgn.
 101      */
 102     public RegionClipSpanIterator(Region rgn, SpanIterator spanIter) {
 103 
 104         this.spanIter = spanIter;
 105 


 121         rgnbndshiy = rgnbox[3];
 122         if (rgnbndslox >= rgnbndshix ||
 123             rgnbndsloy >= rgnbndshiy) {
 124             done = true;
 125             return;
 126         }
 127 
 128         this.rgn = rgn;
 129 
 130 
 131         row = lwm.createCopy();
 132         box = row.createCopy();
 133         doNextSpan = true;
 134         doNextBox = false;
 135     }
 136 
 137     /*
 138      * Gets the bbox of the available path segments, clipped to the
 139      * Region.
 140      */
 141     public void getPathBox(int pathbox[]) {
 142         int[] rgnbox = new int[4];
 143         rgn.getBounds(rgnbox);
 144         spanIter.getPathBox(pathbox);
 145 
 146         if (pathbox[0] < rgnbox[0]) {
 147             pathbox[0] = rgnbox[0];
 148         }
 149 
 150         if (pathbox[1] < rgnbox[1]) {
 151             pathbox[1] = rgnbox[1];
 152         }
 153 
 154         if (pathbox[2] > rgnbox[2]) {
 155             pathbox[2] = rgnbox[2];
 156         }
 157 
 158         if (pathbox[3] > rgnbox[3]) {
 159             pathbox[3] = rgnbox[3];
 160         }
 161 }
 162 
 163     /*
 164      * Intersects the path box with the given bbox.
 165      * Returned spans are clipped to this region, or discarded
 166      * altogether if they lie outside it.
 167      */
 168     public void intersectClipBox(int lox, int loy, int hix, int hiy) {
 169         spanIter.intersectClipBox(lox, loy, hix, hiy);
 170     }
 171 
 172 
 173     /*
 174      * Fetches the next span that needs to be operated on.
 175      * If the return value is false then there are no more spans.
 176      */
 177     public boolean nextSpan(int resultbox[]) {
 178         if (done) {
 179             return false;
 180         }
 181 
 182         int resultlox, resultloy, resulthix, resulthiy;
 183         boolean doNextRow = false;
 184 
 185         // REMIND: Cache the coordinate inst vars used in this loop
 186         // in locals vars.
 187         while (true) {
 188             // We've exhausted the current span so get the next one
 189             if (doNextSpan) {
 190                 if (!spanIter.nextSpan(spanbox)) {
 191                     done = true;
 192                     return false;
 193                 } else {
 194                     spanlox = spanbox[0];
 195                     // Clip out spans that lie outside of the rgn's bounds
 196                     if (spanlox >= rgnbndshix) {
 197                         continue;


   1 /*
   2  * Copyright (c) 1999, 2018, 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


  62     // The cursors that track the progress through the region
  63     RegionIterator resetState;
  64     RegionIterator lwm;
  65     RegionIterator row;
  66     RegionIterator box;
  67 
  68     // The bounds of the current span iterator span
  69     int spanlox, spanhix, spanloy, spanhiy;
  70 
  71     // The extent of the region band marking the low water mark
  72     int lwmloy, lwmhiy;
  73 
  74     // The bounds of the current region box
  75     int rgnlox, rgnloy, rgnhix, rgnhiy;
  76 
  77     // The bounding box of the input Region. Used for click
  78     // rejection of iterator spans
  79     int rgnbndslox, rgnbndsloy, rgnbndshix, rgnbndshiy;
  80 
  81     // The array used to hold coordinates from the region iterator
  82     int[] rgnbox = new int[4];
  83 
  84     // The array used to hold coordinates from the span iterator
  85     int[] spanbox = new int[4];
  86 
  87     // True if the next iterator span should be read on the next
  88     // iteration of the main nextSpan() loop
  89     boolean doNextSpan;
  90 
  91     // True if the next region box should be read on the next
  92     // iteration of the main nextSpan() loop
  93     boolean doNextBox;
  94 
  95     // True if there are no more spans or the Region is empty
  96     boolean done = false;
  97 
  98     /*
  99      * Creates an instance that filters the spans generated by
 100      * spanIter through the region described by rgn.
 101      */
 102     public RegionClipSpanIterator(Region rgn, SpanIterator spanIter) {
 103 
 104         this.spanIter = spanIter;
 105 


 121         rgnbndshiy = rgnbox[3];
 122         if (rgnbndslox >= rgnbndshix ||
 123             rgnbndsloy >= rgnbndshiy) {
 124             done = true;
 125             return;
 126         }
 127 
 128         this.rgn = rgn;
 129 
 130 
 131         row = lwm.createCopy();
 132         box = row.createCopy();
 133         doNextSpan = true;
 134         doNextBox = false;
 135     }
 136 
 137     /*
 138      * Gets the bbox of the available path segments, clipped to the
 139      * Region.
 140      */
 141     public void getPathBox(int[] pathbox) {
 142         int[] rgnbox = new int[4];
 143         rgn.getBounds(rgnbox);
 144         spanIter.getPathBox(pathbox);
 145 
 146         if (pathbox[0] < rgnbox[0]) {
 147             pathbox[0] = rgnbox[0];
 148         }
 149 
 150         if (pathbox[1] < rgnbox[1]) {
 151             pathbox[1] = rgnbox[1];
 152         }
 153 
 154         if (pathbox[2] > rgnbox[2]) {
 155             pathbox[2] = rgnbox[2];
 156         }
 157 
 158         if (pathbox[3] > rgnbox[3]) {
 159             pathbox[3] = rgnbox[3];
 160         }
 161 }
 162 
 163     /*
 164      * Intersects the path box with the given bbox.
 165      * Returned spans are clipped to this region, or discarded
 166      * altogether if they lie outside it.
 167      */
 168     public void intersectClipBox(int lox, int loy, int hix, int hiy) {
 169         spanIter.intersectClipBox(lox, loy, hix, hiy);
 170     }
 171 
 172 
 173     /*
 174      * Fetches the next span that needs to be operated on.
 175      * If the return value is false then there are no more spans.
 176      */
 177     public boolean nextSpan(int[] resultbox) {
 178         if (done) {
 179             return false;
 180         }
 181 
 182         int resultlox, resultloy, resulthix, resulthiy;
 183         boolean doNextRow = false;
 184 
 185         // REMIND: Cache the coordinate inst vars used in this loop
 186         // in locals vars.
 187         while (true) {
 188             // We've exhausted the current span so get the next one
 189             if (doNextSpan) {
 190                 if (!spanIter.nextSpan(spanbox)) {
 191                     done = true;
 192                     return false;
 193                 } else {
 194                     spanlox = spanbox[0];
 195                     // Clip out spans that lie outside of the rgn's bounds
 196                     if (spanlox >= rgnbndshix) {
 197                         continue;


< prev index next >