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..c9ad2acb5b81a47f4b8ff8fd69245c58cf134f83 100644 |
--- a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm |
+++ b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm |
@@ -15,6 +15,8 @@ |
#import "RTCShader+Private.h" |
#import "WebRTC/RTCVideoFrame.h" |
+#include "webrtc/base/optional.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 +59,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<int> _current_rotation; |
tkchin_webrtc
2016/08/08 22:58:45
nit: camelcase for objc files
_currentRotation
magjed_webrtc
2016/08/09 13:54:27
Done.
|
// Used to create a non-padded plane for GPU upload when we receive padded |
// frames. |
std::vector<uint8_t> _planeBuffer; |
@@ -119,6 +124,10 @@ static const char kI420FragmentShaderSource[] = |
glBindVertexArray(_vertexArray); |
#endif |
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); |
+ if (!_current_rotation || frame.rotation != *_current_rotation) { |
+ _current_rotation = rtc::Optional<int>(frame.rotation); |
+ RTCSetVertexData(frame.rotation); |
+ } |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
return YES; |