Commit 001b1982 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[vr] Take target transform to calculate content resolution

The translation of the content group (parent of the content quad) is
animated when entering fullscreen. As a result, the calculated content
texture resolution differs depending on the animation's timing. Take the
the target transform of the animation instead in order to get a
deterministic content texture resolution.

Change-Id: Ieef5165c41d02ab2fa87f6736ebf91a10aa3f166
Reviewed-on: https://chromium-review.googlesource.com/667925
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502125}
parent b5edb4f2
...@@ -383,6 +383,19 @@ bool AnimationPlayer::IsAnimatingProperty(int property) const { ...@@ -383,6 +383,19 @@ bool AnimationPlayer::IsAnimatingProperty(int property) const {
return false; return false;
} }
cc::TransformOperations AnimationPlayer::GetTargetTransformOperationsValue(
int target_property) const {
cc::Animation* running_animation = nullptr;
for (auto& animation : animations_) {
if (animation->target_property_id() == target_property) {
running_animation = animation.get();
}
}
DCHECK(running_animation);
const auto* curve = running_animation->curve()->ToTransformAnimationCurve();
return curve->GetValue(GetEndTime(running_animation));
}
gfx::SizeF AnimationPlayer::GetTargetSizeValue(int target_property) const { gfx::SizeF AnimationPlayer::GetTargetSizeValue(int target_property) const {
cc::Animation* running_animation = nullptr; cc::Animation* running_animation = nullptr;
for (auto& animation : animations_) { for (auto& animation : animations_) {
......
...@@ -85,6 +85,8 @@ class AnimationPlayer final { ...@@ -85,6 +85,8 @@ class AnimationPlayer final {
bool IsAnimatingProperty(int property) const; bool IsAnimatingProperty(int property) const;
// TODO(754822): Implement target getters for other value types. // TODO(754822): Implement target getters for other value types.
cc::TransformOperations GetTargetTransformOperationsValue(
int target_property) const;
gfx::SizeF GetTargetSizeValue(int target_property) const; gfx::SizeF GetTargetSizeValue(int target_property) const;
private: private:
......
...@@ -177,7 +177,8 @@ static constexpr float kContentAspectRatioPropagationThreshold = 0.01f; ...@@ -177,7 +177,8 @@ static constexpr float kContentAspectRatioPropagationThreshold = 0.01f;
// kFloor // kFloor
// kCeiling // kCeiling
// k2dBrowsingForeground // k2dBrowsingForeground
// kContentQuad // k2dBrowsingContentGroup
// kContentQuad
// kBackplane // kBackplane
// kIndicatorLayout // kIndicatorLayout
// kAudioCaptureIndicator // kAudioCaptureIndicator
...@@ -714,8 +715,27 @@ void UiSceneManager::OnProjMatrixChanged(const gfx::Transform& proj_matrix) { ...@@ -714,8 +715,27 @@ void UiSceneManager::OnProjMatrixChanged(const gfx::Transform& proj_matrix) {
main_content_size = main_content_->size(); main_content_size = main_content_->size();
} }
// We take the target transform in case the content quad's parent's translate
// is animated. This approach only works with the current scene hierarchy and
// set of animated properties.
// TODO(tiborg): Find a way to get the target value of the inheritable
// transfrom that works with any scene hierarchy and set of animated
// properties.
gfx::Transform main_content_inheritable_transform;
if (scene_->GetUiElementByName(k2dBrowsingContentGroup)
->animation_player()
.IsAnimatingProperty(TargetProperty::TRANSFORM)) {
main_content_inheritable_transform =
scene_->GetUiElementByName(k2dBrowsingContentGroup)
->animation_player()
.GetTargetTransformOperationsValue(TargetProperty::TRANSFORM)
.Apply();
} else {
main_content_inheritable_transform = main_content_->inheritable_transform();
}
gfx::SizeF screen_size = CalculateScreenSize( gfx::SizeF screen_size = CalculateScreenSize(
proj_matrix, main_content_->inheritable_transform(), main_content_size); proj_matrix, main_content_inheritable_transform, main_content_size);
float aspect_ratio = main_content_size.width() / main_content_size.height(); float aspect_ratio = main_content_size.width() / main_content_size.height();
gfx::SizeF screen_bounds; gfx::SizeF screen_bounds;
......
...@@ -588,7 +588,7 @@ TEST_F(UiSceneManagerTest, PropagateContentBoundsOnFullscreen) { ...@@ -588,7 +588,7 @@ TEST_F(UiSceneManagerTest, PropagateContentBoundsOnFullscreen) {
manager_->SetFullscreen(true); manager_->SetFullscreen(true);
AnimateBy(MsToDelta(0)); AnimateBy(MsToDelta(0));
gfx::SizeF expected_bounds(0.705449f, 0.396737f); gfx::SizeF expected_bounds(0.587874f, 0.330614f);
EXPECT_CALL(*browser_, EXPECT_CALL(*browser_,
OnContentScreenBoundsChanged( OnContentScreenBoundsChanged(
SizeFsAreApproximatelyEqual(expected_bounds, kTolerance))); SizeFsAreApproximatelyEqual(expected_bounds, kTolerance)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment