Chromium Code Reviews| Index: webrtc/api/android/java/src/org/webrtc/EglRenderer.java |
| diff --git a/webrtc/api/android/java/src/org/webrtc/EglRenderer.java b/webrtc/api/android/java/src/org/webrtc/EglRenderer.java |
| index 65961bb56021d0c4bdc6472ed72a1bd0601145a2..b6dd649a5204bfddbd9323918f81dc2dc8bfd25a 100644 |
| --- a/webrtc/api/android/java/src/org/webrtc/EglRenderer.java |
| +++ b/webrtc/api/android/java/src/org/webrtc/EglRenderer.java |
| @@ -533,6 +533,8 @@ public class EglRenderer implements VideoRenderer.Callbacks { |
| // After a surface size change, the EGLSurface might still have a buffer of the old size in the |
| // pipeline. Querying the EGLSurface will show if the underlying buffer dimensions haven't yet |
| // changed. Such a buffer will be rendered incorrectly, so flush it with a black frame. |
| + final int drawnFrameWidth; |
| + final int drawnFrameHeight; |
| synchronized (layoutLock) { |
| int surfaceClearCount = 0; |
| while (eglBase.surfaceWidth() != surfaceWidth || eglBase.surfaceHeight() != surfaceHeight) { |
| @@ -548,11 +550,20 @@ public class EglRenderer implements VideoRenderer.Callbacks { |
| } |
| final float[] layoutMatrix; |
| if (layoutAspectRatio > 0) { |
| - layoutMatrix = RendererCommon.getLayoutMatrix( |
| - mirror, frame.rotatedWidth() / (float) frame.rotatedHeight(), layoutAspectRatio); |
| + final float frameAspectRatio = frame.rotatedWidth() / (float) frame.rotatedHeight(); |
| + layoutMatrix = RendererCommon.getLayoutMatrix(mirror, frameAspectRatio, layoutAspectRatio); |
| + if (frameAspectRatio > layoutAspectRatio) { |
|
magjed_webrtc
2016/11/18 16:31:17
I find it easier with:
drawnFrameWidth = Math.min(
magjed_webrtc
2016/11/21 10:00:45
Nevermind, this is fine.
|
| + drawnFrameWidth = (int) (frame.rotatedHeight() * layoutAspectRatio); |
| + drawnFrameHeight = frame.rotatedHeight(); |
| + } else { |
| + drawnFrameWidth = frame.rotatedWidth(); |
| + drawnFrameHeight = (int) (frame.rotatedWidth() / layoutAspectRatio); |
| + } |
| } else { |
| layoutMatrix = |
| mirror ? RendererCommon.horizontalFlipMatrix() : RendererCommon.identityMatrix(); |
| + drawnFrameWidth = frame.rotatedWidth(); |
| + drawnFrameHeight = frame.rotatedHeight(); |
| } |
| drawMatrix = RendererCommon.multiplyMatrices(texMatrix, layoutMatrix); |
| } |
| @@ -567,12 +578,13 @@ public class EglRenderer implements VideoRenderer.Callbacks { |
| yuvTextures[i] = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); |
| } |
| } |
| + |
| yuvUploader.uploadYuvData( |
| yuvTextures, frame.width, frame.height, frame.yuvStrides, frame.yuvPlanes); |
| - drawer.drawYuv(yuvTextures, drawMatrix, frame.rotatedWidth(), frame.rotatedHeight(), 0, 0, |
| - surfaceWidth, surfaceHeight); |
| + drawer.drawYuv(yuvTextures, drawMatrix, drawnFrameWidth, drawnFrameHeight, 0, 0, surfaceWidth, |
| + surfaceHeight); |
| } else { |
| - drawer.drawOes(frame.textureId, drawMatrix, frame.rotatedWidth(), frame.rotatedHeight(), 0, 0, |
| + drawer.drawOes(frame.textureId, drawMatrix, drawnFrameWidth, drawnFrameHeight, 0, 0, |
| surfaceWidth, surfaceHeight); |
| } |