diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index c40dc12c43fe0..44714b14c5a6f 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2608,8 +2608,8 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngin FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm +FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h +FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyPrimaryResponder.h @@ -2617,7 +2617,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeybo FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyboardManager.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyboardManagerUnittests.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyboardViewDelegate.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPlugin.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPlugin.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPluginTest.mm diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index 1c208037a2500..e51c50cf1cb02 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -69,16 +69,14 @@ source_set("flutter_framework_source") { "framework/Source/FlutterEmbedderKeyResponder.mm", "framework/Source/FlutterEngine.mm", "framework/Source/FlutterEngine_Internal.h", - "framework/Source/FlutterExternalTextureMetal.h", - "framework/Source/FlutterExternalTextureMetal.mm", + "framework/Source/FlutterExternalTexture.h", + "framework/Source/FlutterExternalTexture.mm", "framework/Source/FlutterIOSurfaceHolder.h", "framework/Source/FlutterIOSurfaceHolder.mm", "framework/Source/FlutterKeyPrimaryResponder.h", "framework/Source/FlutterKeyboardManager.h", "framework/Source/FlutterKeyboardManager.mm", "framework/Source/FlutterKeyboardViewDelegate.h", - "framework/Source/FlutterMacOSExternalTexture.h", - "framework/Source/FlutterMacOSExternalTexture.h", "framework/Source/FlutterMenuPlugin.h", "framework/Source/FlutterMenuPlugin.mm", "framework/Source/FlutterMenuPlugin_Internal.h", diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEmbedderExternalTextureUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterEmbedderExternalTextureUnittests.mm index 1444503ca3fcd..c4c1f8f08410a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEmbedderExternalTextureUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEmbedderExternalTextureUnittests.mm @@ -10,7 +10,7 @@ #import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" #import "flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h" +#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/embedder/embedder_external_texture_metal.h" #import "flutter/testing/testing.h" @@ -140,9 +140,9 @@ - (CVPixelBufferRef)pixelBuffer { [[TestExternalTexture alloc] initWidth:width height:height pixelFormatType:kCVPixelFormatType_32BGRA]; - FlutterExternalTextureMetal* textureHolder = - [[FlutterExternalTextureMetal alloc] initWithFlutterTexture:testExternalTexture - darwinMetalContext:darwinContextMetal]; + FlutterExternalTexture* textureHolder = + [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture + darwinMetalContext:darwinContextMetal]; // Callback to resolve the texture. EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w, @@ -192,9 +192,9 @@ - (CVPixelBufferRef)pixelBuffer { [[TestExternalTexture alloc] initWidth:width height:height pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange]; - FlutterExternalTextureMetal* textureHolder = - [[FlutterExternalTextureMetal alloc] initWithFlutterTexture:testExternalTexture - darwinMetalContext:darwinContextMetal]; + FlutterExternalTexture* textureHolder = + [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture + darwinMetalContext:darwinContextMetal]; // Callback to resolve the texture. EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w, @@ -246,9 +246,9 @@ - (CVPixelBufferRef)pixelBuffer { [[TestExternalTexture alloc] initWidth:width height:height pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]; - FlutterExternalTextureMetal* textureHolder = - [[FlutterExternalTextureMetal alloc] initWithFlutterTexture:testExternalTexture - darwinMetalContext:darwinContextMetal]; + FlutterExternalTexture* textureHolder = + [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture + darwinMetalContext:darwinContextMetal]; // Callback to resolve the texture. EmbedderExternalTextureMetal::ExternalTextureCallback callback = [&](int64_t texture_id, size_t w, diff --git a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h b/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h similarity index 80% rename from shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h rename to shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h index 8942d1ff71062..79d222a392050 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h @@ -5,13 +5,14 @@ #import #import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h" +#include "flutter/shell/platform/embedder/embedder.h" /** + * Embedding side texture wrappers for Metal external textures. * Used to bridge FlutterTexture object and handle the texture copy request the * Flutter engine. */ -@interface FlutterExternalTextureMetal : NSObject +@interface FlutterExternalTexture : NSObject /** * Initializes a texture adapter with |texture|. @@ -19,6 +20,11 @@ - (nonnull instancetype)initWithFlutterTexture:(nonnull id)texture darwinMetalContext:(nonnull FlutterDarwinContextMetalSkia*)context; +/** + * Returns the ID for the FlutterExternalTexture instance. + */ +- (int64_t)textureID; + /** * Accepts texture buffer copy request from the Flutter engine. * When the user side marks the textureID as available, the Flutter engine will diff --git a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm b/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.mm similarity index 98% rename from shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm rename to shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.mm index db49abf14a340..0d95de6814f50 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.mm @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h" +#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h" #include "flutter/fml/platform/darwin/cf_utils.h" -@implementation FlutterExternalTextureMetal { +@implementation FlutterExternalTexture { FlutterDarwinContextMetalSkia* _darwinMetalContext; int64_t _textureID; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h b/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h deleted file mode 100644 index 9ea64e5567bb8..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import - -#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" -#import "flutter/shell/platform/embedder/embedder.h" - -/* - * Embedding side texture wrappers for GL and Metal external textures. - */ -@protocol FlutterMacOSExternalTexture - -/** - * Returns the ID for the FlutterTexture instance. - */ -- (int64_t)textureID; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm index 1dee38f436352..3c756534eaad7 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm @@ -5,7 +5,7 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h" +#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" #include "flutter/shell/platform/embedder/embedder.h" @@ -111,15 +111,13 @@ - (void)presentWithoutContent { - (BOOL)populateTextureWithIdentifier:(int64_t)textureID metalTexture:(FlutterMetalExternalTexture*)textureOut { - id texture = [self getTextureWithID:textureID]; - FlutterExternalTextureMetal* metalTexture = - reinterpret_cast(texture); - return [metalTexture populateTexture:textureOut]; + FlutterExternalTexture* texture = [self getTextureWithID:textureID]; + return [texture populateTexture:textureOut]; } -- (id)onRegisterTexture:(id)texture { - return [[FlutterExternalTextureMetal alloc] initWithFlutterTexture:texture - darwinMetalContext:_darwinMetalContext]; +- (FlutterExternalTexture*)onRegisterTexture:(id)texture { + return [[FlutterExternalTexture alloc] initWithFlutterTexture:texture + darwinMetalContext:_darwinMetalContext]; } @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.h b/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.h index 7ca5d98a83b0c..cc9ddfdd9c81a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.h @@ -5,7 +5,7 @@ #import #import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h" +#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h" /* * Delegate methods for FlutterTextureRegistrar. @@ -15,7 +15,7 @@ /* * Called by the FlutterTextureRegistrar when a texture is registered. */ -- (nonnull id)onRegisterTexture:(nonnull id)texture; +- (nonnull FlutterExternalTexture*)onRegisterTexture:(nonnull id)texture; @end @@ -43,6 +43,6 @@ /* * Returns the registered texture with the provided `textureID`. */ -- (nullable id)getTextureWithID:(int64_t)textureID; +- (nullable FlutterExternalTexture*)getTextureWithID:(int64_t)textureID; @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.mm index 206eb20b8d1b0..c4f97a49bf23e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextureRegistrar.mm @@ -11,8 +11,8 @@ @implementation FlutterTextureRegistrar { __weak FlutterEngine* _flutterEngine; - // A mapping of textureID to internal FlutterExternalTextureGL adapter. - NSMutableDictionary>* _textures; + // A mapping of textureID to internal FlutterExternalTexture wrapper. + NSMutableDictionary* _textures; } - (instancetype)initWithDelegate:(id)delegate @@ -26,7 +26,7 @@ - (instancetype)initWithDelegate:(id)delegate } - (int64_t)registerTexture:(id)texture { - id externalTexture = [_delegate onRegisterTexture:texture]; + FlutterExternalTexture* externalTexture = [_delegate onRegisterTexture:texture]; int64_t textureID = [externalTexture textureID]; BOOL success = [_flutterEngine registerTextureWithID:textureID]; if (success) { @@ -54,7 +54,7 @@ - (void)unregisterTexture:(int64_t)textureID { } } -- (id)getTextureWithID:(int64_t)textureID { +- (FlutterExternalTexture*)getTextureWithID:(int64_t)textureID { return _textures[@(textureID)]; }