Skip to content

Commit d67c47f

Browse files
jgneffkevinrushforth
authored andcommitted
8201567: QuantumRenderer modifies buffer in use by JavaFX Application Thread
Reviewed-by: kcr, arapte
1 parent 126637f commit d67c47f

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Pixels.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ public final int getBytesPerComponent() {
167167
return this.bytesPerComponent;
168168
}
169169

170-
/*
171-
* Return the original pixels buffer.
170+
/**
171+
* Rewinds and returns the buffer used to create this {@code Pixels} object.
172+
*
173+
* @return the original pixels buffer with its position set to zero and its
174+
* mark discarded
172175
*/
173176
public final Buffer getPixels() {
174177
if (this.bytes != null) {
@@ -182,6 +185,21 @@ public final Buffer getPixels() {
182185
}
183186
}
184187

188+
/**
189+
* Returns the buffer used to create this {@code Pixels} object.
190+
*
191+
* @return the original pixels buffer, unmodified
192+
*/
193+
public final Buffer getBuffer() {
194+
if (this.bytes != null) {
195+
return this.bytes;
196+
} else if (this.ints != null) {
197+
return this.ints;
198+
} else {
199+
throw new RuntimeException("Unexpected Pixels state.");
200+
}
201+
}
202+
185203
/*
186204
* Return a copy of pixels as bytes.
187205
*/

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/EPDFrameBuffer.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,11 @@ int getByteOffset() {
582582
*/
583583
ByteBuffer getOffscreenBuffer() {
584584
/*
585-
* Allocates a direct byte buffer to avoid bug JDK-8201567,
586-
* "QuantumRenderer modifies buffer in use by JavaFX Application Thread"
587-
* <https://bugs.openjdk.java.net/browse/JDK-8201567>.
585+
* In this case, a direct byte buffer outside of the normal heap is
586+
* faster than a non-direct byte buffer on the heap. The frame rate is
587+
* roughly 10 to 40 percent faster for a framebuffer with 8 bits per
588+
* pixel and 40 to 60 percent faster for a framebuffer with 16 bits per
589+
* pixel, depending on the device processor and screen size.
588590
*/
589591
int size = xresVirtual * yres * Integer.BYTES;
590592
return ByteBuffer.allocateDirect(size);

modules/javafx.graphics/src/main/java/com/sun/prism/impl/QueuedPixelSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public synchronized void skipLatestPixels() {
100100
private boolean usesSameBuffer(Pixels p1, Pixels p2) {
101101
if (p1 == p2) return true;
102102
if (p1 == null || p2 == null) return false;
103-
return (p1.getPixels() == p2.getPixels());
103+
return (p1.getBuffer() == p2.getBuffer());
104104
}
105105

106106
/**

0 commit comments

Comments
 (0)