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/SpanClipRenderer.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
import java.awt.Rectangle;
29
import java.awt.Shape;
30
import sun.java2d.SunGraphics2D;
31
32
/**
33
* This class uses a Region iterator to modify the extents of alpha
34
* tiles created during Shape rendering based upon a non-rectangular
35
* clipping path.
36
*/
37
public class SpanClipRenderer implements CompositePipe
38
{
39
CompositePipe outpipe;
40
41
static Class<?> RegionClass = Region.class;
42
static Class<?> RegionIteratorClass = RegionIterator.class;
43
44
static {
45
initIDs(RegionClass, RegionIteratorClass);
46
}
47
48
static native void initIDs(Class<?> rc, Class<?> ric);
49
50
public SpanClipRenderer(CompositePipe pipe) {
51
outpipe = pipe;
52
}
53
54
class SCRcontext {
55
RegionIterator iterator;
56
Object outcontext;
57
int[] band;
58
byte[] tile;
59
60
public SCRcontext(RegionIterator ri, Object outctx) {
61
iterator = ri;
62
outcontext = outctx;
63
band = new int[4];
64
}
65
}
66
67
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
68
int[] abox) {
69
RegionIterator ri = sg.clipRegion.getIterator();
70
71
return new SCRcontext(ri, outpipe.startSequence(sg, s, devR, abox));
72
}
73
74
public boolean needTile(Object ctx, int x, int y, int w, int h) {
75
SCRcontext context = (SCRcontext) ctx;
76
return (outpipe.needTile(context.outcontext, x, y, w, h));
77
}
78
79
public void renderPathTile(Object ctx,
80
byte[] atile, int offset, int tsize,
81
int x, int y, int w, int h,
82
ShapeSpanIterator sr) {
83
renderPathTile(ctx, atile, offset, tsize, x, y, w, h);
84
}
85
86
public void renderPathTile(Object ctx,
87
byte[] atile, int offset, int tsize,
88
int x, int y, int w, int h) {
89
SCRcontext context = (SCRcontext) ctx;
90
RegionIterator ri = context.iterator.createCopy();
91
int[] band = context.band;
92
band[0] = x;
93
band[1] = y;
94
band[2] = x + w;
95
band[3] = y + h;
96
if (atile == null) {
97
int size = w * h;
98
atile = context.tile;
99
if (atile != null && atile.length < size) {
100
atile = null;
101
}
102
if (atile == null) {
103
atile = new byte[size];
104
context.tile = atile;
105
}
106
offset = 0;
107
tsize = w;
108
fillTile(ri, atile, offset, tsize, band);
109
} else {
110
eraseTile(ri, atile, offset, tsize, band);
111
}
112
113
if (band[2] > band[0] && band[3] > band[1]) {
114
offset += (band[1] - y) * tsize + (band[0] - x);
115
outpipe.renderPathTile(context.outcontext,
116
atile, offset, tsize,
117
band[0], band[1],
118
band[2] - band[0],
119
band[3] - band[1]);
120
}
121
}
122
123
public native void fillTile(RegionIterator ri,
124
byte[] alpha, int offset, int tsize,
125
int[] band);
126
127
public native void eraseTile(RegionIterator ri,
128
byte[] alpha, int offset, int tsize,
129
int[] band);
130
131
public void skipTile(Object ctx, int x, int y) {
132
SCRcontext context = (SCRcontext) ctx;
133
outpipe.skipTile(context.outcontext, x, y);
134
}
135
136
public void endSequence(Object ctx) {
137
SCRcontext context = (SCRcontext) ctx;
138
outpipe.endSequence(context.outcontext);
139
}
140
}
141
142