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/TransformBlit.java
41159 views
1
/*
2
* Copyright (c) 2003, 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
* TransformBlit
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
46
public class TransformBlit extends GraphicsPrimitive
47
{
48
public static final String methodSignature =
49
"TransformBlit(...)".toString();
50
51
public static final int primTypeID = makePrimTypeID();
52
53
private static RenderCache blitcache = new RenderCache(10);
54
55
public static TransformBlit locate(SurfaceType srctype,
56
CompositeType comptype,
57
SurfaceType dsttype)
58
{
59
return (TransformBlit)
60
GraphicsPrimitiveMgr.locate(primTypeID,
61
srctype, comptype, dsttype);
62
}
63
64
public static TransformBlit getFromCache(SurfaceType src,
65
CompositeType comp,
66
SurfaceType dst)
67
{
68
Object o = blitcache.get(src, comp, dst);
69
if (o != null) {
70
return (TransformBlit) o;
71
}
72
TransformBlit blit = locate(src, comp, dst);
73
if (blit == null) {
74
/*
75
System.out.println("blit loop not found for:");
76
System.out.println("src: "+src);
77
System.out.println("comp: "+comp);
78
System.out.println("dst: "+dst);
79
*/
80
} else {
81
blitcache.put(src, comp, dst, blit);
82
}
83
return blit;
84
}
85
86
protected TransformBlit(SurfaceType srctype,
87
CompositeType comptype,
88
SurfaceType dsttype)
89
{
90
super(methodSignature, primTypeID, srctype, comptype, dsttype);
91
}
92
93
public TransformBlit(long pNativePrim,
94
SurfaceType srctype,
95
CompositeType comptype,
96
SurfaceType dsttype)
97
{
98
super(pNativePrim, methodSignature, primTypeID,
99
srctype, comptype, dsttype);
100
}
101
102
public native void Transform(SurfaceData src, SurfaceData dst,
103
Composite comp, Region clip,
104
AffineTransform at, int hint,
105
int srcx, int srcy, int dstx, int dsty,
106
int width, int height);
107
108
public GraphicsPrimitive traceWrap() {
109
return new TraceTransformBlit(this);
110
}
111
112
private static class TraceTransformBlit extends TransformBlit {
113
TransformBlit target;
114
115
public TraceTransformBlit(TransformBlit target) {
116
super(target.getSourceType(),
117
target.getCompositeType(),
118
target.getDestType());
119
this.target = target;
120
}
121
122
public GraphicsPrimitive traceWrap() {
123
return this;
124
}
125
126
public void Transform(SurfaceData src, SurfaceData dst,
127
Composite comp, Region clip,
128
AffineTransform at, int hint,
129
int srcx, int srcy, int dstx, int dsty,
130
int width, int height)
131
{
132
tracePrimitive(target);
133
target.Transform(src, dst, comp, clip, at, hint,
134
srcx, srcy, dstx, dsty, width, height);
135
}
136
}
137
}
138
139