Commit c863ca7f authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

WebXR: Fix incorrect AR frame dimensions

This regressed in https://chromium-review.googlesource.com/c/1197225, the frame
property updates were happening in the wrong code location.

Revert to the original code ordering, and add comments explaining the order
dependency.

BUG=897525

Change-Id: If88575c15de7ca3b069771362d4388f1a95aca06
Reviewed-on: https://chromium-review.googlesource.com/c/1297473Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602163}
parent f5ac6454
...@@ -191,22 +191,8 @@ void ArCoreGl::ProduceFrame( ...@@ -191,22 +191,8 @@ void ArCoreGl::ProduceFrame(
DCHECK(IsOnGlThread()); DCHECK(IsOnGlThread());
DCHECK(is_initialized_); DCHECK(is_initialized_);
if (transfer_size_ != frame_size || display_rotation_ != display_rotation) { // Check if the frame_size and display_rotation updated last frame. If yes,
// Set display geometry before calling Update. It's a pending request that // apply the update for this frame.
// applies to the next frame.
arcore_->SetDisplayGeometry(frame_size, display_rotation);
// Store the passed in values to ensure that we can update them only if they
// change.
transfer_size_ = frame_size;
display_rotation_ = display_rotation;
// Tell the uvs to recalculate on the next animation frame, by which time
// SetDisplayGeometry will have set the new values in arcore_.
should_recalculate_uvs_ = true;
}
// Check if the frame_size and display_rotation updated last frame.
if (should_recalculate_uvs_) { if (should_recalculate_uvs_) {
// Get the UV transform matrix from ArCore's UV transform. // Get the UV transform matrix from ArCore's UV transform.
std::vector<float> uvs_transformed = std::vector<float> uvs_transformed =
...@@ -222,6 +208,24 @@ void ArCoreGl::ProduceFrame( ...@@ -222,6 +208,24 @@ void ArCoreGl::ProduceFrame(
should_recalculate_uvs_ = false; should_recalculate_uvs_ = false;
} }
// Now check if the frame_size or display_rotation neds to be updated
// for the next frame. This must happen after the should_recalculate_uvs_
// check above to ensure it executes with the needed one-frame delay.
if (transfer_size_ != frame_size || display_rotation_ != display_rotation) {
// Set display geometry before calling Update. It's a pending request that
// applies to the next frame.
arcore_->SetDisplayGeometry(frame_size, display_rotation);
// Store the passed in values to ensure that we can update them only if they
// change.
transfer_size_ = frame_size;
display_rotation_ = display_rotation;
// Tell the uvs to recalculate on the next animation frame, by which time
// SetDisplayGeometry will have set the new values in arcore_.
should_recalculate_uvs_ = true;
}
TRACE_EVENT_BEGIN0("gpu", "ArCore Update"); TRACE_EVENT_BEGIN0("gpu", "ArCore Update");
bool camera_updated = false; bool camera_updated = false;
mojom::VRPosePtr pose = arcore_->Update(&camera_updated); mojom::VRPosePtr pose = arcore_->Update(&camera_updated);
......
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