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:

"QuantumRenderer-0"
    at com.sun.glass.ui.Pixels.getPixels
        (Pixels.java:164)
    at com.sun.prism.impl.QueuedPixelSource.usesSameBuffer
        (QueuedPixelSource.java:103)
    at com.sun.prism.impl.QueuedPixelSource.getUnusedPixels
        (QueuedPixelSource.java:129)
    ...

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