Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* backward compatibility, single-view APIs will always operate on the view with
* this ID. Also, the first view assigned to the engine will also have this ID.
*/
extern const uint64_t kFlutterDefaultViewId;
extern const int64_t kFlutterDefaultViewId;

@class FlutterViewController;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ FLUTTER_DARWIN_EXPORT
/**
* The `NSView` associated with the given view ID, if any.
*/
- (nullable NSView*)viewForId:(uint64_t)viewId;
- (nullable NSView*)viewForId:(int64_t)viewId;

/**
* Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FLUTTER_DARWIN_EXPORT
* If the view controller is unattached (see FlutterViewController#attached),
* reading this property throws an assertion.
*/
@property(nonatomic, readonly) uint64_t id;
@property(nonatomic, readonly) int64_t id;

/**
* The style of mouse tracking to use for the view. Defaults to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FlutterCompositor {

// Presents the FlutterLayers by updating the FlutterView specified by
// `view_id` using the layer content. Sets frame_started_ to false.
bool Present(uint64_t view_id, const FlutterLayer** layers, size_t layers_count);
bool Present(int64_t view_id, const FlutterLayer** layers, size_t layers_count);

private:
void PresentPlatformViews(FlutterView* default_base_view,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
return true;
}

bool FlutterCompositor::Present(uint64_t view_id,
const FlutterLayer** layers,
size_t layers_count) {
bool FlutterCompositor::Present(int64_t view_id, const FlutterLayer** layers, size_t layers_count) {
FlutterView* view = [view_provider_ viewForId:view_id];
if (!view) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h"
#import "flutter/testing/testing.h"

extern const uint64_t kFlutterDefaultViewId;
extern const int64_t kFlutterDefaultViewId;

@interface FlutterViewMockProvider : NSObject <FlutterViewProvider> {
FlutterView* _defaultView;
Expand All @@ -32,7 +32,7 @@ - (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view {
return self;
}

- (nullable FlutterView*)viewForId:(uint64_t)viewId {
- (nullable FlutterView*)viewForId:(int64_t)viewId {
if (viewId == kFlutterDefaultViewId) {
return _defaultView;
}
Expand Down
16 changes: 8 additions & 8 deletions shell/platform/darwin/macos/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h"
#include "flutter/shell/platform/embedder/embedder.h"

const uint64_t kFlutterDefaultViewId = 0;
const int64_t kFlutterDefaultViewId = 0;

/**
* Constructs and returns a FlutterLocale struct corresponding to |locale|, which must outlive
Expand Down Expand Up @@ -83,15 +83,15 @@ @interface FlutterEngine () <FlutterBinaryMessenger>
*/
@property(nonatomic, strong) NSMutableArray<NSNumber*>* isResponseValid;

- (nullable FlutterViewController*)viewControllerForId:(uint64_t)viewId;
- (nullable FlutterViewController*)viewControllerForId:(int64_t)viewId;

/**
* An internal method that adds the view controller with the given ID.
*
* This method assigns the controller with the ID, puts the controller into the
* map, and does assertions related to the default view ID.
*/
- (void)registerViewController:(FlutterViewController*)controller forId:(uint64_t)viewId;
- (void)registerViewController:(FlutterViewController*)controller forId:(int64_t)viewId;

/**
* An internal method that removes the view controller with the given ID.
Expand All @@ -100,7 +100,7 @@ - (void)registerViewController:(FlutterViewController*)controller forId:(uint64_
* map. This is an no-op if the view ID is not associated with any view
* controllers.
*/
- (void)deregisterViewControllerForId:(uint64_t)viewId;
- (void)deregisterViewControllerForId:(int64_t)viewId;

