Stop assuming that our render pipeline will only process RGB frames

For one, we have already switched to RGBA some time ago, so the name was
technically incorrect already.
But the main reason is that we'll want to use them for depth maps as well (and
potentially maybe even for HDR images if that's possible with canvas?).
This commit is contained in:
Jonas Herzig
2020-10-03 14:41:08 +02:00
parent 4c4c052d8a
commit aee486c4f3
19 changed files with 165 additions and 136 deletions

View File

@@ -6,19 +6,19 @@ import org.apache.commons.lang3.Validate;
import java.nio.ByteBuffer;
public class RGBFrame implements Frame {
public class BitmapFrame implements Frame {
private final int frameId;
private final ReadableDimension size;
private final int bytesPerPixel;
private final ByteBuffer byteBuffer;
public RGBFrame(int frameId, ReadableDimension size, ByteBuffer byteBuffer) {
Validate.isTrue(size.getWidth() * size.getHeight() * 4 == byteBuffer.remaining(),
public BitmapFrame(int frameId, ReadableDimension size, int bytesPerPixel, ByteBuffer byteBuffer) {
Validate.isTrue(size.getWidth() * size.getHeight() * bytesPerPixel == byteBuffer.remaining(),
"Buffer size is %d (cap: %d) but should be %d",
byteBuffer.remaining(), byteBuffer.capacity(), size.getWidth() * size.getHeight() * 4);
byteBuffer.remaining(), byteBuffer.capacity(), size.getWidth() * size.getHeight() * bytesPerPixel);
this.frameId = frameId;
this.size = size;
this.bytesPerPixel = bytesPerPixel;
this.byteBuffer = byteBuffer;
}
@@ -30,6 +30,10 @@ public class RGBFrame implements Frame {
return this.size;
}
public int getBytesPerPixel() {
return bytesPerPixel;
}
public ByteBuffer getByteBuffer() {
return this.byteBuffer;
}

View File

@@ -7,14 +7,14 @@ import java.nio.ByteBuffer;
public class OpenGlFrame implements Frame {
private final int frameId;
private final ReadableDimension size;
private final int bytesPerPixel;
private final ByteBuffer byteBuffer;
public OpenGlFrame(int frameId, ReadableDimension size, ByteBuffer byteBuffer) {
public OpenGlFrame(int frameId, ReadableDimension size, int bytesPerPixel, ByteBuffer byteBuffer) {
this.frameId = frameId;
this.size = size;
this.bytesPerPixel = bytesPerPixel;
this.byteBuffer = byteBuffer;
}
@@ -26,6 +26,10 @@ public class OpenGlFrame implements Frame {
return this.size;
}
public int getBytesPerPixel() {
return bytesPerPixel;
}
public ByteBuffer getByteBuffer() {
return this.byteBuffer;
}