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 |
11 #import "RTCShader.h" | 11 #import "RTCShader.h" |
12 | 12 |
13 // Native CVPixelBufferRef rendering is only supported on iPhone because it | 13 // Native CVPixelBufferRef rendering is only supported on iPhone because it |
14 // depends on CVOpenGLESTextureCacheCreate. | 14 // depends on CVOpenGLESTextureCacheCreate. |
15 #if TARGET_OS_IPHONE | 15 #if TARGET_OS_IPHONE |
16 | 16 |
17 #import <CoreVideo/CVOpenGLESTextureCache.h> | 17 #import <CoreVideo/CVOpenGLESTextureCache.h> |
18 | 18 |
19 #import "RTCShader+Private.h" | 19 #import "RTCShader+Private.h" |
| 20 #import "WebRTC/RTCLogging.h" |
20 #import "WebRTC/RTCVideoFrame.h" | 21 #import "WebRTC/RTCVideoFrame.h" |
21 | 22 |
22 #include "webrtc/base/checks.h" | 23 #include "webrtc/base/checks.h" |
23 #include "webrtc/base/optional.h" | 24 #include "webrtc/base/optional.h" |
24 | 25 |
25 static const char kNV12FragmentShaderSource[] = | 26 static const char kNV12FragmentShaderSource[] = |
26 SHADER_VERSION | 27 SHADER_VERSION |
27 "precision mediump float;" | 28 "precision mediump float;" |
28 FRAGMENT_SHADER_IN " vec2 v_texcoord;\n" | 29 FRAGMENT_SHADER_IN " vec2 v_texcoord;\n" |
29 "uniform lowp sampler2D s_textureY;\n" | 30 "uniform lowp sampler2D s_textureY;\n" |
(...skipping 19 matching lines...) Expand all Loading... |
49 CVOpenGLESTextureCacheRef _textureCache; | 50 CVOpenGLESTextureCacheRef _textureCache; |
50 // Store current rotation and only upload new vertex data when rotation | 51 // Store current rotation and only upload new vertex data when rotation |
51 // changes. | 52 // changes. |
52 rtc::Optional<RTCVideoRotation> _currentRotation; | 53 rtc::Optional<RTCVideoRotation> _currentRotation; |
53 } | 54 } |
54 | 55 |
55 - (instancetype)initWithContext:(GlContextType *)context { | 56 - (instancetype)initWithContext:(GlContextType *)context { |
56 if (self = [super init]) { | 57 if (self = [super init]) { |
57 if (![self setupNV12Program] || ![self setupTextureCacheWithContext:context]
|| | 58 if (![self setupNV12Program] || ![self setupTextureCacheWithContext:context]
|| |
58 !RTCSetupVerticesForProgram(_nv12Program, &_vertexBuffer, nullptr)) { | 59 !RTCSetupVerticesForProgram(_nv12Program, &_vertexBuffer, nullptr)) { |
| 60 RTCLog(@"Failed to initialize RTCNativeNV12Shader."); |
59 self = nil; | 61 self = nil; |
60 } | 62 } |
61 } | 63 } |
62 return self; | 64 return self; |
63 } | 65 } |
64 | 66 |
65 - (void)dealloc { | 67 - (void)dealloc { |
66 glDeleteProgram(_nv12Program); | 68 glDeleteProgram(_nv12Program); |
67 glDeleteBuffers(1, &_vertexBuffer); | 69 glDeleteBuffers(1, &_vertexBuffer); |
68 if (_textureCache) { | 70 if (_textureCache) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); | 162 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
161 | 163 |
162 CFRelease(chromaTexture); | 164 CFRelease(chromaTexture); |
163 CFRelease(lumaTexture); | 165 CFRelease(lumaTexture); |
164 | 166 |
165 return YES; | 167 return YES; |
166 } | 168 } |
167 | 169 |
168 @end | 170 @end |
169 #endif // TARGET_OS_IPHONE | 171 #endif // TARGET_OS_IPHONE |
OLD | NEW |