From 202caa050d5e02c250c8fcba16e276e02796632a Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Wed, 17 Nov 2021 14:46:52 +0100 Subject: [PATCH 1/3] PhysicalShapeLayer: Only push cull rect during diff if clipping (#29783) --- flow/layers/physical_shape_layer.cc | 3 +- flow/layers/physical_shape_layer_unittests.cc | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/flow/layers/physical_shape_layer.cc b/flow/layers/physical_shape_layer.cc index d443448ed97e6..8215f3d6e592f 100644 --- a/flow/layers/physical_shape_layer.cc +++ b/flow/layers/physical_shape_layer.cc @@ -46,7 +46,8 @@ void PhysicalShapeLayer::Diff(DiffContext* context, const Layer* old_layer) { context->AddLayerBounds(bounds); - if (context->PushCullRect(bounds)) { + // Only push cull rect if there is clip. + if (clip_behavior_ == Clip::none || context->PushCullRect(bounds)) { DiffChildren(context, prev); } context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion()); diff --git a/flow/layers/physical_shape_layer_unittests.cc b/flow/layers/physical_shape_layer_unittests.cc index e81c28080ea53..9a9bafb8f6895 100644 --- a/flow/layers/physical_shape_layer_unittests.cc +++ b/flow/layers/physical_shape_layer_unittests.cc @@ -4,6 +4,7 @@ #include "flutter/flow/layers/physical_shape_layer.h" +#include "flutter/flow/testing/diff_context_test.h" #include "flutter/flow/testing/layer_test.h" #include "flutter/flow/testing/mock_layer.h" #include "flutter/fml/macros.h" @@ -350,5 +351,43 @@ TEST_F(PhysicalShapeLayerTest, Readback) { EXPECT_TRUE(ReadbackResult(context, save_layer, reader, true)); } +using PhysicalShapeLayerDiffTest = DiffContextTest; + +TEST_F(PhysicalShapeLayerDiffTest, NoClipPaintRegion) { + MockLayerTree tree1; + const SkPath layer_path = SkPath().addRect(SkRect::MakeXYWH(0, 0, 100, 100)); + auto layer = + std::make_shared(SK_ColorGREEN, SK_ColorBLACK, + 0.0f, // elevation + layer_path, Clip::none); + + const SkPath layer_path2 = + SkPath().addRect(SkRect::MakeXYWH(200, 200, 200, 200)); + auto layer2 = std::make_shared(layer_path2); + layer->Add(layer2); + tree1.root()->Add(layer); + + auto damage = DiffLayerTree(tree1, MockLayerTree()); + EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 400, 400)); +} + +TEST_F(PhysicalShapeLayerDiffTest, ClipPaintRegion) { + MockLayerTree tree1; + const SkPath layer_path = SkPath().addRect(SkRect::MakeXYWH(0, 0, 100, 100)); + auto layer = + std::make_shared(SK_ColorGREEN, SK_ColorBLACK, + 0.0f, // elevation + layer_path, Clip::hardEdge); + + const SkPath layer_path2 = + SkPath().addRect(SkRect::MakeXYWH(200, 200, 200, 200)); + auto layer2 = std::make_shared(layer_path2); + layer->Add(layer2); + tree1.root()->Add(layer); + + auto damage = DiffLayerTree(tree1, MockLayerTree()); + EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 100, 100)); +} + } // namespace testing } // namespace flutter From 75476d2e7dcf2953ecfe0d9b4c5ea748ebd370e9 Mon Sep 17 00:00:00 2001 From: WenJingRui <2539699336@qq.com> Date: Tue, 23 Nov 2021 07:27:56 +0800 Subject: [PATCH 2/3] [iOS] Fix:Keyboard inset is not correct when presenting and native ViewController on FlutterViewController (#29862) --- .../darwin/ios/framework/Source/FlutterViewController.mm | 5 +++-- .../ios/framework/Source/FlutterViewControllerTest.mm | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 5b789d0175f99..c38cb4cd56854 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -1193,9 +1193,10 @@ - (void)startKeyBoardAnimation:(NSTimeInterval)duration { } completion:^(BOOL finished) { if (self.displayLink == currentDisplayLink) { + // Indicates the displaylink captured by this block is the original one,which also + // indicates the animation has not been interrupted from its beginning. Moreover,indicates + // the animation is over and there is no more animation about to exectute. [self invalidateDisplayLink]; - } - if (finished) { [self removeKeyboardAnimationView]; [self ensureViewportMetricsIsCorrect]; } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm index 84abb4bb13dbe..9e27a13e54857 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm @@ -173,9 +173,17 @@ - (void)testkeyboardWillChangeFrameWillStartKeyboardAnimation { @"UIKeyboardAnimationDurationUserInfoKey" : [NSNumber numberWithDouble:0.25], @"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal] }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"update viewport"]; + OCMStub([mockEngine updateViewportMetrics:flutter::ViewportMetrics()]) + .ignoringNonObjectArgs() + .andDo(^(NSInvocation* invocation) { + [expectation fulfill]; + }); id viewControllerMock = OCMPartialMock(viewController); [viewControllerMock keyboardWillChangeFrame:notification]; OCMVerify([viewControllerMock startKeyBoardAnimation:0.25]); + [self waitForExpectationsWithTimeout:5.0 handler:nil]; } - (void)testEnsureViewportMetricsWillInvokeAndDisplayLinkWillInvalidateInViewDidDisappear { From 9e0d7e51f7891752a934408699e793d04107ad7e Mon Sep 17 00:00:00 2001 From: Xiao Yu Date: Tue, 23 Nov 2021 13:18:43 -0800 Subject: [PATCH 3/3] add branch to test for CI --- .ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci.yaml b/.ci.yaml index 12abdde9297e9..2c8d231a6a45b 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -11,6 +11,7 @@ enabled_branches: - dev - beta - stable + - flutter-2.8-candidate.7 platform_properties: linux: