Commit f7c34177 authored by John Neffenger's avatar John Neffenger

Compare buffers without rewinding them

The QuantumRenderer calls the getPixels() method while trying to find a
buffer that's not in use, yet in doing so it can inadvertently rewind a
buffer in use by the JavaFX Application Thread. The stack of the call to
rewind() is:

    at com.sun.prism.impl.QueuedPixelSource.usesSameBuffer
    at com.sun.prism.impl.QueuedPixelSource.getUnusedPixels

Create a new method, getBuffer(), that returns the same ByteBuffer or
IntBuffer as getPixels() but does not rewind it, and change the method
usesSameBuffer(Pixels, Pixels) to call it instead of getPixels().

Fixes #1
parent a9236ad2
......@@ -168,6 +168,19 @@ public abstract class Pixels {
* Return the original pixels buffer without rewinding it.
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.
......@@ -100,7 +100,7 @@ public class QueuedPixelSource implements PixelSource {
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());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment