diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 5b7ab4907fada..cad4866d91e46 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2638,6 +2638,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterVie ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProviderTest.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h + ../../../flutter/LICENSE @@ -5100,6 +5101,7 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewE FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProviderTest.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h +FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index 6dc6b79a98146..d3d51635de682 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -182,6 +182,7 @@ executable("flutter_desktop_darwin_unittests") { "framework/Source/FlutterViewControllerTestUtils.h", "framework/Source/FlutterViewControllerTestUtils.mm", "framework/Source/FlutterViewEngineProviderTest.mm", + "framework/Source/FlutterViewTest.mm", "framework/Source/TestFlutterPlatformView.h", "framework/Source/TestFlutterPlatformView.mm", ] diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index d71f5accafab4..74173158d8c59 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -88,7 +88,7 @@ FML_DCHECK(platform_view) << "Platform view not found for id: " << platform_view_id; - CGFloat scale = platform_view.layer.contentsScale; + CGFloat scale = default_base_view.layer.contentsScale; platform_view.frame = CGRectMake(layer->offset.x / scale, layer->offset.y / scale, layer->size.width / scale, layer->size.height / scale); if (platform_view.superview == nil) { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/shell/platform/darwin/macos/framework/Source/FlutterView.mm index 9991918153dfa..c3f802d43ed9e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -106,6 +106,12 @@ - (void)viewDidChangeBackingProperties { [_reshapeListener viewDidReshape:self]; } +- (BOOL)layer:(CALayer*)layer + shouldInheritContentsScale:(CGFloat)newScale + fromWindow:(NSWindow*)window { + return YES; +} + - (void)shutdown { [_threadSynchronizer shutdown]; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm new file mode 100644 index 0000000000000..15ca078042fd8 --- /dev/null +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm @@ -0,0 +1,30 @@ +// 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/macos/framework/Source/FlutterView.h" + +#import + +#import "flutter/testing/testing.h" + +@interface TestReshapeListener : NSObject + +@end + +@implementation TestReshapeListener + +- (void)viewDidReshape:(nonnull NSView*)view { +} + +@end + +TEST(FlutterView, ShouldInheritContentsScaleReturnsYes) { + id device = MTLCreateSystemDefaultDevice(); + id queue = [device newCommandQueue]; + TestReshapeListener* listener = [[TestReshapeListener alloc] init]; + FlutterView* view = [[FlutterView alloc] initWithMTLDevice:device + commandQueue:queue + reshapeListener:listener]; + EXPECT_EQ([view layer:view.layer shouldInheritContentsScale:3.0 fromWindow:view.window], YES); +}