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/ScaledBlit.java
41159 views
1
/*
2
* Copyright (c) 2001, 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
30
import sun.java2d.SurfaceData;
31
import sun.java2d.pipe.Region;
32
33
/**
34
* ScaledBlit
35
* 1) copies rectangle of pixels from one surface to another
36
* while scaling the pixels to meet the sizes specified
37
* 2) performs compositing of colors based upon a Composite
38
* parameter
39
*
40
* precise behavior is undefined if the source surface
41
* and the destination surface are the same surface
42
* with overlapping regions of pixels
43
*/
44
45
public class ScaledBlit extends GraphicsPrimitive
46
{
47
public static final String methodSignature = "ScaledBlit(...)".toString();
48
49
public static final int primTypeID = makePrimTypeID();
50
51
private static RenderCache blitcache = new RenderCache(20);
52
53
public static ScaledBlit locate(SurfaceType srctype,
54
CompositeType comptype,
55
SurfaceType dsttype)
56
{
57
return (ScaledBlit)
58
GraphicsPrimitiveMgr.locate(primTypeID,
59
srctype, comptype, dsttype);
60
}
61
62
public static ScaledBlit getFromCache(SurfaceType src,
63
CompositeType comp,
64
SurfaceType dst)
65
{
66
Object o = blitcache.get(src, comp, dst);
67
if (o != null) {
68
return (ScaledBlit) o;
69
}
70
ScaledBlit blit = locate(src, comp, dst);
71
if (blit == null) {
72
/*
73
System.out.println("blit loop not found for:");
74
System.out.println("src: "+src);
75
System.out.println("comp: "+comp);
76
System.out.println("dst: "+dst);
77
*/
78
} else {
79
blitcache.put(src, comp, dst, blit);
80
}
81
return blit;
82
}
83
84
protected ScaledBlit(SurfaceType srctype,
85
CompositeType comptype,
86
SurfaceType dsttype)
87
{
88
super(methodSignature, primTypeID, srctype, comptype, dsttype);
89
}
90
91
public ScaledBlit(long pNativePrim,
92
SurfaceType srctype,
93
CompositeType comptype,
94
SurfaceType dsttype)
95
{
96
super(pNativePrim, methodSignature, primTypeID,
97
srctype, comptype, dsttype);
98
}
99
100
public native void Scale(SurfaceData src, SurfaceData dst,
101
Composite comp, Region clip,
102
int sx1, int sy1,
103
int sx2, int sy2,
104
double dx1, double dy1,
105
double dx2, double dy2);
106
107
public GraphicsPrimitive traceWrap() {
108
return new TraceScaledBlit(this);
109
}
110
111
private static class TraceScaledBlit extends ScaledBlit {
112
ScaledBlit target;
113
114
public TraceScaledBlit(ScaledBlit target) {
115
super(target.getSourceType(),
116
target.getCompositeType(),
117
target.getDestType());
118
this.target = target;
119
}
120
121
public GraphicsPrimitive traceWrap() {
122
return this;
123
}
124
125
public void Scale(SurfaceData src, SurfaceData dst,
126
Composite comp, Region clip,
127
int sx1, int sy1,
128
int sx2, int sy2,
129
double dx1, double dy1,
130
double dx2, double dy2)
131
{
132
tracePrimitive(target);
133
target.Scale(src, dst, comp, clip,
134
sx1, sy1, sx2, sy2,
135
dx1, dy1, dx2, dy2);
136
}
137
}
138
}
139
140