| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5602ead commit 225c750
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -881,7 +881,7 @@ public void disposeSourceBuffer() { | |||
| 881 | 881 | public void getBufferPixels(int[] pixels) { | |
| 882 | 882 | BufferData data = null; | |
| 883 | 883 | 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 | ||
| 885 | 885 | // texture | |
| 886 | 886 | data = usedBuffers.getLast(); | |
| 887 | 887 | } else if (bufferCache != null && 0 < bufferCache.size()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,6 +107,7 @@ public class Capture extends PImage implements PConstants { | |||
| 107 | 107 | protected int reqHeight; | |
| 108 | 108 | ||
| 109 | 109 | protected boolean useBufferSink = false; | |
| 110 | + protected boolean outdatedPixels = true; | ||
| 110 | 111 | protected Object bufferSink; | |
| 111 | 112 | protected Method sinkCopyMethod; | |
| 112 | 113 | protected Method sinkSetMethod; | |
@@ -375,6 +376,7 @@ public synchronized void read() { | |||
| 375 | 376 | } | |
| 376 | 377 | ||
| 377 | 378 | if (useBufferSink) { // The native buffer from gstreamer is copied to the buffer sink. | |
| 379 | + outdatedPixels = true; | ||
| 378 | 380 | if (natBuffer == null) { | |
| 379 | 381 | return; | |
| 380 | 382 | } | |
@@ -442,10 +444,32 @@ public synchronized void loadPixels() { | |||
| 442 | 444 | e.printStackTrace(); | |
| 443 | 445 | } | |
| 444 | 446 | } | |
| 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; | ||
| 445 | 454 | } | |
| 446 | 455 | } | |
| 447 | 456 | ||
| 448 | 457 | ||
| 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 | + | ||
| 449 | 473 | //////////////////////////////////////////////////////////// | |
| 450 | 474 | ||
| 451 | 475 | // List methods. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,6 +79,7 @@ public class Movie extends PImage implements PConstants { | |||
| 79 | 79 | protected boolean seeking = false; | |
| 80 | 80 | ||
| 81 | 81 | protected boolean useBufferSink = false; | |
| 82 | + protected boolean outdatedPixels = true; | ||
| 82 | 83 | protected Object bufferSink; | |
| 83 | 84 | protected Method sinkCopyMethod; | |
| 84 | 85 | protected Method sinkSetMethod; | |
@@ -487,6 +488,7 @@ public synchronized void read() { | |||
| 487 | 488 | } | |
| 488 | 489 | ||
| 489 | 490 | if (useBufferSink) { // The native buffer from gstreamer is copied to the buffer sink. | |
| 491 | + outdatedPixels = true; | ||
| 490 | 492 | if (natBuffer == null) { | |
| 491 | 493 | return; | |
| 492 | 494 | } | |
@@ -565,11 +567,33 @@ public synchronized void loadPixels() { | |||
| 565 | 567 | } catch (Exception e) { | |
| 566 | 568 | e.printStackTrace(); | |
| 567 | 569 | } | |
| 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; | ||
| 569 | 578 | } | |
| 570 | 579 | } | |
| 571 | 580 | ||
| 572 | 581 | ||
| 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 | + | ||
| 573 | 597 | //////////////////////////////////////////////////////////// | |
| 574 | 598 | ||
| 575 | 599 | // Initialization methods. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments