-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Account for root surface transformation on the surfaces managed by the external view embedder. #11384
Conversation
cc @dnicoara |
A couple of observations:
|
Sure. I will document this. But does this match your expectations? I wasn't sure if the least unexpected behavior for embedders would be for them to be in control of applying this transformation themselves.
|
Ok, I am convinced, this is bogus behavior in this patch. I am fixing it so you wont have to apply the offset about the x-axis. You will still have to apply to the transformation to the contents though. |
Fixed the math. You no longer have to apply the flip over the x-axis unnecessarily. Also documented the behavior that setting the root surface transformation will affect layer offsets and sizes in the present callback. PTAL. |
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.
LGTM modulo nits
if (!surface_transformation_callback_) { | ||
return SkMatrix{}; | ||
} | ||
|
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.
To make sure we apply the same transformation to the frame size and contents, I'd suggest make GetSurfaceTransformation
return identity if !surface_transformation_callback_().rectStaysRect()
. (since if that condition is false we're not applying a size transformation)
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.
Disagree. We use the surface transformation to not only affect the size, but also the offset (of the root surface too). We will lose this information if we return identity here.
// TODO(chinmaygarde): This has the opportunity to become super spammy. Move | ||
// this to the begin frame call so that embedders get just one warning per | ||
// frame. | ||
FML_LOG(ERROR) << "Embedder supplied surface transformation does not map a " |
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.
if we apply the suggestion above this can be an assertion
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.
On second thought, I think this block is incorrect. We can still return the bounding box of the transform box even when rect-ness is not maintained. Embedders can still apply transformations on their own.
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.
Fixed.
FlutterLayer layer = {}; | ||
|
||
layer.struct_size = sizeof(layer); | ||
layer.type = kFlutterLayerContentTypePlatformView; | ||
layer.platform_view = &platform_view; | ||
|
||
layer.offset.x = params.offsetPixels.x(); | ||
layer.offset.y = params.offsetPixels.y(); | ||
const auto layer_bounds = SkRect::MakeXYWH(params.offsetPixels.x(), // |
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.
nit: remove empty comment lines
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.
I am actually using those to format the args in a column :/
@@ -15,6 +15,7 @@ | |||
#include "flutter/shell/platform/embedder/embedder.h" | |||
#include "flutter/shell/platform/embedder/tests/embedder_config_builder.h" | |||
#include "flutter/testing/testing.h" | |||
#include "third_party/skia/include/core/SkMatrix.h" |
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.
why is this needed here?
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.
Not necessary. Removed.
c015c41
to
a03db9d
Compare
More unit-tests have been added because @dnicoara was mentioning that root surface transformations may not be consistent between the compositor and non-compositor use cases. They were consistent but now we have unit-tests to verify this. |
6a18798
to
082abef
Compare
c4af6c7
to
59819e0
Compare
This is good to go. The coordinate space for all OpenGL backing stores is bottom left origin while that for Flutter uses top-left origin. This is consistent with the previous behavior of treating the root OpenGL surface as having a bottom left origin. |
Thanks, it did work as expected for the 270 degree clockwise rotation. Would it be possible to add tests for other rotations (90, 180)? For example, when I used a 90 degree rotation I didn't get the content upside-down, it was still right side-up (though it's possible I messed up and forgot to update something). |
59819e0
to
2575be4
Compare
…e external view embedder. The earlier design speculated that embedders could affect the same transformations on the layers post engine compositor presentation but before final composition. However, the linked issue points out that this design is not suitable for use with hardware overlay planes. When rendering to the same, to affect the transformation before composition, embedders would have to render to an off-screen render target and then apply the transformation before presentation. This patch negates the need for that off-screen render pass. To be clear, the previous architecture is still fully viable. Embedders still have full control over layer transformations before composition. This is an optimization for the hardware overlay planes use-case. Fixes b/139758641
2575be4
to
1afb79f
Compare
Fixes flutter/flutter#39339 |
…ed by the external view embedder. (flutter/engine#11384)
git@github.com:flutter/engine.git/compare/d1692d4cc703...6a96417 git log d1692d4..6a96417 --no-merges --oneline 2019-09-17 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/linux-amd64 from RRgw-... to F-g18... (flutter/engine#12326) 2019-09-17 chinmaygarde@google.com Account for root surface transformation on the surfaces managed by the external view embedder. (flutter/engine#11384) 2019-09-17 matthew-carroll@users.noreply.github.com Introduce FlutterFragmentActivity (flutter/engine#12305) 2019-09-17 chinmaygarde@google.com Shuffle test order and repeat test runs once. (flutter/engine#12275) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
git@github.com:flutter/engine.git/compare/d1692d4cc703...6a96417 git log d1692d4..6a96417 --no-merges --oneline 2019-09-17 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/linux-amd64 from RRgw-... to F-g18... (flutter/engine#12326) 2019-09-17 chinmaygarde@google.com Account for root surface transformation on the surfaces managed by the external view embedder. (flutter/engine#11384) 2019-09-17 matthew-carroll@users.noreply.github.com Introduce FlutterFragmentActivity (flutter/engine#12305) 2019-09-17 chinmaygarde@google.com Shuffle test order and repeat test runs once. (flutter/engine#12275) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
The earlier design speculated that embedders could affect the same
transformations on the layers post engine compositor presentation but before
final composition.
However, the linked issue points out that this design is not suitable for use
with hardware overlay planes. When rendering to the same, to affect the
transformation before composition, embedders would have to render to an
off-screen render target and then apply the transformation before presentation.
This patch negates the need for that off-screen render pass.
To be clear, the previous architecture is still fully viable. Embedders still
have full control over layer transformations before composition. This is an
optimization for the hardware overlay planes use-case.
Fixes b/139758641