Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/sun/java2d/pipe/RegionIterator.java
41159 views
1
/*
2
* Copyright (c) 1998, 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
23
* questions.
24
*/
25
26
package sun.java2d.pipe;
27
28
29
/**
30
* This class defines the API for iterating through the bands
31
* of a region object.
32
*/
33
public class RegionIterator {
34
Region region;
35
int curIndex;
36
int numXbands;
37
38
RegionIterator(Region r) {
39
region = r;
40
}
41
42
/**
43
* Returns a new RegionIterator object representing the same
44
* iteration state as this object to allow multiple iteration
45
* branches from the current position.
46
*/
47
public RegionIterator createCopy() {
48
RegionIterator r = new RegionIterator(region);
49
r.curIndex = this.curIndex;
50
r.numXbands = this.numXbands;
51
return r;
52
}
53
54
/**
55
* Copies the iteration state from this RegionIterator object
56
* into another RegionIterator object to allow multiple iteration
57
* branches from the current position.
58
*/
59
public void copyStateFrom(RegionIterator ri) {
60
if (this.region != ri.region) {
61
throw new InternalError("region mismatch");
62
}
63
this.curIndex = ri.curIndex;
64
this.numXbands = ri.numXbands;
65
}
66
67
/**
68
* Moves the iteration state to the beginning of the next
69
* Y range in the region returning true if one is found
70
* and recording the low and high Y coordinates of the
71
* range in the array at locations 1 and 3 respectively.
72
*/
73
public boolean nextYRange(int[] range) {
74
curIndex += numXbands * 2;
75
numXbands = 0;
76
if (curIndex >= region.endIndex) {
77
return false;
78
}
79
range[1] = region.bands[curIndex++];
80
range[3] = region.bands[curIndex++];
81
numXbands = region.bands[curIndex++];
82
return true;
83
}
84
85
/**
86
* Moves the iteration state to the beginning of the next
87
* X band in the current Y range returning true if one is
88
* found and recording the low and high X coordinates of
89
* the range in the array at locations 0 and 2 respectively.
90
*/
91
public boolean nextXBand(int[] range) {
92
if (numXbands <= 0) {
93
return false;
94
}
95
numXbands--;
96
range[0] = region.bands[curIndex++];
97
range[2] = region.bands[curIndex++];
98
return true;
99
}
100
}
101
102