< prev index next >

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

Print this page


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


  60 
  61     /**
  62      * Constructs an instance based on the given Region
  63      */
  64     public RegionSpanIterator(Region r) {
  65         int[] bounds = new int[4];
  66 
  67         r.getBounds(bounds);
  68         lox = bounds[0];
  69         loy = bounds[1];
  70         hix = bounds[2];
  71         hiy = bounds[3];
  72         isrect = r.isRectangular();
  73 
  74         ri = r.getIterator();
  75     }
  76 
  77     /**
  78      * Gets the bbox of the available region spans.
  79      */
  80     public void getPathBox(int pathbox[]) {
  81         pathbox[0] = lox;
  82         pathbox[1] = loy;
  83         pathbox[2] = hix;
  84         pathbox[3] = hiy;
  85     }
  86 
  87     /**
  88      * Intersect the box used for clipping the output spans with the
  89      * given box.
  90      */
  91     public void intersectClipBox(int clox, int cloy, int chix, int chiy) {
  92         if (clox > lox) {
  93             lox = clox;
  94         }
  95         if (cloy > loy) {
  96             loy = cloy;
  97         }
  98         if (chix < hix) {
  99             hix = chix;
 100         }
 101         if (chiy < hiy) {
 102             hiy = chiy;
 103         }
 104         done = lox >= hix || loy >= hiy;
 105     }
 106 
 107     /**
 108      * Fetches the next span that needs to be operated on.
 109      * If the return value is false then there are no more spans.
 110      */
 111     public boolean nextSpan(int spanbox[]) {
 112 
 113         // Quick test for end conditions
 114         if (done) {
 115             return false;
 116         }
 117 
 118         // If the Region is rectangular, we store our bounds (possibly
 119         // clipped via intersectClipBox()) in spanbox and return true
 120         // so that the caller will process the single span.  We set done
 121         // to true to ensure that this will be the last span processed.
 122         if (isrect) {
 123             getPathBox(spanbox);
 124             done = true;
 125             return true;
 126         }
 127 
 128         // Local cache of current span's bounds
 129         int curlox, curhix;
 130         int curloy = this.curloy;
 131         int curhiy = this.curhiy;


   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


  60 
  61     /**
  62      * Constructs an instance based on the given Region
  63      */
  64     public RegionSpanIterator(Region r) {
  65         int[] bounds = new int[4];
  66 
  67         r.getBounds(bounds);
  68         lox = bounds[0];
  69         loy = bounds[1];
  70         hix = bounds[2];
  71         hiy = bounds[3];
  72         isrect = r.isRectangular();
  73 
  74         ri = r.getIterator();
  75     }
  76 
  77     /**
  78      * Gets the bbox of the available region spans.
  79      */
  80     public void getPathBox(int[] pathbox) {
  81         pathbox[0] = lox;
  82         pathbox[1] = loy;
  83         pathbox[2] = hix;
  84         pathbox[3] = hiy;
  85     }
  86 
  87     /**
  88      * Intersect the box used for clipping the output spans with the
  89      * given box.
  90      */
  91     public void intersectClipBox(int clox, int cloy, int chix, int chiy) {
  92         if (clox > lox) {
  93             lox = clox;
  94         }
  95         if (cloy > loy) {
  96             loy = cloy;
  97         }
  98         if (chix < hix) {
  99             hix = chix;
 100         }
 101         if (chiy < hiy) {
 102             hiy = chiy;
 103         }
 104         done = lox >= hix || loy >= hiy;
 105     }
 106 
 107     /**
 108      * Fetches the next span that needs to be operated on.
 109      * If the return value is false then there are no more spans.
 110      */
 111     public boolean nextSpan(int[] spanbox) {
 112 
 113         // Quick test for end conditions
 114         if (done) {
 115             return false;
 116         }
 117 
 118         // If the Region is rectangular, we store our bounds (possibly
 119         // clipped via intersectClipBox()) in spanbox and return true
 120         // so that the caller will process the single span.  We set done
 121         // to true to ensure that this will be the last span processed.
 122         if (isrect) {
 123             getPathBox(spanbox);
 124             done = true;
 125             return true;
 126         }
 127 
 128         // Local cache of current span's bounds
 129         int curlox, curhix;
 130         int curloy = this.curloy;
 131         int curhiy = this.curhiy;


< prev index next >