FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix #2202 · ranlevinstein/processing@225c750 · GitHub

Repository navigation

Commit 225c750

Browse files
committed
1 parent 5602ead commit 225c750

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

‎core/src/processing/opengl/Texture.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ public void disposeSourceBuffer() {
881881
public void getBufferPixels(int[] pixels) {
882882
BufferData data = null;
883883
if (usedBuffers != null && 0 < usedBuffers.size()) {
884-
// the last used buffer is the one currently stored in the opengl the
884+
// the last used buffer is the one currently stored in the opengl
885885
// texture
886886
data = usedBuffers.getLast();
887887
} else if (bufferCache != null && 0 < bufferCache.size()) {

‎java/libraries/video/src/processing/video/Capture.java‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public class Capture extends PImage implements PConstants {
107107
protected int reqHeight;
108108

109109
protected boolean useBufferSink = false;
110+
protected boolean outdatedPixels = true;
110111
protected Object bufferSink;
111112
protected Method sinkCopyMethod;
112113
protected Method sinkSetMethod;
@@ -375,6 +376,7 @@ public synchronized void read() {
375376
}
376377

377378
if (useBufferSink) { // The native buffer from gstreamer is copied to the buffer sink.
379+
outdatedPixels = true;
378380
if (natBuffer == null) {
379381
return;
380382
}
@@ -442,10 +444,32 @@ public synchronized void loadPixels() {
442444
e.printStackTrace();
443445
}
444446
}
447+
448+
// super.loadPixels() sets loaded to true, but in the useBufferSink mode,
449+
// the contents of the pixels array is overriden by the buffers coming
450+
// from gstreamer, so we don't want PGraphicsOpenGL replacing the OpenGL
451+
// texture with the pixels.
452+
setLoaded(false);
453+
outdatedPixels = false;
445454
}
446455
}
447456

448457

458+
public int get(int x, int y) {
459+
if (outdatedPixels) loadPixels();
460+
return super.get(x, y);
461+
}
462+
463+
464+
protected void getImpl(int sourceX, int sourceY,
465+
int sourceWidth, int sourceHeight,
466+
PImage target, int targetX, int targetY) {
467+
if (outdatedPixels) loadPixels();
468+
super.getImpl(sourceX, sourceY, sourceWidth, sourceHeight,
469+
target, targetX, targetY);
470+
}
471+
472+
449473
////////////////////////////////////////////////////////////
450474

451475
// List methods.

‎java/libraries/video/src/processing/video/Movie.java‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Movie extends PImage implements PConstants {
7979
protected boolean seeking = false;
8080

8181
protected boolean useBufferSink = false;
82+
protected boolean outdatedPixels = true;
8283
protected Object bufferSink;
8384
protected Method sinkCopyMethod;
8485
protected Method sinkSetMethod;
@@ -487,6 +488,7 @@ public synchronized void read() {
487488
}
488489

489490
if (useBufferSink) { // The native buffer from gstreamer is copied to the buffer sink.
491+
outdatedPixels = true;
490492
if (natBuffer == null) {
491493
return;
492494
}
@@ -565,11 +567,33 @@ public synchronized void loadPixels() {
565567
} catch (Exception e) {
566568
e.printStackTrace();
567569
}
568-
}
570+
}
571+
572+
// super.loadPixels() sets loaded to true, but in the useBufferSink mode,
573+
// the contents of the pixels array is overriden by the buffers coming
574+
// from gstreamer, so we don't want PGraphicsOpenGL replacing the OpenGL
575+
// texture with the pixels.
576+
setLoaded(false);
577+
outdatedPixels = false;
569578
}
570579
}
571580

572581

582+
public int get(int x, int y) {
583+
if (outdatedPixels) loadPixels();
584+
return super.get(x, y);
585+
}
586+
587+
588+
protected void getImpl(int sourceX, int sourceY,
589+
int sourceWidth, int sourceHeight,
590+
PImage target, int targetX, int targetY) {
591+
if (outdatedPixels) loadPixels();
592+
super.getImpl(sourceX, sourceY, sourceWidth, sourceHeight,
593+
target, targetX, targetY);
594+
}
595+
596+
573597
////////////////////////////////////////////////////////////
574598

575599
// Initialization methods.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL