Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all combinations of GetRectsForRange styles #6591

Merged
merged 8 commits into from
Oct 23, 2018

Conversation

GaryQian
Copy link
Contributor

This PR defines two engine-side enums, RectHeightStyle and RectWidthStyle which are used to specify the type of rects GetRectsForRange will return.

  • RectHeightStyle controls the top and bottom edges of the rects, and provides options for Tight bounds, Max height of the line, as well as full coverage (taking into account line spacing) as aligned in the middle, top and bottom.
  • RectWidthStyle allows mac-style extension of boxes to the end of the line as well as the default tight bounds.

This feature is not yet enabled in the framework and currently defaults to Tight bounds on both height and width to maintain compatibility. It will be enabled in a separate (near) future PR.

std::map<size_t, std::vector<Paragraph::TextBox>> line_boxes;

// Per-line min and max top/bottom edges over all runs in a given line.
std::vector<SkScalar> min_tops;
Copy link
Member

Choose a reason for hiding this comment

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

Change the value type of the line_boxes map to be a struct that hold the line's TextBoxes and its min/max_top/bottom values

// Check to see if we are finished.
if (run.code_units.start >= end) {
// We continue to store metrics of one additional line if available.
if (run.line_number <= max_line + 1) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to avoid processing runs outside the selected range if possible.

It looks like the additional line's runs are needed in order to find the amount of spacing between lines. Can this be calculated and stored during layout?

} else if (rect_height_style ==
RectHeightStyle::kIncludeLineSpacingMiddle) {
SkScalar adjusted_bottom =
kv.first >= line_ranges_.size() - 1
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: the ternary expressions used to calculate the adjusted_top/bottom values duplicate the non-adjusted values. This would be simpler as:

SkScalar adjusted_bottom = line_baselines_[kv.first] + line_max_descent_[kv.first];
if (kv.first < line_ranges_.size() - 1) {
  adjusted_botom += (line_max_spacings_[kv.first + 1] - line_max_ascent_[kv.first + 1]) / 2;
}

double max_right_;
double min_left_;

struct LineBoxMetrics {
Copy link
Member

Choose a reason for hiding this comment

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

This can be declared locally within Paragraph::GetRectsForRange

for (const Paragraph::TextBox& box : kv.second.boxes) {
SkScalar adjusted_bottom =
kv.first >= line_ranges_.size() - 1
? line_baselines_[kv.first] + line_max_descent_[kv.first]
Copy link
Member

Choose a reason for hiding this comment

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

Remove the ternary operator here (similar to the change made to adjusted_bottom above)

@GaryQian GaryQian merged commit 2586e94 into flutter:master Oct 23, 2018
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 23, 2018
flutter/engine@4c79e42...2586e94

git log 4c79e42..2586e94 --no-merges --oneline
2586e94 Support all combinations of GetRectsForRange styles (flutter/engine#6591)
e78f86e Fix mac builds. Only Linux and Windows require default GL proc resolvers. (flutter/engine#6641)
52e48ab Fix Windows embedding. Appears that flutter#6523 or flutter#6525 introduced a bug for embedder scenarios causing the window native library to be incorrectly initialized and thus incapable of correctly resolving GL functions.  This change fixes that. (flutter/engine#6624)
c9197e4 Roll src/third_party/skia 25837bf17019..b46c4d0925ad (6 commits) (flutter/engine#6640)
324c21a Roll src/third_party/skia 1b07dffd979d..25837bf17019 (1 commits) (flutter/engine#6639)
5dfbc0a Roll src/third_party/skia e023ae7c5540..1b07dffd979d (1 commits) (flutter/engine#6638)
4a18dff Roll src/third_party/skia ff1aeb953faf..e023ae7c5540 (1 commits) (flutter/engine#6637)
427915e Allow FlutterViewController to specify whether its FlutterView is opaque (flutter/engine#6570)
20c805c Ensure that Scene::toImage renders texture backed images. (flutter/engine#6636)
25d0507 Roll buildtools to 5a9e1b3a0b84a2871f20f85fde665e54a894ba72 (flutter/engine#6633)
4f17d7e Roll src/third_party/skia 327955b1ba19..ff1aeb953faf (13 commits) (flutter/engine#6635)
cdd592f Reland &#39;Pass null instead of &#39;none&#39; locale&#39; (flutter/engine#6632)
2cd8920 Roll src/third_party/skia b1a002e850e1..327955b1ba19 (12 commits) (flutter/engine#6631)
edfe024 13771 - iOS dictation bug (flutter/engine#6607)
cadf440 Roll src/third_party/skia b9998cdceec7..b1a002e850e1 (13 commits) (flutter/engine#6626)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/&#43;/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff, who should
be CC&#39;d on the roll, and stop the roller if necessary.
goderbauer pushed a commit to flutter/flutter that referenced this pull request Oct 23, 2018
flutter/engine@4c79e42...2586e94

git log 4c79e42..2586e94 --no-merges --oneline
2586e94 Support all combinations of GetRectsForRange styles (flutter/engine#6591)
e78f86e Fix mac builds. Only Linux and Windows require default GL proc resolvers. (flutter/engine#6641)
52e48ab Fix Windows embedding. Appears that #6523 or #6525 introduced a bug for embedder scenarios causing the window native library to be incorrectly initialized and thus incapable of correctly resolving GL functions.  This change fixes that. (flutter/engine#6624)
c9197e4 Roll src/third_party/skia 25837bf17019..b46c4d0925ad (6 commits) (flutter/engine#6640)
324c21a Roll src/third_party/skia 1b07dffd979d..25837bf17019 (1 commits) (flutter/engine#6639)
5dfbc0a Roll src/third_party/skia e023ae7c5540..1b07dffd979d (1 commits) (flutter/engine#6638)
4a18dff Roll src/third_party/skia ff1aeb953faf..e023ae7c5540 (1 commits) (flutter/engine#6637)
427915e Allow FlutterViewController to specify whether its FlutterView is opaque (flutter/engine#6570)
20c805c Ensure that Scene::toImage renders texture backed images. (flutter/engine#6636)
25d0507 Roll buildtools to 5a9e1b3a0b84a2871f20f85fde665e54a894ba72 (flutter/engine#6633)
4f17d7e Roll src/third_party/skia 327955b1ba19..ff1aeb953faf (13 commits) (flutter/engine#6635)
cdd592f Reland &#39;Pass null instead of &#39;none&#39; locale&#39; (flutter/engine#6632)
2cd8920 Roll src/third_party/skia b1a002e850e1..327955b1ba19 (12 commits) (flutter/engine#6631)
edfe024 13771 - iOS dictation bug (flutter/engine#6607)
cadf440 Roll src/third_party/skia b9998cdceec7..b1a002e850e1 (13 commits) (flutter/engine#6626)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/&#43;/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff, who should
be CC&#39;d on the roll, and stop the roller if necessary.
Xavjer pushed a commit to Xavjer/flutter that referenced this pull request Oct 24, 2018
flutter/engine@4c79e42...2586e94

git log 4c79e42..2586e94 --no-merges --oneline
2586e94 Support all combinations of GetRectsForRange styles (flutter/engine#6591)
e78f86e Fix mac builds. Only Linux and Windows require default GL proc resolvers. (flutter/engine#6641)
52e48ab Fix Windows embedding. Appears that flutter#6523 or flutter#6525 introduced a bug for embedder scenarios causing the window native library to be incorrectly initialized and thus incapable of correctly resolving GL functions.  This change fixes that. (flutter/engine#6624)
c9197e4 Roll src/third_party/skia 25837bf17019..b46c4d0925ad (6 commits) (flutter/engine#6640)
324c21a Roll src/third_party/skia 1b07dffd979d..25837bf17019 (1 commits) (flutter/engine#6639)
5dfbc0a Roll src/third_party/skia e023ae7c5540..1b07dffd979d (1 commits) (flutter/engine#6638)
4a18dff Roll src/third_party/skia ff1aeb953faf..e023ae7c5540 (1 commits) (flutter/engine#6637)
427915e Allow FlutterViewController to specify whether its FlutterView is opaque (flutter/engine#6570)
20c805c Ensure that Scene::toImage renders texture backed images. (flutter/engine#6636)
25d0507 Roll buildtools to 5a9e1b3a0b84a2871f20f85fde665e54a894ba72 (flutter/engine#6633)
4f17d7e Roll src/third_party/skia 327955b1ba19..ff1aeb953faf (13 commits) (flutter/engine#6635)
cdd592f Reland &flutter#39;Pass null instead of &flutter#39;none&flutter#39; locale&flutter#39; (flutter/engine#6632)
2cd8920 Roll src/third_party/skia b1a002e850e1..327955b1ba19 (12 commits) (flutter/engine#6631)
edfe024 13771 - iOS dictation bug (flutter/engine#6607)
cadf440 Roll src/third_party/skia b9998cdceec7..b1a002e850e1 (13 commits) (flutter/engine#6626)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/&#43;/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff, who should
be CC&flutter#39;d on the roll, and stop the roller if necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants