mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[macOS] Update FlutterView layer scale when backing properties change (flutter/engine#38402)
This commit is contained in:
parent
7ff15f1845
commit
bc41422fb1
@ -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
|
||||
|
||||
@ -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",
|
||||
]
|
||||
|
||||
@ -88,7 +88,7 @@ void FlutterCompositor::PresentPlatformView(FlutterView* default_base_view,
|
||||
|
||||
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) {
|
||||
|
||||
@ -106,6 +106,12 @@
|
||||
[_reshapeListener viewDidReshape:self];
|
||||
}
|
||||
|
||||
- (BOOL)layer:(CALayer*)layer
|
||||
shouldInheritContentsScale:(CGFloat)newScale
|
||||
fromWindow:(NSWindow*)window {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)shutdown {
|
||||
[_threadSynchronizer shutdown];
|
||||
}
|
||||
|
||||
@ -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 <Metal/Metal.h>
|
||||
|
||||
#import "flutter/testing/testing.h"
|
||||
|
||||
@interface TestReshapeListener : NSObject <FlutterViewReshapeListener>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TestReshapeListener
|
||||
|
||||
- (void)viewDidReshape:(nonnull NSView*)view {
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
TEST(FlutterView, ShouldInheritContentsScaleReturnsYes) {
|
||||
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
|
||||
id<MTLCommandQueue> 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);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user