Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8289756

Do not always request 16x16 icon

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 20
    • client-libs

      When an icon is extracted, 16×16 is always extracted even though it's not used.

      This code wasn't part of JDK-8182043, it was removed to address this comment [1].

      Yet it proved that small (16×16) isn't always extracted with that approach [2]. JDK-8282526 brings extraction of 16x16 icon back [3][4].

      Even though it doesn't seem to add any performance penalty [4], "...there is no performance impact at all from the latest changes...", I think a cleaner way would be extract only one icon.

      If the icon size requested is less than 24, set the size to `16 << 16` and extract only the small icon only; otherwise, extract the large icon.

      Something like this should work:
                  if (size < 24) {
                      iconSize = (size << 16);
                      hres = pIcon->Extract(szBuf, index, NULL, &hIcon, iconSize);
                  } else {
                      iconSize = size;
                      hres = pIcon->Extract(szBuf, index, &hIcon, NULL, iconSize);
                  }

      // hIcon is the handle to the icon


      References:
      [1] https://github.com/openjdk/jdk/pull/380#discussion_r500639220
      [2] https://github.com/openjdk/jdk/blob/94127f43a4a28a89094fa93cd1da49763134f9db/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp#L983-L986
      [3] https://github.com/openjdk/jdk/pull/7805#issuecomment-1148010850
      [4] https://github.com/openjdk/jdk/blob/3d177fea00efe68e742db91f05f82a692957670c/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp#L985-L994

            kizune Alexander Zuev
            aivanov Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: