Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
8201567: QuantumRenderer modifies buffer in use by JavaFX Application…
… Thread
Reviewed-by: kcr, arapte
- Loading branch information
|
@@ -167,8 +167,11 @@ public final int getBytesPerComponent() { |
|
|
return this.bytesPerComponent; |
|
|
} |
|
|
|
|
|
/* |
|
|
* Return the original pixels buffer. |
|
|
/** |
|
|
* Rewinds and returns the buffer used to create this {@code Pixels} object. |
|
|
* |
|
|
* @return the original pixels buffer with its position set to zero and its |
|
|
* mark discarded |
|
|
*/ |
|
|
public final Buffer getPixels() { |
|
|
if (this.bytes != null) { |
|
@@ -182,6 +185,21 @@ public final Buffer getPixels() { |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Returns the buffer used to create this {@code Pixels} object. |
|
|
* |
|
|
* @return the original pixels buffer, unmodified |
|
|
*/ |
|
|
public final Buffer getBuffer() { |
|
|
if (this.bytes != null) { |
|
|
return this.bytes; |
|
|
} else if (this.ints != null) { |
|
|
return this.ints; |
|
|
} else { |
|
|
throw new RuntimeException("Unexpected Pixels state."); |
|
|
} |
|
|
} |
|
|
|
|
|
/* |
|
|
* Return a copy of pixels as bytes. |
|
|
*/ |
|
|
|
@@ -582,9 +582,11 @@ int getByteOffset() { |
|
|
*/ |
|
|
ByteBuffer getOffscreenBuffer() { |
|
|
/* |
|
|
* Allocates a direct byte buffer to avoid bug JDK-8201567, |
|
|
* "QuantumRenderer modifies buffer in use by JavaFX Application Thread" |
|
|
* <https://bugs.openjdk.java.net/browse/JDK-8201567>. |
|
|
* In this case, a direct byte buffer outside of the normal heap is |
|
|
* faster than a non-direct byte buffer on the heap. The frame rate is |
|
|
* roughly 10 to 40 percent faster for a framebuffer with 8 bits per |
|
|
* pixel and 40 to 60 percent faster for a framebuffer with 16 bits per |
|
|
* pixel, depending on the device processor and screen size. |
|
|
*/ |
|
|
int size = xresVirtual * yres * Integer.BYTES; |
|
|
return ByteBuffer.allocateDirect(size); |
|
|
|
@@ -100,7 +100,7 @@ public synchronized void skipLatestPixels() { |
|
|
private boolean usesSameBuffer(Pixels p1, Pixels p2) { |
|
|
if (p1 == p2) return true; |
|
|
if (p1 == null || p2 == null) return false; |
|
|
return (p1.getPixels() == p2.getPixels()); |
|
|
return (p1.getBuffer() == p2.getBuffer()); |
|
|
} |
|
|
|
|
|
/** |
|
|