Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/java2d/marlin/StrokedLinePerf.java
41149 views
1
/*
2
* Copyright (c) 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.awt.BasicStroke;
25
import java.awt.Graphics2D;
26
import java.awt.RenderingHints;
27
import java.awt.Stroke;
28
import java.awt.geom.Line2D;
29
import java.awt.image.BufferedImage;
30
31
import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE;
32
33
/**
34
* @test
35
* @bug 7018932
36
* @summary fix LoopPipe.getStrokedSpans() performance (clipping enabled by Marlin renderer)
37
* @run main/othervm/timeout=10 -Dsun.java2d.renderer=sun.java2d.marlin.DMarlinRenderingEngine StrokedLinePerf
38
*/
39
public class StrokedLinePerf {
40
41
public static void main(String[] unused) {
42
BufferedImage bi = new BufferedImage(400, 400, TYPE_INT_ARGB_PRE);
43
test(bi, true);
44
test(bi, false);
45
}
46
47
private static void test(BufferedImage bi, boolean useAA) {
48
final long start = System.nanoTime();
49
50
final Graphics2D g2d = bi.createGraphics();
51
52
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
53
(useAA) ? RenderingHints.VALUE_ANTIALIAS_ON
54
: RenderingHints.VALUE_ANTIALIAS_OFF);
55
56
Stroke stroke = new BasicStroke(2.0f, 1, 0, 1.0f, new float[]{0.0f, 4.0f}, 0.0f);
57
g2d.setStroke(stroke);
58
59
//Large values to trigger crash / infinite loop.
60
g2d.draw(new Line2D.Double(4.0, 1.794369841E9, 567.0, -2.147483648E9));
61
62
System.out.println("StrokedLinePerf(" + useAA + "): Test duration= " + (1e-6 * (System.nanoTime() - start)) + " ms.");
63
g2d.dispose();
64
}
65
}
66
67