Skip to content

Commit 2dad883

Browse files
committed
Review feedback: floating point precision in test, ensure unsigned int handling in Robot
1 parent 20c2375 commit 2dad883

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

modules/javafx.graphics/src/main/native-glass/mac/GlassRobot.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,15 @@ - (void)mouseRelease:(UInt32)buttons
412412
CFDataRef data = CGDataProviderCopyData(provider);
413413
if (data != NULL)
414414
{
415-
jint *pixels = (jint*)CFDataGetBytePtr(data);
415+
uint32_t *pixels = (uint32_t*)CFDataGetBytePtr(data);
416416
if (pixels != NULL)
417417
{
418-
color = *pixels;
418+
uint32_t pixel = *pixels;
419419
CGFloat components[4];
420-
components[0] = (CGFloat)((color & 0x00FF0000) >> 16) / 255.0;
421-
components[1] = (CGFloat)((color & 0x0000FF00) >> 8) / 255.0;
422-
components[2] = (CGFloat)((color & 0x000000FF)) / 255.0;
423-
components[3] = (CGFloat)((color & 0xFF000000) >> 24) / 255.0;
420+
components[0] = (CGFloat)((pixel & 0x00FF0000) >> 16) / 255.0;
421+
components[1] = (CGFloat)((pixel & 0x0000FF00) >> 8) / 255.0;
422+
components[2] = (CGFloat)((pixel & 0x000000FF)) / 255.0;
423+
components[3] = (CGFloat)((pixel & 0xFF000000) >> 24) / 255.0;
424424
origColor = CGColorCreate(CGImageGetColorSpace(screenImage), components);
425425
}
426426
}

tests/system/src/test/java/test/robot/javafx/scene/SRGBTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ public class SRGBTest extends VisualTestBase {
6464
static final float HIGH = 0.75f;
6565

6666
// The component tolerance allows one bit of rounding when writing a color
67-
// out and another bit when reading it back in.
68-
static final double COMPONENT_TOLERANCE = 2.0 / 255.0;
67+
// out and another bit when reading it back in. The additional 0.0001
68+
// accounts for floating point precision limitations.
69+
static final double COMPONENT_TOLERANCE = 2.0001 / 255.0;
6970

7071
private enum TestColor {
7172
COLOR_01(LOW, MID, HIGH),

0 commit comments

Comments
 (0)