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

Commit 0c76c75

Browse files
authored
Add comment to use of 3x3 mapRect in TransformLayer (#43608)
Addresses comment in flutter/flutter#130303 (comment) No tests as this is just a comment.
1 parent 257bb8d commit 0c76c75

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

flow/layers/transform_layer.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ void TransformLayer::Preroll(PrerollContext* context) {
4646
SkRect child_paint_bounds = SkRect::MakeEmpty();
4747
PrerollChildren(context, &child_paint_bounds);
4848

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

0 commit comments

Comments
 (0)