-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS FlutterTextureRegistry should be a proxy, not the engine itself #37666
Changes from 8 commits
79fba0b
14feca2
dc1f340
b3beefd
f49856c
857f959
9bde5fc
a754c39
5b91b48
6934d90
446a3ef
784a1e8
1bca083
2e25e93
f18803d
860c244
41d503b
3d43683
bdbe21e
a166525
40324bd
7a69a39
10ab885
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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 "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" | ||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" | ||
|
||
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG | ||
FLUTTER_DARWIN_EXPORT | ||
#endif | ||
@interface FlutterTextureRegistryRelay : NSObject <FlutterTextureRegistry> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a comment explaining that this relay is used to solve the issue with plugin retaining the engine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use From this comment I don't really understand when this would be used. Returned from what? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jmagman, are these comments ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this would be better. |
||
@property(nonatomic, assign) NSObject<FlutterTextureRegistry>* parent; | ||
- (instancetype)initWithParent:(NSObject<FlutterTextureRegistry>*)parent; | ||
@end |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
// 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 "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h" | ||||||
|
||||||
#include "flutter/fml/logging.h" | ||||||
|
||||||
@implementation FlutterTextureRegistryRelay : NSObject | ||||||
|
||||||
#pragma mark - FlutterTextureRegistry | ||||||
|
||||||
- (instancetype)initWithParent:(NSObject<FlutterTextureRegistry>*)parent { | ||||||
if (self = [super init]) { | ||||||
self.parent = parent; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||||||
} | ||||||
return self; | ||||||
} | ||||||
|
||||||
- (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture { | ||||||
if (!self.parent) { | ||||||
FML_LOG(WARNING) << "Using on an empty registry."; | ||||||
return 0; | ||||||
} | ||||||
return [self.parent registerTexture:texture]; | ||||||
} | ||||||
|
||||||
- (void)textureFrameAvailable:(int64_t)textureId { | ||||||
if (!self.parent) { | ||||||
FML_LOG(WARNING) << "Using on an empty registry."; | ||||||
} | ||||||
return [self.parent textureFrameAvailable:textureId]; | ||||||
} | ||||||
|
||||||
- (void)unregisterTexture:(int64_t)textureId { | ||||||
if (!self.parent) { | ||||||
FML_LOG(WARNING) << "Using on an empty registry."; | ||||||
} | ||||||
return [self.parent unregisterTexture:textureId]; | ||||||
} | ||||||
|
||||||
endless7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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 "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h" | ||
|
||
#import <OCMock/OCMock.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" | ||
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterTextureRegistryRelayTest : XCTestCase | ||
@end | ||
|
||
@implementation FlutterTextureRegistryRelayTest | ||
endless7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- (void)testCreate { | ||
id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry)); | ||
FlutterTextureRegistryRelay* relay = | ||
[[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry]; | ||
XCTAssertNotNil(relay); | ||
XCTAssertEqual(textureRegistry, relay.parent); | ||
} | ||
|
||
- (void)testRegisterTexture { | ||
id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry)); | ||
FlutterTextureRegistryRelay* relay = | ||
[[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry]; | ||
id texture = OCMProtocolMock(@protocol(FlutterTexture)); | ||
[relay registerTexture:texture]; | ||
OCMVerify([textureRegistry registerTexture:texture]); | ||
} | ||
|
||
- (void)testTextureFrameAvailable { | ||
id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry)); | ||
FlutterTextureRegistryRelay* relay = | ||
[[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry]; | ||
[relay textureFrameAvailable:0]; | ||
OCMVerify([textureRegistry textureFrameAvailable:0]); | ||
} | ||
|
||
- (void)testUnregisterTexture { | ||
id textureRegistry = OCMProtocolMock(@protocol(FlutterTextureRegistry)); | ||
FlutterTextureRegistryRelay* relay = | ||
[[FlutterTextureRegistryRelay alloc] initWithParent:textureRegistry]; | ||
[relay unregisterTexture:0]; | ||
OCMVerify([textureRegistry unregisterTexture:0]); | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.