JDK-8119975 : Implementation of floating point viewports may not match what developers want or expect
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx2.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2012-02-28
  • Updated: 2015-06-17
  • Resolved: 2012-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7u6Fixed
Related Reports
Relates :  
Description
We fixed the implementation of viewports in the presence of scaling and fit-dimensions in 2.1 to match what the code appeared to be trying to do, but in doing so it raised questions as to whether that behavior was really desirable.

Specifically, the code appears to simulate what the image would look like if you extracted the pixels into a separate, smaller, cropped image and then did its standard rendering from that cropped version.  The primary visual effect of that theoretical procedure would be that the outer 0.5 pixels of the source image are clamped to the value of the pixels on the edge rather than blended to transparency or blended with the next pixel over in the whole image.

That behavior matches what Java2D does, but Java2D had only integer values for the subpixel coordinates so the concept of "pretending the image only had the pixels that appear in the defined subimage" made more sense.  Unfortunately, the FX ImageView object has floating point coordinates for its viewport so it begs the question - what does it mean to extract the image that consists only of "these pixels plus this fraction of those pixels" when the floating point viewport coordinates are not integers?  In fact, the ImageView's viewport parameters seem more similar to the concept of 3D texture mapping which does not simulate "edge conditions" for the edges of the texture coordinates when they represent a sub-image.

Finally, with floating point coordinates for the subimage, the operation seems more similar to the HTML5 drawImage() method that takes a set of source rectangle coordinates (in floating point).  We should look at what that API defines for subimages and consider that that behavior is already locked into the expectations of our target developers.

Once we decide what the behavior that we actually want is, it should be a simple matter of implementing the new behavior, but we need to investigate HTML5 and create a demo app that shows the differences so our API designers can make a decision...
Comments
verified in 2.2.0b18
26-07-2012

Fixed with the following changeset: changeset: 16212:fb9375368023 date: Tue Jun 05 10:04:22 2012 -0700 summary: Fix RT-19962: Floating point Viewports implement confusing behavior.
05-06-2012

Bug court review (March 19, 2012): Defer to JavaFX 2.2 from RM, Dev (for Nandini Ramani), Arch, SQE
19-03-2012

See the test cases in RT-19306 for examples that show off the issues involved.
19-03-2012