mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 06:10:40 +01:00
[desktopCapture Mac] Continue screen capture at graphic cards switching
The MBP having both discrete and integrated graphic cards will do automate graphics switching by default. When it switches from discrete to integrated one, the current display ID of the built-in display will change and this will cause screen capture stops. So make screen capture of built-in display continuing even if its display ID is changed. Bug: chromium:836979 Change-Id: If4f2d04d99a2690ccd6f894d94e6f8ff58ba2ec8 Reviewed-on: https://webrtc-review.googlesource.com/72603 Reviewed-by: Jamie Walch <jamiewalch@chromium.org> Commit-Queue: Brave Yao <braveyao@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23048}
This commit is contained in:
parent
65e9439f38
commit
ad7f6e5ccf
2 changed files with 17 additions and 4 deletions
|
@ -40,6 +40,9 @@ struct MacDisplayConfiguration {
|
|||
|
||||
// Scale factor from DIPs to physical pixels.
|
||||
float dip_to_pixel_scale = 1.0f;
|
||||
|
||||
// Display type, built-in or external.
|
||||
bool is_builtin;
|
||||
};
|
||||
|
||||
typedef std::vector<MacDisplayConfiguration> MacDisplayConfigurations;
|
||||
|
@ -67,7 +70,9 @@ struct MacDesktopConfiguration {
|
|||
// Returns true if the given desktop configuration equals this one.
|
||||
bool Equals(const MacDesktopConfiguration& other);
|
||||
|
||||
// Returns the pointer to the display configuration with the specified id.
|
||||
// If |id| corresponds to the built-in display, return its configuration,
|
||||
// otherwise return the configuration for the display with the specified id,
|
||||
// or nullptr if no such display exists.
|
||||
const MacDisplayConfiguration* FindDisplayConfigurationById(
|
||||
CGDirectDisplayID id);
|
||||
|
||||
|
|
|
@ -69,6 +69,9 @@ MacDisplayConfiguration GetConfigurationForScreen(NSScreen* screen) {
|
|||
display_config.pixel_bounds = display_config.bounds;
|
||||
}
|
||||
|
||||
// Determine if the display is built-in or external.
|
||||
display_config.is_builtin = CGDisplayIsBuiltin(display_config.id);
|
||||
|
||||
return display_config;
|
||||
}
|
||||
|
||||
|
@ -164,14 +167,19 @@ bool MacDesktopConfiguration::Equals(const MacDesktopConfiguration& other) {
|
|||
displays == other.displays;
|
||||
}
|
||||
|
||||
// Finds the display configuration with the specified id.
|
||||
const MacDisplayConfiguration*
|
||||
MacDesktopConfiguration::FindDisplayConfigurationById(
|
||||
CGDirectDisplayID id) {
|
||||
bool is_builtin = CGDisplayIsBuiltin(id);
|
||||
for (MacDisplayConfigurations::const_iterator it = displays.begin();
|
||||
it != displays.end(); ++it) {
|
||||
if (it->id == id)
|
||||
return &(*it);
|
||||
// The MBP having both discrete and integrated graphic cards will do
|
||||
// automate graphics switching by default. When it switches from discrete to
|
||||
// integrated one, the current display ID of the built-in display will
|
||||
// change and this will cause screen capture stops.
|
||||
// So make screen capture of built-in display continuing even if its display
|
||||
// ID is changed.
|
||||
if ((is_builtin && it->is_builtin) || (!is_builtin && it->id == id)) return &(*it);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue