United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7124520 [macosx] re:6373505 Toolkit.getScreenResolution() != GraphicsConfiguration.getNormalizingTransform()
JDK-7124520 : [macosx] re:6373505 Toolkit.getScreenResolution() != GraphicsConfiguration.getNormalizingTransform()

Details
Type:
Bug
Submit Date:
2011-12-23
Status:
Closed
Updated Date:
2014-03-11
Project Name:
JDK
Resolved Date:
2012-10-19
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
http://java.net/jira/browse/MACOSX_PORT-709 submitted 2011/11/16 by Yuri Nesterenko
Attached is a regression test to <span class=&quot;nobr&quot;><a href=&quot;http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373505&quot;>http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373505<sup><img class=&quot;rendericon&quot; src=&quot;/jira/images/icons/linkext7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/></sup></a></span> &#8211;
it's very short.
On my system toolkit reports screen resolution == 72 while default configuration of default screen device gets 85. Looks like the former one is hardcoded, isn't it?
The same test also fails on Apple JDK 6.

                                    

Comments
EVALUATION

Author: Yuri Nesterenko Date: 16/Nov/11 10:29 AM
Build: b217
closed/java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java
                                     
2011-12-23
EVALUATION

The test verifies that the result of Toolkit.getScreenResolution() is consistent with GraphicsConfiguration.getNormalizingTransform().

The actual implementation of Toolkit.getScreenResolution() (see src/macosx/classes/sun/awt/CGraphicsDevice.java) is

    public int getScreenResolution() {
        // TODO: report non-72 value when HiDPI is turned on
        return 72;
    }

The actual implementation of GraphicsConfiguration.getNormalizingTransform() (see src/macosx/native/sun/awt/CGraphicsDevice.m) is

JNIEXPORT jdouble JNICALL
Java_sun_awt_CGraphicsDevice_nativeGetXResolution
  (JNIEnv *env, jclass class, jint displayID)
{
    // TODO: this is the physically correct answer, but we probably want  
    // to use NSScreen API instead...

    CGSize size = CGDisplayScreenSize(displayID);
    CGRect rect = CGDisplayBounds(displayID);
    // 1 inch == 25.4 mm                                                                                                  
    jfloat inches = size.width / 25.4f;
    jfloat dpi = rect.size.width / inches;
    return dpi;
}

Looks like it's wrong that Toolkit.getScreenResolution() returns hardcoded value and its implementation should fetch the appropriate value from the native code like we do on other platforms.
                                     
2012-02-14
URL:   http://hg.openjdk.java.net/jdk8/awt/jdk/rev/6b16f6fc41c5
User:  serb
Date:  2012-10-19 11:29:28 +0000

                                     
2012-10-19
Testcase moved to java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java
                                     
2012-10-19
java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java

PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows.
Closed issue as Fixed/Verified.
                                     
2014-03-11



Hardware and Software, Engineered to Work Together