/**
* Shuts down the engine if view requirement is not met, and headless execution
Expand Down Expand Up @@ -190,7 +190,7 @@ - (NSView*)view {
return [self viewForId:kFlutterDefaultViewId];
}

- (NSView*)viewForId:(uint64_t)viewId {
- (NSView*)viewForId:(int64_t)viewId {
FlutterViewController* controller = [_flutterEngine viewControllerForId:viewId];
if (controller == nil) {
return nil;
Expand Down Expand Up @@ -463,7 +463,7 @@ - (void)loadAOTData:(NSString*)assetsDir {
}
}

- (void)registerViewController:(FlutterViewController*)controller forId:(uint64_t)viewId {
- (void)registerViewController:(FlutterViewController*)controller forId:(int64_t)viewId {
NSAssert(controller != nil, @"The controller must not be nil.");
NSAssert(![controller attached],
@"The incoming view controller is already attached to an engine.");
Expand All @@ -473,7 +473,7 @@ - (void)registerViewController:(FlutterViewController*)controller forId:(uint64_
[_viewControllers setObject:controller forKey:@(viewId)];
}

- (void)deregisterViewControllerForId:(uint64_t)viewId {
- (void)deregisterViewControllerForId:(int64_t)viewId {
FlutterViewController* oldController = [self viewControllerForId:viewId];
if (oldController != nil) {
[oldController detachFromEngine];
Expand All @@ -487,7 +487,7 @@ - (void)shutDownIfNeeded {
}
}

- (FlutterViewController*)viewControllerForId:(uint64_t)viewId {
- (FlutterViewController*)viewControllerForId:(int64_t)viewId {
FlutterViewController* controller = [_viewControllers objectForKey:@(viewId)];
NSAssert(controller == nil || controller.id == viewId,
@"The stored controller has unexpected view ID.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
@autoreleasepool {
// Create FVC1.
viewController1 = [[FlutterViewController alloc] initWithProject:project];
EXPECT_EQ(viewController1.id, 0ull);
EXPECT_EQ(viewController1.id, 0ll);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be just 11? Same comment for other occurrences in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, if this should be 1l, then the tests wouldn't pass. :)

Second, all tests here are for the current single-view uses, which only uses the default view. IDs starting from 1 are only for multiviews.

Copy link
Member

@loic-sharma loic-sharma Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm sorry, those are Ls not 1s. Please ignore this comment, I should check my eye prescription.


engine = viewController1.engine;
engine.viewController = nil;
Expand All @@ -661,7 +661,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable

engine.viewController = viewController1;
EXPECT_EQ(engine.viewController, viewController1);
EXPECT_EQ(viewController1.id, 0ull);
EXPECT_EQ(viewController1.id, 0ll);
}

TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByEngine) {
Expand All @@ -675,15 +675,15 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable

@autoreleasepool {
viewController1 = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil];
EXPECT_EQ(viewController1.id, 0ull);
EXPECT_EQ(viewController1.id, 0ll);
EXPECT_EQ(engine.viewController, viewController1);

engine.viewController = nil;

FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine
nibName:nil
bundle:nil];
EXPECT_EQ(viewController2.id, 0ull);
EXPECT_EQ(viewController2.id, 0ll);
EXPECT_EQ(engine.viewController, viewController2);
}
// FVC2 is deallocated but FVC1 is retained.
Expand All @@ -692,7 +692,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable

engine.viewController = viewController1;
EXPECT_EQ(engine.viewController, viewController1);
EXPECT_EQ(viewController1.id, 0ull);
EXPECT_EQ(viewController1.id, 0ll);
}

} // namespace flutter::testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
/**
* The `FlutterViewController` associated with the given view ID, if any.
*/
- (nullable FlutterViewController*)viewControllerForId:(uint64_t)viewId;
- (nullable FlutterViewController*)viewControllerForId:(int64_t)viewId;

/**
* Informs the engine that the specified view controller's window metrics have changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

// Set up embedder API mock.
FlutterSemanticsAction called_action;
uint64_t called_id;
int64_t called_id;

engine.embedderAPI.DispatchSemanticsAction = MOCK_ENGINE_PROC(
DispatchSemanticsAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
/**
* Called by the engine when the given view's buffers should be swapped.
*/
- (BOOL)present:(uint64_t)viewId texture:(nonnull const FlutterMetalTexture*)texture;
- (BOOL)present:(int64_t)viewId texture:(nonnull const FlutterMetalTexture*)texture;

