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

Provide public API to make natively rendered images cacheable

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • CPU:
      x86
    • OS:
      os_x

      Description

      A DESCRIPTION OF THE REQUEST :
      BufferedImages created from primitive arrays or whose data buffer arrays have been exposed are marked as untrackable and thus prevented from being cached in a GPU. A public API is requested to allow such images to be marked as immutable to permit caching. This API would replace uses of the internal stealData/markDirty API, which will become inaccessible in JDK 9.

      Relevant labels: modularization, jdkinternals


      JUSTIFICATION :
      When using native code to render images, a common technique used in the JDK is to create a BufferedImage, extract the internal data buffer array using SunWritableRaster.stealData(), pass the array to native code where it is filled, then call SunWritableRaster.markDirty() to inform the graphics system that the image data has been modified. This technique allows the natively rendered image to be cached, and it avoids making a copy of the image data.

      A public API is needed so that code outside the JDK can accomplish this task in JDK 9, where the internal class SunWritableRaster will be inaccessible.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Rather than expose the existing API, my suggestion is to add an API to change the state of a BufferedImage to immutable. This API would support the above usage. It would also support creating the primitive array first, filling it using native code, then using the array to create an image.

      Although this API gives programmers a new way to make a mistake (if they later modify the array), the only consequence (I believe) is that stale pixels may be displayed.

      ACTUAL -
      Currently native rendering into a primitive array without using an internal API requires copying the data in some manner to create a cacheable image.


        Attachments

          Activity

            People

            Assignee:
            prr Philip Race
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: