Skip to content

Conversation

@bernaferrari
Copy link
Contributor

@bernaferrari bernaferrari commented Mar 9, 2023

Fix #13675 by reducing paint area by the width of the border, when border has opacity of 1.

image

Frame 10

There are many many ways to face this challenge. I opted into the "slightly-weirder but cleaner" solution, since I need to cast OutlinedBorder in ShapeDecoration. The other option would be adding isShadow = false to paintInterior (or maybe even an enum like PaintInteriorKind) so we can differ between shadows and not shadows (we want shadows to be painted over the same area). This would add the calculation everywhere (RoundedRectangleBorder, CircleBorder, StadiumBorder, etc), so I thought it was simpler to just put in ShapeDecoration (simpler + easier to maintain!).

  • ✅ This fixes color.
  • ✅ Images get bounded already when there is a border, so this isn't needed for them.
  • ❌ This doesn't fix gradient, for now (should it? Should it work the same as images or color?). If you have a lerp between a solid and transparent border, the gradient will jump at t=0. It is small, but necessary. Which issue is better to have?

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 9, 2023
@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch 4 times, most recently from 5c974c4 to 0933a9b Compare March 9, 2023 19:32
@flutter-dashboard

This comment was marked as outdated.

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Mar 9, 2023
@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch 4 times, most recently from c9402fd to 1517d4f Compare March 9, 2023 21:39
@flutter-dashboard

This comment was marked as outdated.

@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch 2 times, most recently from c88563b to 82d5630 Compare March 10, 2023 14:49
@flutter-dashboard

This comment was marked as outdated.

@HansMuller HansMuller requested a review from gspencergoog March 17, 2023 22:00
@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch 8 times, most recently from 9a594d2 to 7d69b22 Compare March 19, 2023 16:17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are flipped because of this #122034 (comment)

I don't know which name would fit better. borderVerticalLines? Or I just flip them and vertical: borderHorizontal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't appear flipped to me, and make sense as-is. They're referring to the border size on the vertical and horizontal sides of the rect, right?

@flutter-dashboard flutter-dashboard bot added the f: material design flutter/packages/flutter/material repository. label Mar 19, 2023
@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch 2 times, most recently from f80f915 to cb6bc78 Compare March 19, 2023 16:30
@flutter-dashboard

This comment was marked as outdated.

@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch from cb6bc78 to 650fac1 Compare March 20, 2023 03:55
@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch from e7ed131 to 90fda14 Compare April 27, 2023 16:45
@bernaferrari bernaferrari force-pushed the Avoid-Clipping-Edges branch from 90fda14 to 2e68863 Compare April 27, 2023 16:46
@gspencergoog
Copy link
Contributor

It's also some with borders too:
image

Here's an example of the diffs for one without borders:
image

@bernaferrari
Copy link
Contributor Author

Thanks. I'll debug that here.

@gspencergoog
Copy link
Contributor

They're pretty trivial, so as long as we can say that they are more correct now than they were, I'm OK with approving them.

@bernaferrari
Copy link
Contributor Author

I'll see if I can debug today (at max, until weekend) and tell you the verdict. I think the code I just pushed should help. Please check here again in a few hours when Google Testing has ran again to see if it changed.. lol

@bernaferrari
Copy link
Contributor Author

Meanwhile, if you want to play with borders, I have two other border-related-PRs waiting for your feedback 😛.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #122317 at sha 92de4b2

@gspencergoog
Copy link
Contributor

I approved the goldens. Looks like they are fine.

// rounding error leaking the background color around the clipped
// shape.
// https://github.com/flutter/flutter/issues/13675
final Rect ajustedRect = _adjustRectOnOutlinedBorder(rect, textDirection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: adjusted

Copy link
Contributor Author

@bernaferrari bernaferrari Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm traveling to SF, I'll fix this (and my other PRs) next week.

// When border is filled, the rect is reduced to avoid anti-aliasing
// rounding error leaking the background color around the clipped
// shape.
// https://github.com/flutter/flutter/issues/13675
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to link to the issue, just put whatever is relevant in the comment. (The code will probably outlive the bug database.)

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@bernaferrari
Copy link
Contributor Author

Status: I went on vacation, I came back, I already fixed a few pending PRs, this is coming pretty soon.

@CoolDude53
Copy link

@bernaferrari any update on this?

@bernaferrari
Copy link
Contributor Author

Not yet, I got ready a few things that were pending already, but this is tricky because of the Google Testing, so it is trial and error and I need to ask someone from Google every trial and error if there was a progress.

@bernaferrari
Copy link
Contributor Author

Without being able to test on google testing, I think I'll give up on this for now :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Circular-shaped decorations are not properly clipped

4 participants