Skip to content

Commit 42c9f65

Browse files
Yuri Nesterenkognu-andrew
Yuri Nesterenko
authored andcommittedJul 6, 2024
8320097: Improve Image transformations
Reviewed-by: mbalao, andrew Backport-of: 1401634b21b76db90291011bcae68c461742e687
1 parent 45b83c2 commit 42c9f65

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
 

‎jdk/src/share/classes/sun/java2d/pipe/DrawImage.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -367,6 +367,13 @@ protected void renderImageXform(SunGraphics2D sg, Image img,
367367
final AffineTransform itx;
368368
try {
369369
itx = tx.createInverse();
370+
double[] mat = new double[6];
371+
itx.getMatrix(mat);
372+
for (double d : mat) {
373+
if (!Double.isFinite(d)) {
374+
return;
375+
}
376+
}
370377
} catch (final NoninvertibleTransformException ignored) {
371378
// Non-invertible transform means no output
372379
return;

‎jdk/src/share/native/sun/java2d/loops/TransformHelper.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -120,7 +120,12 @@ TransformInterpFunc *pBicubicFunc = BicubicInterp;
120120
/* We reject coordinates not less than 1<<30 so that the distance between */
121121
/* any 2 of them is less than 1<<31 which would overflow into the sign */
122122
/* bit of a signed long value used to represent fixed point coordinates. */
123-
#define TX_FIXED_UNSAFE(v) (fabs(v) >= (1<<30))
123+
#if !defined(_MSC_VER) && (defined(__STDC_VERSION__) && __STDC_VERSION__ <= 199409)
124+
#if !defined(isinf)
125+
#define isinf(x) (!finite(x))
126+
#endif
127+
#endif
128+
#define TX_FIXED_UNSAFE(v) (isinf(v) || isnan(v) || fabs(v) >= (1<<30))
124129
static jboolean
125130
checkOverflow(jint dxoff, jint dyoff,
126131
SurfaceDataBounds *pBounds,

0 commit comments

Comments
 (0)
Please sign in to comment.