File tree 3 files changed +26
-6
lines changed
modules/javafx.graphics/src/main/java/com/sun
3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -167,8 +167,11 @@ public final int getBytesPerComponent() {
167
167
return this .bytesPerComponent ;
168
168
}
169
169
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
172
175
*/
173
176
public final Buffer getPixels () {
174
177
if (this .bytes != null ) {
@@ -182,6 +185,21 @@ public final Buffer getPixels() {
182
185
}
183
186
}
184
187
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
+
185
203
/*
186
204
* Return a copy of pixels as bytes.
187
205
*/
Original file line number Diff line number Diff line change @@ -582,9 +582,11 @@ int getByteOffset() {
582
582
*/
583
583
ByteBuffer getOffscreenBuffer () {
584
584
/*
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.
588
590
*/
589
591
int size = xresVirtual * yres * Integer .BYTES ;
590
592
return ByteBuffer .allocateDirect (size );
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ public synchronized void skipLatestPixels() {
100
100
private boolean usesSameBuffer (Pixels p1 , Pixels p2 ) {
101
101
if (p1 == p2 ) return true ;
102
102
if (p1 == null || p2 == null ) return false ;
103
- return (p1 .getPixels () == p2 .getPixels ());
103
+ return (p1 .getBuffer () == p2 .getBuffer ());
104
104
}
105
105
106
106
/**
You can’t perform that action at this time.
0 commit comments