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

Add comment to use of 3x3 mapRect in TransformLayer #43608

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions flow/layers/transform_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ void TransformLayer::Preroll(PrerollContext* context) {
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, &child_paint_bounds);

// We convert to a 3x3 matrix here primarily because the SkM44 object
// does not support a mapRect operation.
// https://bugs.chromium.org/p/skia/issues/detail?id=11720&q=mapRect&can=2
//
// All geometry is X,Y only which means the 3rd row of the 4x4 matrix
// is ignored and the output of the 3rd column is also ignored.
// So we can transform the rectangle using just the 3x3 SkMatrix
// equivalent without any loss of information.
//
// Performance consideration:
// Skia has an internal mapRect for their SkM44 object that is faster
// than what SkMatrix does when it has perspective elements. But SkMatrix
// is otherwise optimal for non-perspective matrices. If SkM44 ever exposes
// a mapRect operation, or if SkMatrix ever optimizes its handling of
// the perspective elements, this issue will become moot.
transform_.asM33().mapRect(&child_paint_bounds);
set_paint_bounds(child_paint_bounds);
}
Expand Down