Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/sun/java2d/loops/TransformHelper.java
41159 views
1
/*
2
* Copyright (c) 2004, 2021, 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.loops;
27
28
import java.awt.Composite;
29
import java.awt.geom.AffineTransform;
30
31
import sun.java2d.SurfaceData;
32
import sun.java2d.pipe.Region;
33
34
/**
35
* TransformHelper
36
* 1) applies an AffineTransform to a rectangle of pixels while copying
37
* from one surface to another
38
* 2) performs compositing of colors based upon a Composite
39
* parameter
40
*
41
* precise behavior is undefined if the source surface
42
* and the destination surface are the same surface
43
* with overlapping regions of pixels
44
*/
45
public class TransformHelper extends GraphicsPrimitive
46
{
47
public static final String methodSignature =
48
"TransformHelper(...)".toString();
49
50
public static final int primTypeID = makePrimTypeID();
51
52
private static RenderCache helpercache = new RenderCache(10);
53
54
public static TransformHelper locate(SurfaceType srctype) {
55
return (TransformHelper)
56
GraphicsPrimitiveMgr.locate(primTypeID,
57
srctype,
58
CompositeType.SrcNoEa,
59
SurfaceType.IntArgbPre);
60
}
61
62
public static synchronized TransformHelper getFromCache(SurfaceType src) {
63
Object o = helpercache.get(src, null, null);
64
if (o != null) {
65
return (TransformHelper) o;
66
}
67
TransformHelper helper = locate(src);
68
if (helper == null) {
69
/*
70
System.out.println("helper loop not found for:");
71
System.out.println("src: "+src);
72
*/
73
} else {
74
helpercache.put(src, null, null, helper);
75
}
76
return helper;
77
}
78
79
protected TransformHelper(SurfaceType srctype) {
80
super(methodSignature, primTypeID, srctype,
81
CompositeType.SrcNoEa,
82
SurfaceType.IntArgbPre);
83
}
84
85
public TransformHelper(long pNativePrim, SurfaceType srctype,
86
CompositeType comptype,
87
SurfaceType dsttype)
88
{
89
super(pNativePrim, methodSignature, primTypeID,
90
srctype, comptype, dsttype);
91
}
92
93
public native void Transform(MaskBlit output,
94
SurfaceData src, SurfaceData dst,
95
Composite comp, Region clip,
96
AffineTransform itx, int txtype,
97
int sx1, int sy1, int sx2, int sy2,
98
int dx1, int dy1, int dx2, int dy2,
99
int[] edges, int dxoff, int dyoff);
100
101
public GraphicsPrimitive traceWrap() {
102
return new TraceTransformHelper(this);
103
}
104
105
private static class TraceTransformHelper extends TransformHelper {
106
TransformHelper target;
107
108
public TraceTransformHelper(TransformHelper target) {
109
super(target.getSourceType());
110
this.target = target;
111
}
112
113
public GraphicsPrimitive traceWrap() {
114
return this;
115
}
116
117
public void Transform(MaskBlit output,
118
SurfaceData src, SurfaceData dst,
119
Composite comp, Region clip,
120
AffineTransform itx, int txtype,
121
int sx1, int sy1, int sx2, int sy2,
122
int dx1, int dy1, int dx2, int dy2,
123
int[] edges, int dxoff, int dyoff)
124
{
125
tracePrimitive(target);
126
target.Transform(output, src, dst, comp, clip, itx, txtype,
127
sx1, sy1, sx2, sy2,
128
dx1, dy1, dx2, dy2,
129
edges, dxoff, dyoff);
130
}
131
}
132
}
133
134