Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
/*
|
2017-04-28 02:14:54 -07:00
|
|
|
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#import "RTCMTLNV12Renderer.h"
|
|
|
|
|
|
|
|
|
|
#import <Metal/Metal.h>
|
|
|
|
|
#import <MetalKit/MetalKit.h>
|
|
|
|
|
|
|
|
|
|
#import "WebRTC/RTCLogging.h"
|
|
|
|
|
#import "WebRTC/RTCVideoFrame.h"
|
2017-06-22 15:26:30 +02:00
|
|
|
#import "WebRTC/RTCVideoFrameBuffer.h"
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
|
2017-04-28 02:14:54 -07:00
|
|
|
#import "RTCMTLRenderer+Private.h"
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
|
|
|
|
|
#define MTL_STRINGIFY(s) @ #s
|
|
|
|
|
|
|
|
|
|
static NSString *const shaderSource = MTL_STRINGIFY(
|
|
|
|
|
using namespace metal; typedef struct {
|
|
|
|
|
packed_float2 position;
|
|
|
|
|
packed_float2 texcoord;
|
|
|
|
|
} Vertex;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
float4 position[[position]];
|
|
|
|
|
float2 texcoord;
|
|
|
|
|
} Varyings;
|
|
|
|
|
|
|
|
|
|
vertex Varyings vertexPassthrough(device Vertex * verticies[[buffer(0)]],
|
|
|
|
|
unsigned int vid[[vertex_id]]) {
|
|
|
|
|
Varyings out;
|
|
|
|
|
device Vertex &v = verticies[vid];
|
|
|
|
|
out.position = float4(float2(v.position), 0.0, 1.0);
|
|
|
|
|
out.texcoord = v.texcoord;
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Receiving YCrCb textures.
|
|
|
|
|
fragment half4 fragmentColorConversion(
|
|
|
|
|
Varyings in[[stage_in]], texture2d<float, access::sample> textureY[[texture(0)]],
|
|
|
|
|
texture2d<float, access::sample> textureCbCr[[texture(1)]]) {
|
|
|
|
|
constexpr sampler s(address::clamp_to_edge, filter::linear);
|
|
|
|
|
float y;
|
|
|
|
|
float2 uv;
|
|
|
|
|
y = textureY.sample(s, in.texcoord).r;
|
|
|
|
|
uv = textureCbCr.sample(s, in.texcoord).rg - float2(0.5, 0.5);
|
|
|
|
|
|
|
|
|
|
// Conversion for YUV to rgb from http://www.fourcc.org/fccyvrgb.php
|
|
|
|
|
float4 out = float4(y + 1.403 * uv.y, y - 0.344 * uv.x - 0.714 * uv.y, y + 1.770 * uv.x, 1.0);
|
|
|
|
|
|
|
|
|
|
return half4(out);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@implementation RTCMTLNV12Renderer {
|
|
|
|
|
// Textures.
|
|
|
|
|
CVMetalTextureCacheRef _textureCache;
|
|
|
|
|
id<MTLTexture> _yTexture;
|
|
|
|
|
id<MTLTexture> _CrCbTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)addRenderingDestination:(__kindof MTKView *)view {
|
2017-04-28 02:14:54 -07:00
|
|
|
if ([super addRenderingDestination:view]) {
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
[self initializeTextureCache];
|
2017-04-28 02:14:54 -07:00
|
|
|
return YES;
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
}
|
2017-04-28 02:14:54 -07:00
|
|
|
return NO;
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initializeTextureCache {
|
2017-04-28 02:14:54 -07:00
|
|
|
CVReturn status = CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, [self currentMetalDevice],
|
|
|
|
|
nil, &_textureCache);
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
if (status != kCVReturnSuccess) {
|
|
|
|
|
RTCLogError(@"Metal: Failed to initialize metal texture cache. Return status is %d", status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-28 02:14:54 -07:00
|
|
|
- (NSString *)shaderSource {
|
|
|
|
|
return shaderSource;
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
}
|
|
|
|
|
|
2017-03-09 03:34:27 -08:00
|
|
|
- (BOOL)setupTexturesForFrame:(nonnull RTCVideoFrame *)frame {
|
2017-04-28 02:14:54 -07:00
|
|
|
[super setupTexturesForFrame:frame];
|
2017-06-22 15:26:30 +02:00
|
|
|
CVPixelBufferRef pixelBuffer = ((RTCCVPixelBuffer *)frame.buffer).pixelBuffer;
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
|
|
|
|
|
id<MTLTexture> lumaTexture = nil;
|
|
|
|
|
id<MTLTexture> chromaTexture = nil;
|
|
|
|
|
CVMetalTextureRef outTexture = nullptr;
|
|
|
|
|
|
|
|
|
|
// Luma (y) texture.
|
|
|
|
|
int lumaWidth = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
|
|
|
|
|
int lumaHeight = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);
|
|
|
|
|
|
|
|
|
|
int indexPlane = 0;
|
|
|
|
|
CVReturn result = CVMetalTextureCacheCreateTextureFromImage(
|
|
|
|
|
kCFAllocatorDefault, _textureCache, pixelBuffer, nil, MTLPixelFormatR8Unorm, lumaWidth,
|
|
|
|
|
lumaHeight, indexPlane, &outTexture);
|
|
|
|
|
|
|
|
|
|
if (result == kCVReturnSuccess) {
|
|
|
|
|
lumaTexture = CVMetalTextureGetTexture(outTexture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Same as CFRelease except it can be passed NULL without crashing.
|
|
|
|
|
CVBufferRelease(outTexture);
|
|
|
|
|
outTexture = nullptr;
|
|
|
|
|
|
|
|
|
|
// Chroma (CrCb) texture.
|
|
|
|
|
indexPlane = 1;
|
|
|
|
|
result = CVMetalTextureCacheCreateTextureFromImage(
|
|
|
|
|
kCFAllocatorDefault, _textureCache, pixelBuffer, nil, MTLPixelFormatRG8Unorm, lumaWidth / 2,
|
|
|
|
|
lumaHeight / 2, indexPlane, &outTexture);
|
|
|
|
|
if (result == kCVReturnSuccess) {
|
|
|
|
|
chromaTexture = CVMetalTextureGetTexture(outTexture);
|
|
|
|
|
}
|
|
|
|
|
CVBufferRelease(outTexture);
|
|
|
|
|
|
|
|
|
|
if (lumaTexture != nil && chromaTexture != nil) {
|
|
|
|
|
_yTexture = lumaTexture;
|
|
|
|
|
_CrCbTexture = chromaTexture;
|
2017-03-09 03:34:27 -08:00
|
|
|
return YES;
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
}
|
2017-03-09 03:34:27 -08:00
|
|
|
return NO;
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
}
|
|
|
|
|
|
2017-04-28 02:14:54 -07:00
|
|
|
- (void)uploadTexturesToRenderEncoder:(id<MTLRenderCommandEncoder>)renderEncoder {
|
|
|
|
|
[renderEncoder setFragmentTexture:_yTexture atIndex:0];
|
|
|
|
|
[renderEncoder setFragmentTexture:_CrCbTexture atIndex:1];
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Add metal view, shaders and renderer. (patchset #1 id:1 of https://codereview.webrtc.org/2711003004/ )
Reason for revert:
Re-land
Original issue's description:
> Revert of Add metal view, shaders and renderer. (patchset #18 id:340001 of https://codereview.webrtc.org/2651743007/ )
>
> Reason for revert:
> Reverting due to breakage in the Google3 import
>
> Original issue's description:
> > Add metal view, shaders and renderer.
> >
> > This CL submits standalone Metal view, renderer and shader.
> >
> > BUG=webrtc:7079
> >
> > Review-Url: https://codereview.webrtc.org/2651743007
> > Cr-Commit-Position: refs/heads/master@{#16787}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/fc8c97f950a4fead4a5debe3c838942db1834010
>
> TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2711003004
> Cr-Commit-Position: refs/heads/master@{#16788}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b681aabdfcdcb22de049df3916f2dd8c40dcbf57
TBR=magjed@webrtc.org,kthelgason@webrtc.org,tkchin@webrtc.org,haysc@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2716703004
Cr-Commit-Position: refs/heads/master@{#16846}
2017-02-26 11:44:13 -08:00
|
|
|
@end
|