This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
iOS PlatformView clip path #9478
Merged
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
853cbd6
get the stack ready
72042cf
draft
8489c08
Do nothing if the params didn't change when compositing platform views.
647e66b
merge
f7d7aaa
draft
c0741b2
draft
6e95d26
draft2
a3e1d61
clip rrect
4cf9f8a
typo fix
1daacb0
Merge branch 'master' into platform_view_transform
04d1f40
counting previous clips and only add and remove uiview when number of…
5b05eb2
draft
9b290cb
draft
52a8252
comments and formatting
3a899fa
english
cabc67a
remove friend from operator==
4496b21
merge master
4bdae98
fix issue caused by merging
33513b9
review fixes
e8926a5
remove tranform\cilpping util method into a different file and add th…
3f4c586
rename after review
d4f88f2
move stack to paint context
4eeb64f
draft vector with unique_ptr
6d78901
more review fixes
e494853
unittests for mutator stack
81e5c19
move stack to paint context complete
ea11fad
formatting
2c79050
Merge branch 'master' into platform_view_transform
5deaaeb
draft
0f70a44
mutator stack compare fixes
32d2681
mutator stack compare fixes
021b2ce
merge
b874420
revert the change that made the vector containing unique_ptr
95d2834
merge
a1794de
formatting
7178add
Merge branch 'platform_view_transform' into platform_view_clip_path
2f0125c
add TODO
d22acbd
fix a bug where the reused clip view doesn't reset transform
2b08642
addition to last fix
1599067
adding touch transparent view
f1f36bd
Merge branch 'platform_view_transform' into platform_view_clip_path
b8e4111
adding approximate for conic and remove debugging logs
a027fa0
some review fixes
12ff43a
union done
a9a660f
draft
f4b9503
review fixes
7c0fa63
draft
2eb40d6
embeded param does not delete stack when destructed
6d4c82c
Merge branch 'platform_view_transform' into platform_view_transform_u…
7d1d0e5
copy constructor for Mutator
46098a4
more tests
fa1248a
remove the move to
dd0eed8
merge
50843a0
share ptr for vector_
31ec192
Merge branch 'master' into platform_view_transform
00fb915
merge
3b6b3b0
formatting
b4b59ca
fixes unittest
ee57e42
Update BUILD.gn
iskakaushik 979d251
license file fix
c4bfea1
Merge branch 'platform_view_transform' into platform_view_clip_path
a297a9f
remove testing logs
98f47aa
merge master
6c7d755
fix
13f515c
mark
467ac65
revert mark
ac72abf
formatting
e64360c
use constant
9b2f55f
review fixes
ad6f400
add todo
8ef8260
Merge branch 'master' into platform_view_clip_path
2c9f1aa
Merge branch 'master' into platform_view_clip_path
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |
|
|
||
| #include "flutter/shell/platform/darwin/ios/ios_surface.h" | ||
|
|
||
| static int kMaxPointsInVerb = 4; | ||
|
|
||
| namespace flutter { | ||
|
|
||
| FlutterPlatformViewLayer::FlutterPlatformViewLayer(fml::scoped_nsobject<UIView> overlay_view, | ||
|
|
@@ -129,6 +131,76 @@ - (void)clipRRect:(const SkRRect&)clipSkRRect { | |
| CGPathRelease(pathRef); | ||
| } | ||
|
|
||
| - (void)clipPath:(const SkPath&)path { | ||
| CGMutablePathRef pathRef = CGPathCreateMutable(); | ||
| if (!path.isValid()) { | ||
| return; | ||
| } | ||
| if (path.isEmpty()) { | ||
| CAShapeLayer* clip = [[CAShapeLayer alloc] init]; | ||
| clip.path = pathRef; | ||
| self.layer.mask = clip; | ||
| CGPathRelease(pathRef); | ||
| return; | ||
| } | ||
|
|
||
| // Loop through all verbs and translate them into CGPath | ||
| SkPath::Iter iter(path, true); | ||
| SkPoint pts[kMaxPointsInVerb]; | ||
| SkPath::Verb verb = iter.next(pts); | ||
| SkPoint last_pt_from_last_verb; | ||
| while (verb != SkPath::kDone_Verb) { | ||
| if (verb == SkPath::kLine_Verb || verb == SkPath::kQuad_Verb || verb == SkPath::kConic_Verb || | ||
| verb == SkPath::kCubic_Verb) { | ||
| FML_DCHECK(last_pt_from_last_verb == pts[0]); | ||
| } | ||
| switch (verb) { | ||
| case SkPath::kMove_Verb: { | ||
| CGPathMoveToPoint(pathRef, nil, pts[0].x(), pts[0].y()); | ||
| last_pt_from_last_verb = pts[0]; | ||
| break; | ||
| } | ||
| case SkPath::kLine_Verb: { | ||
| CGPathAddLineToPoint(pathRef, nil, pts[1].x(), pts[1].y()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we sure we can assume that pts[0] is the last point of the previous verb?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Offline discussion: We confirmed we can assume the pts[0] is always the last point of the previous verb, but we are going to add a DCHECK for our own sanity. |
||
| last_pt_from_last_verb = pts[1]; | ||
| break; | ||
| } | ||
| case SkPath::kQuad_Verb: { | ||
| CGPathAddQuadCurveToPoint(pathRef, nil, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y()); | ||
| last_pt_from_last_verb = pts[2]; | ||
| break; | ||
| } | ||
| case SkPath::kConic_Verb: { | ||
| // Conic is not available in quartz, we use quad to approximate. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reference a TODO issue here to better approximate this with multiple quads. |
||
| // TODO(cyanglaz): Better approximate the conic path. | ||
| // https://github.com/flutter/flutter/issues/35062 | ||
| CGPathAddQuadCurveToPoint(pathRef, nil, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y()); | ||
| last_pt_from_last_verb = pts[2]; | ||
| break; | ||
| } | ||
| case SkPath::kCubic_Verb: { | ||
| CGPathAddCurveToPoint(pathRef, nil, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y(), | ||
| pts[3].x(), pts[3].y()); | ||
| last_pt_from_last_verb = pts[3]; | ||
| break; | ||
| } | ||
| case SkPath::kClose_Verb: { | ||
| CGPathCloseSubpath(pathRef); | ||
| break; | ||
| } | ||
| case SkPath::kDone_Verb: { | ||
| break; | ||
| } | ||
| } | ||
| verb = iter.next(pts); | ||
| } | ||
|
|
||
| CAShapeLayer* clip = [[CAShapeLayer alloc] init]; | ||
| clip.path = pathRef; | ||
| self.layer.mask = clip; | ||
| CGPathRelease(pathRef); | ||
| } | ||
|
|
||
| - (void)setClip:(flutter::MutatorType)type | ||
| rect:(const SkRect&)rect | ||
| rrect:(const SkRRect&)rrect | ||
|
|
@@ -143,7 +215,7 @@ - (void)setClip:(flutter::MutatorType)type | |
| [self clipRRect:rrect]; | ||
| break; | ||
| case flutter::clip_path: | ||
| // TODO(cyanglaz): Add clip path | ||
| [self clipPath:path]; | ||
| break; | ||
| default: | ||
| break; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert