Android: Add option to mirror vertically in EglRenderer
Bug: None
Change-Id: I4f46f9f0e1fa3805880335ebb6a767b8cb33f8c6
Reviewed-on: https://webrtc-review.googlesource.com/c/114540
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26028}
diff --git a/sdk/android/api/org/webrtc/EglRenderer.java b/sdk/android/api/org/webrtc/EglRenderer.java
index c369527..d87c517 100644
--- a/sdk/android/api/org/webrtc/EglRenderer.java
+++ b/sdk/android/api/org/webrtc/EglRenderer.java
@@ -136,7 +136,9 @@
private final Object layoutLock = new Object();
private float layoutAspectRatio;
// If true, mirrors the video stream horizontally.
- private boolean mirror;
+ private boolean mirrorHorizontally;
+ // If true, mirrors the video stream vertically.
+ private boolean mirrorVertically;
// These variables are synchronized on |statisticsLock|.
private final Object statisticsLock = new Object();
@@ -342,12 +344,22 @@
}
/**
- * Set if the video stream should be mirrored or not.
+ * Set if the video stream should be mirrored horizontally or not.
*/
public void setMirror(final boolean mirror) {
- logD("setMirror: " + mirror);
+ logD("setMirrorHorizontally: " + mirror);
synchronized (layoutLock) {
- this.mirror = mirror;
+ this.mirrorHorizontally = mirror;
+ }
+ }
+
+ /**
+ * Set if the video stream should be mirrored vertically or not.
+ */
+ public void setMirrorVertically(final boolean mirrorVertically) {
+ logD("setMirrorVertically: " + mirrorVertically);
+ synchronized (layoutLock) {
+ this.mirrorVertically = mirrorVertically;
}
}
@@ -621,8 +633,7 @@
drawMatrix.reset();
drawMatrix.preTranslate(0.5f, 0.5f);
- if (mirror)
- drawMatrix.preScale(-1f, 1f);
+ drawMatrix.preScale(mirrorHorizontally ? -1f : 1f, mirrorVertically ? -1f : 1f);
drawMatrix.preScale(scaleX, scaleY);
drawMatrix.preTranslate(-0.5f, -0.5f);
@@ -657,8 +668,7 @@
drawMatrix.reset();
drawMatrix.preTranslate(0.5f, 0.5f);
- if (mirror)
- drawMatrix.preScale(-1f, 1f);
+ drawMatrix.preScale(mirrorHorizontally ? -1f : 1f, mirrorVertically ? -1f : 1f);
drawMatrix.preScale(1f, -1f); // We want the output to be upside down for Bitmap.
drawMatrix.preTranslate(-0.5f, -0.5f);