/**
* Creates a Metal texture for the given view with the given size.
*/
- (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size;
- (FlutterMetalTexture)createTextureForView:(int64_t)viewId size:(CGSize)size;

/**
* Populates the texture registry with the provided metalTexture.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static FlutterMetalTexture OnGetNextDrawableForDefaultView(FlutterEngine* engine
// TODO(dkwingsmt): This callback only supports single-view, therefore it only
// operates on the default view. To support multi-view, we need a new callback
// that also receives a view ID, or pass the ID via FlutterFrameInfo.
uint64_t viewId = kFlutterDefaultViewId;
int64_t viewId = kFlutterDefaultViewId;
CGSize size = CGSizeMake(frameInfo->size.width, frameInfo->size.height);
return [engine.renderer createTextureForView:viewId size:size];
}
Expand All @@ -27,7 +27,7 @@ static bool OnPresentDrawableOfDefaultView(FlutterEngine* engine,
// TODO(dkwingsmt): This callback only supports single-view, therefore it only
// operates on the default view. To support multi-view, we need a new callback
// that also receives a view ID.
uint64_t viewId = kFlutterDefaultViewId;
int64_t viewId = kFlutterDefaultViewId;
return [engine.renderer present:viewId texture:texture];
}

Expand Down Expand Up @@ -88,7 +88,7 @@ - (FlutterRendererConfig)createRendererConfig {

#pragma mark - Embedder callback implementations.

- (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size {
- (FlutterMetalTexture)createTextureForView:(int64_t)viewId size:(CGSize)size {
FlutterView* view = [_viewProvider viewForId:viewId];
NSAssert(view != nil, @"Can't create texture on a non-existent view 0x%llx.", viewId);
if (view == nil) {
Expand All @@ -98,7 +98,7 @@ - (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size {
return [view.surfaceManager surfaceForSize:size].asFlutterMetalTexture;
}

- (BOOL)present:(uint64_t)viewId texture:(const FlutterMetalTexture*)texture {
- (BOOL)present:(int64_t)viewId texture:(const FlutterMetalTexture*)texture {
FlutterView* view = [_viewProvider viewForId:viewId];
if (view == nil) {
return NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ @implementation FlutterViewController {

std::shared_ptr<flutter::AccessibilityBridgeMac> _bridge;

uint64_t _id;
int64_t _id;
}

@dynamic id;
Expand Down Expand Up @@ -430,7 +430,7 @@ - (void)setBackgroundColor:(NSColor*)color {
[_flutterView setBackgroundColor:_backgroundColor];
}

- (uint64_t)id {
- (int64_t)id {
NSAssert([self attached], @"This view controller is not attched.");
return _id;
}
Expand Down Expand Up @@ -459,7 +459,7 @@ - (void)notifySemanticsEnabledChanged {
return _bridge;
}

- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(uint64_t)viewId {
- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(int64_t)viewId {
NSAssert(_engine == nil, @"Already attached to an engine %@.", _engine);
_engine = engine;
_id = viewId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* This method is called by FlutterEngine.
*/
- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(uint64_t)viewId;
- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(int64_t)viewId;

/**
* Reset the `engine` and `id` of this controller.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine {
return self;
}

- (nullable FlutterView*)viewForId:(uint64_t)viewId {
- (nullable FlutterView*)viewForId:(int64_t)viewId {
return [_engine viewControllerForId:viewId].flutterView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
OCMStub([mockEngine viewControllerForId:0])
.ignoringNonObjectArgs()
.andDo(^(NSInvocation* invocation) {
uint64_t viewId;
int64_t viewId;
[invocation getArgument:&viewId atIndex:2];
if (viewId == 0 /* kFlutterDefaultViewId */) {
if (mockFlutterViewController != nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"

extern const uint64_t kFlutterDefaultViewId;
extern const int64_t kFlutterDefaultViewId;

/**
* An interface to query FlutterView.
Expand All @@ -20,6 +20,6 @@ extern const uint64_t kFlutterDefaultViewId;
*
* Returns nil if the ID is invalid.
*/
- (nullable FlutterView*)viewForId:(uint64_t)id;
- (nullable FlutterView*)viewForId:(int64_t)id;

@end