Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ContinuousTexture.m
Go to the documentation of this file.
1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7@implementation ContinuousTexture
8
9+ (void)registerWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar>*)registrar {
10 NSObject<FlutterTextureRegistry>* textureRegistry = [registrar textures];
12 int64_t textureId = [textureRegistry registerTexture:texture];
13 [NSTimer scheduledTimerWithTimeInterval:0.05
14 repeats:YES
15 block:^(NSTimer* _Nonnull timer) {
16 [textureRegistry textureFrameAvailable:textureId];
17 }];
18}
19
20@end
21
22@implementation FlutterScenarioTestTexture
23
24- (CVPixelBufferRef _Nullable)copyPixelBuffer {
25 return [self pixelBuffer];
26}
27
28- (CVPixelBufferRef)pixelBuffer {
29 NSDictionary* options = @{
30 // This key is required to generate SKPicture with CVPixelBufferRef in metal.
31 (NSString*)kCVPixelBufferMetalCompatibilityKey : @YES
32 };
33 CVPixelBufferRef pxbuffer = NULL;
34 CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, 200, 200, kCVPixelFormatType_32BGRA,
35 (__bridge CFDictionaryRef)options, &pxbuffer);
36
37 NSAssert(status == kCVReturnSuccess && pxbuffer != NULL, @"Failed to create pixel buffer.");
38 return pxbuffer;
39}
40
41@end
const char * options
CVPixelBufferRef _Nullable copyPixelBuffer()
FlTexture * texture