From 0e16af448c5c9030930cb57e983cf6f06c24e5d1 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Fri, 17 Feb 2023 01:52:16 -0800 Subject: [PATCH] opt: add doc for macOS --- example/lib/main.dart | 1 + macos/Classes/TextRgba.swift | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 1affee1..ad63f2d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,3 +1,4 @@ +import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; diff --git a/macos/Classes/TextRgba.swift b/macos/Classes/TextRgba.swift index 61bc916..f2dba86 100644 --- a/macos/Classes/TextRgba.swift +++ b/macos/Classes/TextRgba.swift @@ -33,6 +33,7 @@ public final class TextRgba: NSObject, FlutterTexture { public func markFrameAvaliable(data: Data, width: Int, height: Int) -> Bool { self.data = data.withUnsafeBytes { buffer in var pixelBufferCopy: CVPixelBuffer! + // macOS only support 32BGRA currently. let result = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, nil, &pixelBufferCopy) guard result == kCVReturnSuccess else { return nil @@ -53,7 +54,7 @@ public final class TextRgba: NSObject, FlutterTexture { } self.width = width self.height = height - if (textureId != -1) { + if (textureId != -1 && self.data != nil) { registry?.textureFrameAvailable(textureId) return true } else {