Commit 4ada619d authored by Yilong Li's avatar Yilong Li Committed by Commit Bot

[fuchsia] Replace C-style array with std::array on Scenic commands.

Scenic functions with C-style array arguments will be removed from SDK
in favor of std::arrays. This change replaces all the C-style arrays used
in Scenic SDK functions with std::array.

Change in Fuchsia-review: https://fuchsia-review.googlesource.com/c/fuchsia/+/351051

TEST=Build on Fuchsia target; run_base_unittests

Bug: fxb/SCN-1442
Change-Id: I2f828e7217258a71267295f4b26b735d29a9b103
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986979
Commit-Queue: Yilong Li <liyl@google.com>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728628}
parent 196aadc3
...@@ -91,10 +91,10 @@ std::vector<uint32_t> ConvertChildIds(std::vector<int32_t> ids) { ...@@ -91,10 +91,10 @@ std::vector<uint32_t> ConvertChildIds(std::vector<int32_t> ids) {
fuchsia::ui::gfx::BoundingBox ConvertBoundingBox(gfx::RectF bounds) { fuchsia::ui::gfx::BoundingBox ConvertBoundingBox(gfx::RectF bounds) {
fuchsia::ui::gfx::BoundingBox box; fuchsia::ui::gfx::BoundingBox box;
float min[3] = {bounds.bottom_left().x(), bounds.bottom_left().y(), 0.0f}; box.min = scenic::NewVector3({bounds.bottom_left().x(),
float max[3] = {bounds.top_right().x(), bounds.top_right().y(), 0.0f}; bounds.bottom_left().y(), 0.0f});
box.min = scenic::NewVector3(min); box.max = scenic::NewVector3({bounds.top_right().x(), bounds.top_right().y(),
box.max = scenic::NewVector3(max); 0.0f});
return box; return box;
} }
...@@ -102,8 +102,8 @@ fuchsia::ui::gfx::BoundingBox ConvertBoundingBox(gfx::RectF bounds) { ...@@ -102,8 +102,8 @@ fuchsia::ui::gfx::BoundingBox ConvertBoundingBox(gfx::RectF bounds) {
// subtree as an optimization to handle resizing or repositioning. This requires // subtree as an optimization to handle resizing or repositioning. This requires
// only one node to be updated on such an event. // only one node to be updated on such an event.
fuchsia::ui::gfx::mat4 ConvertTransform(gfx::Transform* transform) { fuchsia::ui::gfx::mat4 ConvertTransform(gfx::Transform* transform) {
float mat[16] = {}; std::array<float, 16> mat = {};
transform->matrix().asColMajorf(mat); transform->matrix().asColMajorf(mat.data());
fuchsia::ui::gfx::Matrix4Value fuchsia_transform = fuchsia::ui::gfx::Matrix4Value fuchsia_transform =
scenic::NewMatrix4Value(mat); scenic::NewMatrix4Value(mat);
return fuchsia_transform.value; return fuchsia_transform.value;
......
...@@ -26,8 +26,8 @@ const int32_t kRectX = 1; ...@@ -26,8 +26,8 @@ const int32_t kRectX = 1;
const int32_t kRectY = 2; const int32_t kRectY = 2;
const int32_t kRectWidth = 7; const int32_t kRectWidth = 7;
const int32_t kRectHeight = 8; const int32_t kRectHeight = 8;
const float k4DIdentityMatrix[16] = {1, 0, 0, 0, 0, 1, 0, 0, const std::array<float, 16> k4DIdentityMatrix = {1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1}; 0, 0, 1, 0, 0, 0, 0, 1};
bool SemanticNodesAreEqual(const Node& first, const Node& second) { bool SemanticNodesAreEqual(const Node& first, const Node& second) {
if (first.node_id() != second.node_id()) if (first.node_id() != second.node_id())
...@@ -128,10 +128,8 @@ TEST_F(AXTreeConverterTest, AllFieldsSetAndEqual) { ...@@ -128,10 +128,8 @@ TEST_F(AXTreeConverterTest, AllFieldsSetAndEqual) {
Attributes attributes; Attributes attributes;
attributes.set_label(kLabel1); attributes.set_label(kLabel1);
fuchsia::ui::gfx::BoundingBox box; fuchsia::ui::gfx::BoundingBox box;
float min[3] = {kRectX, kRectY + kRectHeight, 0.0f}; box.min = scenic::NewVector3({kRectX, kRectY + kRectHeight, 0.0f});
float max[3] = {kRectHeight, kRectY, 0.0f}; box.max = scenic::NewVector3({kRectHeight, kRectY, 0.0f});
box.min = scenic::NewVector3(min);
box.max = scenic::NewVector3(max);
fuchsia::ui::gfx::Matrix4Value mat = fuchsia::ui::gfx::Matrix4Value mat =
scenic::NewMatrix4Value(k4DIdentityMatrix); scenic::NewMatrix4Value(k4DIdentityMatrix);
auto expected_node = CreateSemanticNode( auto expected_node = CreateSemanticNode(
...@@ -179,8 +177,8 @@ TEST_F(AXTreeConverterTest, FieldMismatch) { ...@@ -179,8 +177,8 @@ TEST_F(AXTreeConverterTest, FieldMismatch) {
Attributes attributes; Attributes attributes;
attributes.set_label(kLabel1); attributes.set_label(kLabel1);
fuchsia::ui::gfx::BoundingBox box; fuchsia::ui::gfx::BoundingBox box;
float min[3] = {kRectX, kRectY + kRectHeight, 0.0f}; std::array<float, 3> min = {kRectX, kRectY + kRectHeight, 0.0f};
float max[3] = {kRectHeight, kRectY, 0.0f}; std::array<float, 3> max = {kRectHeight, kRectY, 0.0f};
box.min = scenic::NewVector3(min); box.min = scenic::NewVector3(min);
box.max = scenic::NewVector3(max); box.max = scenic::NewVector3(max);
fuchsia::ui::gfx::Matrix4Value mat = fuchsia::ui::gfx::Matrix4Value mat =
......
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