forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove size_x and size_z from VRStageParameters
The notion of a simple "size" for Stage Parameters/bounded was a WebVr concept that did not carry over to WebXr. To simplify the mojom, move the "conversion" of square stages (for those runtimes that only support giving size x/z) down into a utility function in the device process. Bug: 1017843 Change-Id: Ib050a7ea3655a3816f6008e82434435ecb2c4426 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918037 Commit-Queue: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Klaus Weidner <klausw@chromium.org> Cr-Commit-Position: refs/heads/master@{#718364}
- Loading branch information
1 parent
eda0417
commit 93f1c75
Showing
17 changed files
with
150 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "device/vr/util/stage_utils.h" | ||
|
||
#include "base/logging.h" | ||
#include "ui/gfx/geometry/point3_f.h" | ||
|
||
namespace device { | ||
namespace vr_utils { | ||
|
||
std::vector<gfx::Point3F> GetStageBoundsFromSize(float size_x, float size_z) { | ||
if (size_x <= 0.0 || size_z <= 0.0) | ||
return {}; | ||
|
||
double hx = size_x * 0.5; | ||
double hz = size_z * 0.5; | ||
|
||
std::vector<gfx::Point3F> bounds = { | ||
gfx::Point3F(hx, 0.0, -hz), gfx::Point3F(hx, 0.0, hz), | ||
gfx::Point3F(-hx, 0.0, hz), gfx::Point3F(-hx, 0.0, -hz)}; | ||
|
||
return bounds; | ||
} | ||
|
||
} // namespace vr_utils | ||
} // namespace device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef DEVICE_VR_UTIL_STAGE_UTILS_H_ | ||
#define DEVICE_VR_UTIL_STAGE_UTILS_H_ | ||
|
||
#include <vector> | ||
|
||
#include "device/vr/vr_export.h" | ||
|
||
namespace gfx { | ||
class Point3F; | ||
} // namespace gfx | ||
|
||
namespace device { | ||
namespace vr_utils { | ||
|
||
// convenience method for runtimes that only support rectangular play areas to | ||
// convert to an array of bounds (which the mojom/WebXr API expects). Returns | ||
// a vector of points representing the four corners of a rectangle centered at | ||
// 0,0 with length and width determined by size_x and size_z respectively. | ||
std::vector<gfx::Point3F> DEVICE_VR_EXPORT GetStageBoundsFromSize(float size_x, | ||
float size_z); | ||
|
||
} // namespace vr_utils | ||
} // namespace device | ||
|
||
#endif // DEVICE_VR_UTIL_STAGE_UTILS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "device/vr/util/stage_utils.h" | ||
|
||
#include "ui/gfx/geometry/point3_f.h" | ||
#include "ui/gfx/geometry/vector3d_f.h" | ||
#include "ui/gfx/transform.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace { | ||
constexpr size_t kExpectedBoundsSize = 4; | ||
} | ||
|
||
namespace device { | ||
|
||
TEST(StageUtils, Basic) { | ||
auto bounds = vr_utils::GetStageBoundsFromSize(2.0, 2.0); | ||
|
||
// The Expected bounds (without transform) are: | ||
// (1, 0, -1) | ||
// (1, 0, 1) | ||
// (-1, 0, 1) | ||
// (-1, 0, -1) | ||
// This represents a box 2x2 box, centered around 0. | ||
// Note that the choice of which point starts is (unfortunately) an | ||
// implementation detail. The order however, should always be | ||
// counter-clockwise. | ||
std::vector<gfx::Point3F> expected_bounds = { | ||
gfx::Point3F(1, 0, -1), gfx::Point3F(1, 0, 1), gfx::Point3F(-1, 0, 1), | ||
gfx::Point3F(-1, 0, -1)}; | ||
|
||
ASSERT_EQ(bounds.size(), kExpectedBoundsSize); | ||
for (size_t i = 0; i < kExpectedBoundsSize; i++) { | ||
EXPECT_FLOAT_EQ(bounds[i].x(), expected_bounds[i].x()); | ||
EXPECT_FLOAT_EQ(bounds[i].y(), expected_bounds[i].y()); | ||
EXPECT_FLOAT_EQ(bounds[i].z(), expected_bounds[i].z()); | ||
} | ||
} | ||
|
||
TEST(StageUtils, InvalidBounds) { | ||
// clang-format off | ||
std::vector<std::pair<float, float>> test_data{ | ||
{ 0.0, 0.0 }, | ||
{ 0.0, 1.0 }, | ||
{ 1.0, 0.0 }, | ||
{ 1.0, -1.0 }, | ||
{ -1.0, 1.0 }, | ||
{-1.0, -1.0 } | ||
}; | ||
// clang-format on | ||
|
||
// This avoids any compiler issues with 0 not being deduced to the right type. | ||
constexpr size_t kEmptyBoundsSize = 0; | ||
for (const auto& data : test_data) { | ||
auto bounds = vr_utils::GetStageBoundsFromSize(data.first, data.second); | ||
ASSERT_EQ(bounds.size(), kEmptyBoundsSize); | ||
} | ||
} | ||
|
||
} // namespace device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.