On 7/21/2016 5:25 PM, Rajeev Chamyal wrote:

Hello Semyon,

The resolution variant image returned is based on the implementation of BaseMultiResolutionImage::getResolutionVariant API.

Current implementation of BaseMultiResolutionImage::getResolutionVariant returns a resolution variant image which has width and height greater than or equal to the passed width and height.

  There is a known issue on it:
JDK-8148619 Select the closest resolution variant in BaseMultiResolutionImage
      https://bugs.openjdk.java.net/browse/JDK-8148619

  Thanks,
  Alexandr.

In the case you have suggested dimensions of RED and BLUE images are 32 and 80 respectively.

Width and height passed to getResolutionVariant is 64 i.e. scaled width and height of base image(RED) (GDK_SCALE=2) and blue image is getting returned.

The width and height passed to this API is that of base image not of the spot.

Applications can control this behaviour by overriding this API in derived classes.

Regards,

Rajeev Chamyal

*From:*Alexandr Scherbatiy
*Sent:* 21 July 2016 15:09
*To:* Semyon Sadetsky; Rajeev Chamyal; swing-dev@openjdk.java.net; Sergey Bylokhov *Subject:* Re: <Swing Dev>[9] Review Request JDK-8147648 [hidpi] multiresolution image: wrong resolution variant is used as icon in the Unity panel

On 7/21/2016 11:49 AM, Semyon Sadetsky wrote:

    Hello Rajeev,

    The taskbar icon is ok now.

    I change the resolution variants from the test a bit:

                    final BaseMultiResolutionImage IMG = new
    BaseMultiResolutionImage(
                            new BufferedImage[]{generateImage(4,
    Color.RED), generateImage(10, Color.BLUE)});

    And the icon I see in the taskbar and in the button is blue. It
    seems to me the first resolution variant (red) is more appropriate
    in this case because its size is closer to the spot. I'm not sure
    if this is an issue.

    I have an extra question to you and Alexander.
    Most native apps on Linux set an array of icons with _NET_WM_ICON.
    Usually they are [16x16, 32x32, 64x64].
    So, desktop environment may select icon of appropriate size.
    In this fix we are preselecting icon of a specific size in the app
    and send it to WM.
    Why not to send array of the resolution variants images and let
    the desktop environment to select the appropriate one, like native
    apps do?

This sounds as good idea. MultiResolutionImage has the special method for this "List<Image> getResolutionVariants()". We do the similar on Mac OS X where NSImage with several representations is created from a MultiResolutionImage: http://cr.openjdk.java.net/~alexsch/8028212/webrev.01/src/macosx/classes/sun/lwawt/macosx/CImage.java.udiff.html <http://cr.openjdk.java.net/%7Ealexsch/8028212/webrev.01/src/macosx/classes/sun/lwawt/macosx/CImage.java.udiff.html>

 It has sense to try the same approach on Linux.

  Thanks,
  Alexandr.



    --Semyon

    On 19.07.2016 23:26, Rajeev Chamyal wrote:

        Hello Semyon,

        Please review the updated webrev.

        http://cr.openjdk.java.net/~rchamyal/8147648/webrev.03/
        <http://cr.openjdk.java.net/%7Erchamyal/8147648/webrev.03/>

        Regards,

        Rajeev Chamyal

        *From:*Semyon Sadetsky
        *Sent:* 14 July 2016 16:58
        *To:* Rajeev Chamyal; swing-dev@openjdk.java.net
        <mailto:swing-dev@openjdk.java.net>; Sergey Bylokhov;
        Alexander Scherbatiy
        *Subject:* Re: <Swing Dev>[9] Review Request JDK-8147648
        [hidpi] multiresolution image: wrong resolution variant is
        used as icon in the Unity panel

        Hi Rajeev,

        I have added 1px border to the icon in your test:

            private static BufferedImage generateImage(int scale,
        Color c) {
                int x = SZ * scale;
                BufferedImage img = new BufferedImage(x, x,
        BufferedImage.TYPE_INT_RGB);
                Graphics g = img.getGraphics();
                if (g != null) {
                    g.setColor(c);
                    g.fillRect(0, 0, x, x);
                    g.setColor(Color.YELLOW);
                    g.drawRect(0, 0, x-1, x-1);
                }
                return img;
            }

        It seems the icon in the taskbar is not correct for UI scale > 1.

        By the way, graphics object should be disposed using
        g.dispose() when it is not needed anymore.

        --Semyon


        On 14.07.2016 10:08, Rajeev Chamyal wrote:

            Hello All,

            Gentle reminder. Please review the updated webrev.

            http://cr.openjdk.java.net/~rchamyal/8147648/webrev.02/
            <http://cr.openjdk.java.net/%7Erchamyal/8147648/webrev.02/>

            Update: simplified the test.

            Regards,

            Rajeev Chamyal

            *From:*Alexandr Scherbatiy
            *Sent:* 22 June 2016 15:46
            *To:* Rajeev Chamyal; Sergey Bylokhov;
            swing-dev@openjdk.java.net <mailto:swing-dev@openjdk.java.net>
            *Subject:* Re: <Swing Dev>[9] Review Request JDK-8147648
            [hidpi] multiresolution image: wrong resolution variant is
            used as icon in the Unity panel

            The fix looks good to me.

            Thanks,
            Alexandr.

            On 6/22/2016 10:49 AM, Rajeev Chamyal wrote:

                Hello Alexandr,

                Thanks for the review. I have updated webrev as per
                comments.

                http://cr.openjdk.java.net/~rchamyal/8147648/webrev.01/
                <http://cr.openjdk.java.net/%7Erchamyal/8147648/webrev.01/>

                Regards,

                Rajeev Chamyal

                *From:*Alexandr Scherbatiy
                *Sent:* 21 June 2016 17:37
                *To:* Rajeev Chamyal; Sergey Bylokhov;
                swing-dev@openjdk.java.net
                <mailto:swing-dev@openjdk.java.net>
                *Subject:* Re: <Swing Dev>[9] Review Request
                JDK-8147648 [hidpi] multiresolution image: wrong
                resolution variant is used as icon in the Unity panel

                On 6/21/2016 12:16 PM, Rajeev Chamyal wrote:

                    Hello All,

                    Please review the following webrev.

                    Webrev:
                    http://cr.openjdk.java.net/~rchamyal/8147648/webrev.00/
                    <http://cr.openjdk.java.net/%7Erchamyal/8147648/webrev.00/>


                    Bug: https://bugs.openjdk.java.net/browse/JDK-8147648

                    Issue: Wrong resolution variant is used as icon in
                    the Unity panel.

                    Cause: The screen transforms are not applied to
                    find the correct resolution variant image in
                    current implementation.

                    Fix: Applied the screen transforms to graphics object.


                 222         int scaleX = (int)tx.getScaleX();
                 223         int scaleY = (int)tx.getScaleY();
                 224         DataBufferInt buffer = new
                DataBufferInt(scaleX * width * scaleY * height);

                  The fix is in the shared code and the scale factor
                can have floating point value on Windows. (for example
                1.5).
                  It is better to round the final width and height
                after scaling them.

                  Thanks,
                  Alexandr.

                    Regards,

                    Rajeev Chamyal


Reply via email to