iOS: Extract constant for CADisableMinimumFrameDurationOnPhone (flutter/engine#56659)
In our vsync waiter and related tests, we hardcode the "CADisableMinimumFrameDurationOnPhone" key in several places. This pulls those into a constant kCADisableMinimumFrameDurationOnPhoneKey declared in the vsync waiter header, which is non-public, and uses that instead. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
c9f8ebef70
commit
d82d8cf3cd
@ -2093,7 +2093,7 @@ extern NSNotificationName const FlutterViewControllerWillDealloc;
|
||||
|
||||
- (void)testSetupKeyboardAnimationVsyncClientWillCreateNewVsyncClientForFlutterViewController {
|
||||
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
|
||||
OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"])
|
||||
OCMStub([bundleMock objectForInfoDictionaryKey:kCADisableMinimumFrameDurationOnPhoneKey])
|
||||
.andReturn(@YES);
|
||||
id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
|
||||
double maxFrameRate = 120;
|
||||
|
@ -53,7 +53,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
|
||||
auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
|
||||
auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
|
||||
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
|
||||
OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"])
|
||||
OCMStub([bundleMock objectForInfoDictionaryKey:kCADisableMinimumFrameDurationOnPhoneKey])
|
||||
.andReturn(@YES);
|
||||
id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
|
||||
double maxFrameRate = 120;
|
||||
@ -75,7 +75,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
|
||||
auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
|
||||
auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
|
||||
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
|
||||
OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"])
|
||||
OCMStub([bundleMock objectForInfoDictionaryKey:kCADisableMinimumFrameDurationOnPhoneKey])
|
||||
.andReturn(@NO);
|
||||
id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
|
||||
double maxFrameRate = 120;
|
||||
|
@ -11,13 +11,24 @@
|
||||
#include "flutter/shell/common/variable_refresh_rate_reporter.h"
|
||||
#include "flutter/shell/common/vsync_waiter.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief Info.plist key enabling the full range of ProMotion refresh rates for CADisplayLink
|
||||
/// callbacks and CAAnimation animations in the app.
|
||||
///
|
||||
/// @see
|
||||
/// https://developer.apple.com/documentation/quartzcore/optimizing_promotion_refresh_rates_for_iphone_13_pro_and_ipad_pro#3885321
|
||||
///
|
||||
extern NSString* const kCADisableMinimumFrameDurationOnPhoneKey;
|
||||
|
||||
@interface DisplayLinkManager : NSObject
|
||||
|
||||
// Whether the max refresh rate on iPhone Pro-motion devices are enabled.
|
||||
// This reflects the value of `CADisableMinimumFrameDurationOnPhone` in the
|
||||
// info.plist file.
|
||||
//
|
||||
// Note on iPads that support Pro-motion, the max refresh rate is always enabled.
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief Whether the max refresh rate on iPhone ProMotion devices are enabled. This reflects
|
||||
/// the value of `CADisableMinimumFrameDurationOnPhone` in the info.plist file. On iPads
|
||||
/// that support ProMotion, the max refresh rate is always enabled.
|
||||
///
|
||||
/// @return YES if the max refresh rate on ProMotion devices is enabled.
|
||||
///
|
||||
@property(class, nonatomic, readonly) BOOL maxRefreshRateEnabledOnIPhone;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
NSString* const kCADisableMinimumFrameDurationOnPhoneKey = @"CADisableMinimumFrameDurationOnPhone";
|
||||
|
||||
@interface VSyncClient ()
|
||||
@property(nonatomic, assign, readonly) double refreshRate;
|
||||
@end
|
||||
@ -170,7 +172,7 @@ double VsyncWaiterIOS::GetRefreshRate() const {
|
||||
}
|
||||
|
||||
+ (BOOL)maxRefreshRateEnabledOnIPhone {
|
||||
return [[NSBundle.mainBundle objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"]
|
||||
return [[NSBundle.mainBundle objectForInfoDictionaryKey:kCADisableMinimumFrameDurationOnPhoneKey]
|
||||
boolValue];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user