Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm

Issue 2176623002: iOS render: Handle frame rotation in OpenGL (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@nv21_texture_render
Patch Set: Keep RTCVideoFrame.h pure ObjC Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
index 0618c1a530b407e5092c661622096b63e9aadc69..e0c96422690d30c509776e7889a10eccb1c3ff8f 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
@@ -15,6 +15,9 @@
#import "RTCShader+Private.h"
#import "WebRTC/RTCVideoFrame.h"
+#include "webrtc/base/optional.h"
+#include "webrtc/common_video/rotation.h"
+
// |kNumTextures| must not exceed 8, which is the limit in OpenGLES2. Two sets
// of 3 textures are used here, one for each of the Y, U and V planes. Having
// two sets alleviates CPU blockage in the event that the GPU is asked to render
@@ -57,6 +60,9 @@ static const char kI420FragmentShaderSource[] =
GLint _ySampler;
GLint _uSampler;
GLint _vSampler;
+ // Store current rotation and only upload new vertex data when rotation
+ // changes.
+ rtc::Optional<webrtc::VideoRotation> _currentRotation;
// Used to create a non-padded plane for GPU upload when we receive padded
// frames.
std::vector<uint8_t> _planeBuffer;
@@ -119,6 +125,11 @@ static const char kI420FragmentShaderSource[] =
glBindVertexArray(_vertexArray);
#endif
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
+ if (!_currentRotation || frame.rotation != *_currentRotation) {
+ _currentRotation = rtc::Optional<webrtc::VideoRotation>(
+ static_cast<webrtc::VideoRotation>(frame.rotation));
+ RTCSetVertexData(*_currentRotation);
+ }
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
return YES;
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m ('k') | webrtc/sdk/objc/Framework/Classes/RTCNativeNV12Shader.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698