Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/macosx/classes/sun/java2d/metal/MTLDrawImage.java
41159 views
1
/*
2
* Copyright (c) 2019, 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.metal;
27
28
import sun.java2d.SunGraphics2D;
29
import sun.java2d.SurfaceData;
30
import sun.java2d.loops.SurfaceType;
31
import sun.java2d.loops.TransformBlit;
32
import sun.java2d.pipe.DrawImage;
33
34
import java.awt.Color;
35
import java.awt.Image;
36
import java.awt.geom.AffineTransform;
37
import java.awt.image.AffineTransformOp;
38
import java.awt.image.BufferedImage;
39
import java.awt.image.BufferedImageOp;
40
41
public class MTLDrawImage extends DrawImage {
42
43
@Override
44
protected void renderImageXform(SunGraphics2D sg, Image img,
45
AffineTransform tx, int interpType,
46
int sx1, int sy1, int sx2, int sy2,
47
Color bgColor)
48
{
49
// punt to the MediaLib-based transformImage() in the superclass if:
50
// - bicubic interpolation is specified
51
// - a background color is specified and will be used
52
// - the source surface is neither a texture nor render-to-texture
53
// surface, and a non-default interpolation hint is specified
54
// (we can only control the filtering for texture->surface
55
// copies)
56
// REMIND: we should tweak the sw->texture->surface
57
// transform case to handle filtering appropriately
58
// (see 4841762)...
59
// - an appropriate TransformBlit primitive could not be found
60
if (interpType != AffineTransformOp.TYPE_BICUBIC) {
61
SurfaceData dstData = sg.surfaceData;
62
SurfaceData srcData =
63
dstData.getSourceSurfaceData(img,
64
SunGraphics2D.TRANSFORM_GENERIC,
65
sg.imageComp,
66
bgColor);
67
68
if (srcData != null &&
69
!isBgOperation(srcData, bgColor) &&
70
(srcData.getSurfaceType() == MTLSurfaceData.MTLTexture ||
71
srcData.getSurfaceType() == MTLSurfaceData.MTLSurfaceRTT ||
72
interpType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR))
73
{
74
SurfaceType srcType = srcData.getSurfaceType();
75
SurfaceType dstType = dstData.getSurfaceType();
76
TransformBlit blit = TransformBlit.getFromCache(srcType,
77
sg.imageComp,
78
dstType);
79
80
if (blit != null) {
81
blit.Transform(srcData, dstData,
82
sg.composite, sg.getCompClip(),
83
tx, interpType,
84
sx1, sy1, 0, 0, sx2-sx1, sy2-sy1);
85
return;
86
}
87
}
88
}
89
90
super.renderImageXform(sg, img, tx, interpType,
91
sx1, sy1, sx2, sy2, bgColor);
92
}
93
94
@Override
95
public void transformImage(SunGraphics2D sg, BufferedImage img,
96
BufferedImageOp op, int x, int y)
97
{
98
if (op != null) {
99
if (op instanceof AffineTransformOp) {
100
AffineTransformOp atop = (AffineTransformOp) op;
101
transformImage(sg, img, x, y,
102
atop.getTransform(),
103
atop.getInterpolationType());
104
return;
105
} else {
106
if (MTLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
107
return;
108
}
109
}
110
img = op.filter(img, null);
111
}
112
copyImage(sg, img, x, y, null);
113
}
114
}
115
116