OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 if (shouldRenderFrame) { | 616 if (shouldRenderFrame) { |
617 GLES20.glClearColor(0 /* red */, 0 /* green */, 0 /* blue */, 0 /* alpha *
/); | 617 GLES20.glClearColor(0 /* red */, 0 /* green */, 0 /* blue */, 0 /* alpha *
/); |
618 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 618 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
619 if (isYuvBuffer) { | 619 if (isYuvBuffer) { |
620 drawer.drawYuv(yuvTextures, | 620 drawer.drawYuv(yuvTextures, |
621 RendererCommon.convertMatrixFromAndroidGraphicsMatrix(drawMatrix), d
rawnFrameWidth, | 621 RendererCommon.convertMatrixFromAndroidGraphicsMatrix(drawMatrix), d
rawnFrameWidth, |
622 drawnFrameHeight, 0, 0, eglBase.surfaceWidth(), eglBase.surfaceHeigh
t()); | 622 drawnFrameHeight, 0, 0, eglBase.surfaceWidth(), eglBase.surfaceHeigh
t()); |
623 } else { | 623 } else { |
624 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) buff
er; | 624 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) buff
er; |
625 drawer.drawTexture(textureBuffer, drawMatrix, drawnFrameWidth, drawnFram
eHeight, 0, 0, | 625 RendererCommon.drawTexture(drawer, textureBuffer, drawMatrix, drawnFrame
Width, |
626 eglBase.surfaceWidth(), eglBase.surfaceHeight()); | 626 drawnFrameHeight, 0, 0, eglBase.surfaceWidth(), eglBase.surfaceHeigh
t()); |
627 } | 627 } |
628 | 628 |
629 final long swapBuffersStartTimeNs = System.nanoTime(); | 629 final long swapBuffersStartTimeNs = System.nanoTime(); |
630 eglBase.swapBuffers(); | 630 eglBase.swapBuffers(); |
631 | 631 |
632 final long currentTimeNs = System.nanoTime(); | 632 final long currentTimeNs = System.nanoTime(); |
633 synchronized (statisticsLock) { | 633 synchronized (statisticsLock) { |
634 ++framesRendered; | 634 ++framesRendered; |
635 renderTimeNs += (currentTimeNs - startTimeNs); | 635 renderTimeNs += (currentTimeNs - startTimeNs); |
636 renderSwapBufferTimeNs += (currentTimeNs - swapBuffersStartTimeNs); | 636 renderSwapBufferTimeNs += (currentTimeNs - swapBuffersStartTimeNs); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 GLES20.GL_TEXTURE_2D, bitmapTextureFramebuffer.getTextureId(), 0); | 682 GLES20.GL_TEXTURE_2D, bitmapTextureFramebuffer.getTextureId(), 0); |
683 | 683 |
684 GLES20.glClearColor(0 /* red */, 0 /* green */, 0 /* blue */, 0 /* alpha *
/); | 684 GLES20.glClearColor(0 /* red */, 0 /* green */, 0 /* blue */, 0 /* alpha *
/); |
685 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 685 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
686 if (isYuvBuffer) { | 686 if (isYuvBuffer) { |
687 listenerAndParams.drawer.drawYuv(yuvTextures, | 687 listenerAndParams.drawer.drawYuv(yuvTextures, |
688 RendererCommon.convertMatrixFromAndroidGraphicsMatrix(drawMatrix), | 688 RendererCommon.convertMatrixFromAndroidGraphicsMatrix(drawMatrix), |
689 frame.getRotatedWidth(), frame.getRotatedHeight(), 0, 0, scaledWidth
, scaledHeight); | 689 frame.getRotatedWidth(), frame.getRotatedHeight(), 0, 0, scaledWidth
, scaledHeight); |
690 } else { | 690 } else { |
691 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) fram
e.getBuffer(); | 691 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) fram
e.getBuffer(); |
692 listenerAndParams.drawer.drawTexture(textureBuffer, drawMatrix, frame.ge
tRotatedWidth(), | 692 RendererCommon.drawTexture(listenerAndParams.drawer, textureBuffer, draw
Matrix, |
693 frame.getRotatedHeight(), 0, 0, scaledWidth, scaledHeight); | 693 frame.getRotatedWidth(), frame.getRotatedHeight(), 0, 0, scaledWidth
, scaledHeight); |
694 } | 694 } |
695 | 695 |
696 final ByteBuffer bitmapBuffer = ByteBuffer.allocateDirect(scaledWidth * sc
aledHeight * 4); | 696 final ByteBuffer bitmapBuffer = ByteBuffer.allocateDirect(scaledWidth * sc
aledHeight * 4); |
697 GLES20.glViewport(0, 0, scaledWidth, scaledHeight); | 697 GLES20.glViewport(0, 0, scaledWidth, scaledHeight); |
698 GLES20.glReadPixels( | 698 GLES20.glReadPixels( |
699 0, 0, scaledWidth, scaledHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BY
TE, bitmapBuffer); | 699 0, 0, scaledWidth, scaledHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BY
TE, bitmapBuffer); |
700 | 700 |
701 GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); | 701 GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); |
702 GlUtil.checkNoGLES2Error("EglRenderer.notifyCallbacks"); | 702 GlUtil.checkNoGLES2Error("EglRenderer.notifyCallbacks"); |
703 | 703 |
(...skipping 24 matching lines...) Expand all Loading... |
728 + " Average swapBuffer time: " | 728 + " Average swapBuffer time: " |
729 + averageTimeAsString(renderSwapBufferTimeNs, framesRendered) + "."); | 729 + averageTimeAsString(renderSwapBufferTimeNs, framesRendered) + "."); |
730 resetStatistics(currentTimeNs); | 730 resetStatistics(currentTimeNs); |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 private void logD(String string) { | 734 private void logD(String string) { |
735 Logging.d(TAG, name + string); | 735 Logging.d(TAG, name + string); |
736 } | 736 } |
737 } | 737 } |
OLD | NEW |