Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8201567: QuantumRenderer modifies buffer in use by JavaFX Application Thread #255

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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());
}

/**
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.