-
Couldn't load subscription status.
- Fork 6k
[embedder] Project Arg to specify the display refresh rate #21094
Changes from all commits
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 |
|---|---|---|
|
|
@@ -963,6 +963,43 @@ typedef const FlutterLocale* (*FlutterComputePlatformResolvedLocaleCallback)( | |
| const FlutterLocale** /* supported_locales*/, | ||
| size_t /* Number of locales*/); | ||
|
|
||
| /// Display refers to a graphics hardware system consisting of a framebuffer, | ||
| /// typically a monitor or a screen. This ID is unique per display and is | ||
| /// stable until the Flutter application restarts. | ||
|
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 would an embedding enforce this? 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. This was the display ID I was planning on using: https://developer.apple.com/documentation/coregraphics/cgdirectdisplayid?language=objc. |
||
| typedef uint64_t FlutterDisplayId; | ||
|
|
||
| typedef struct { | ||
| /// This size of this struct. Must be sizeof(FlutterDisplay). | ||
| size_t struct_size; | ||
|
|
||
| FlutterDisplayId display_id; | ||
|
|
||
| /// A double-precision floating-point value representing the actual refresh | ||
| /// period in seconds. This value may be zero if the device is not running or | ||
| /// unavaliable or unknown. | ||
| double refresh_rate; | ||
|
|
||
| } FlutterDisplay; | ||
|
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. We should use 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. Will do. |
||
|
|
||
| typedef struct { | ||
| /// This size of this struct. Must be sizeof(FlutterDisplaySettings). | ||
| size_t struct_size; | ||
|
|
||
| /// Contains the actual number of displays returned in the displays array. | ||
|
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. s/actual number/number/ s/returned// (since this isn't part of a function, so nothing is being returned) |
||
| size_t display_count; | ||
|
|
||
| /// A pointer to storage provided by the caller for an array of | ||
| /// FlutterDisplays. On return, the array contains a list of active displays. | ||
| /// If you pass NULL, on return the display_count contains the total number of | ||
|
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. Again, this seems to be describing a function, but it's the comment for a struct element. 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. Yup, agreed, I will go over the docs and make sure they align with structs and functions. |
||
| /// active displays. | ||
| FlutterDisplay* displays; | ||
|
|
||
| } FlutterDisplaySettings; | ||
|
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. Same note about prefix. |
||
|
|
||
| typedef void (*FlutterDisplaySettingsCallback)( | ||
|
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. Please document. |
||
| void* user_data, | ||
| FlutterDisplaySettings* display_settings); | ||
|
|
||
| typedef int64_t FlutterEngineDartPort; | ||
|
|
||
| typedef enum { | ||
|
|
@@ -1318,6 +1355,15 @@ typedef struct { | |
| /// matches what the platform would natively resolve to as possible. | ||
| FlutterComputePlatformResolvedLocaleCallback | ||
| compute_platform_resolved_locale_callback; | ||
|
|
||
| /// A callback to provide the settings for all the displays that are active | ||
| /// i.e, not mirrored or sleeping. | ||
| /// | ||
| /// A display is considered active if: | ||
| /// 1. The frame buffer hardware is connected. | ||
| /// 2. The display is drawable, e.g. it isn't being mirrored from another | ||
| /// connected display or sleeping. | ||
| FlutterDisplaySettingsCallback display_settings_callback; | ||
|
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. I'm confused as to how this API would work; how would the engine know when the display list has changed and it needs to call this again? Since the embedder, not the engine, knows when the display list changes, I would expect a method called by the embedder to push information into the engine. Even if for some reason that's not necessary now, it certainly will be when we're actually exposing display information in Dart, and we shouldn't have two different ways of providing the same information. /cc @gspencergoog 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. Good point, currently this change isn't accounting for cases where the display configuration changes while the app is running. I'm thinking of modifying the API to notify the engine on display reconfiguration, with 4 modes:
We might be able to use CGDisplayReconfigurationCallBack on macOS. WDYT? 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. Yes, I think we will need those events, and they will have to come from the embedder and notify the engine. One other thing to note is that some platforms won't be able to provide all of the information. For instance, on UWP and web it's not possible to find out what screens are connected, or their resolutions, if the current view isn't on that screen. And it doesn't provide the information for more than one screen if you span screens. The screen configuration doesn't even have to change, though. You can just drag the window to another screen (or even just adjust it's position so more than half of it is on another screen on some platforms) and that will change these values for that app. 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.
I will document that this is best effort, with the only guarantee that embedder MUST provide at least one display setting which will correspond to the main screen (where the app window is active).
I am envisioning that this will result in 2 events being invoked by the embedder:
Though there is some additional checks that are needed to be done by the embedders to ensure that the engine is aware of at least one display at any given time (i.e, no remove before add), I think it's ok to have this. 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.
Well, but when we have multiple windows, there will be multiple display settings that apply (one or more for each window). Not that you need to solve multi-window here, but maybe the requirement should be that it provide screen settings corresponding to each window displayed. |
||
| } FlutterProjectArgs; | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
|
|
||
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.
Update the class doc comment to cover this ctor.
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