Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d702022

Browse files
authored
Cherrypick #29783 and #29862 to flutter-2.8-candidate.7 (#29898)
Request from b/207432361
1 parent e022c92 commit d702022

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

.ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enabled_branches:
1111
- dev
1212
- beta
1313
- stable
14+
- flutter-2.8-candidate.7
1415

1516
platform_properties:
1617
linux:

flow/layers/physical_shape_layer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ void PhysicalShapeLayer::Diff(DiffContext* context, const Layer* old_layer) {
4646

4747
context->AddLayerBounds(bounds);
4848

49-
if (context->PushCullRect(bounds)) {
49+
// Only push cull rect if there is clip.
50+
if (clip_behavior_ == Clip::none || context->PushCullRect(bounds)) {
5051
DiffChildren(context, prev);
5152
}
5253
context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());

flow/layers/physical_shape_layer_unittests.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "flutter/flow/layers/physical_shape_layer.h"
66

7+
#include "flutter/flow/testing/diff_context_test.h"
78
#include "flutter/flow/testing/layer_test.h"
89
#include "flutter/flow/testing/mock_layer.h"
910
#include "flutter/fml/macros.h"
@@ -350,5 +351,43 @@ TEST_F(PhysicalShapeLayerTest, Readback) {
350351
EXPECT_TRUE(ReadbackResult(context, save_layer, reader, true));
351352
}
352353

354+
using PhysicalShapeLayerDiffTest = DiffContextTest;
355+
356+
TEST_F(PhysicalShapeLayerDiffTest, NoClipPaintRegion) {
357+
MockLayerTree tree1;
358+
const SkPath layer_path = SkPath().addRect(SkRect::MakeXYWH(0, 0, 100, 100));
359+
auto layer =
360+
std::make_shared<PhysicalShapeLayer>(SK_ColorGREEN, SK_ColorBLACK,
361+
0.0f, // elevation
362+
layer_path, Clip::none);
363+
364+
const SkPath layer_path2 =
365+
SkPath().addRect(SkRect::MakeXYWH(200, 200, 200, 200));
366+
auto layer2 = std::make_shared<MockLayer>(layer_path2);
367+
layer->Add(layer2);
368+
tree1.root()->Add(layer);
369+
370+
auto damage = DiffLayerTree(tree1, MockLayerTree());
371+
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 400, 400));
372+
}
373+
374+
TEST_F(PhysicalShapeLayerDiffTest, ClipPaintRegion) {
375+
MockLayerTree tree1;
376+
const SkPath layer_path = SkPath().addRect(SkRect::MakeXYWH(0, 0, 100, 100));
377+
auto layer =
378+
std::make_shared<PhysicalShapeLayer>(SK_ColorGREEN, SK_ColorBLACK,
379+
0.0f, // elevation
380+
layer_path, Clip::hardEdge);
381+
382+
const SkPath layer_path2 =
383+
SkPath().addRect(SkRect::MakeXYWH(200, 200, 200, 200));
384+
auto layer2 = std::make_shared<MockLayer>(layer_path2);
385+
layer->Add(layer2);
386+
tree1.root()->Add(layer);
387+
388+
auto damage = DiffLayerTree(tree1, MockLayerTree());
389+
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 100, 100));
390+
}
391+
353392
} // namespace testing
354393
} // namespace flutter

shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,9 +1193,10 @@ - (void)startKeyBoardAnimation:(NSTimeInterval)duration {
11931193
}
11941194
completion:^(BOOL finished) {
11951195
if (self.displayLink == currentDisplayLink) {
1196+
// Indicates the displaylink captured by this block is the original one,which also
1197+
// indicates the animation has not been interrupted from its beginning. Moreover,indicates
1198+
// the animation is over and there is no more animation about to exectute.
11961199
[self invalidateDisplayLink];
1197-
}
1198-
if (finished) {
11991200
[self removeKeyboardAnimationView];
12001201
[self ensureViewportMetricsIsCorrect];
12011202
}

shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,17 @@ - (void)testkeyboardWillChangeFrameWillStartKeyboardAnimation {
173173
@"UIKeyboardAnimationDurationUserInfoKey" : [NSNumber numberWithDouble:0.25],
174174
@"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal]
175175
}];
176+
177+
XCTestExpectation* expectation = [self expectationWithDescription:@"update viewport"];
178+
OCMStub([mockEngine updateViewportMetrics:flutter::ViewportMetrics()])
179+
.ignoringNonObjectArgs()
180+
.andDo(^(NSInvocation* invocation) {
181+
[expectation fulfill];
182+
});
176183
id viewControllerMock = OCMPartialMock(viewController);
177184
[viewControllerMock keyboardWillChangeFrame:notification];
178185
OCMVerify([viewControllerMock startKeyBoardAnimation:0.25]);
186+
[self waitForExpectationsWithTimeout:5.0 handler:nil];
179187
}
180188

181189
- (void)testEnsureViewportMetricsWillInvokeAndDisplayLinkWillInvalidateInViewDidDisappear {

0 commit comments

Comments
 (0)