Pass size_t to span functions: cc/
In preparation for upgrading various span args from size_t to StrictNumeric<size_t>, this fixes type mismatches that would cause compile errors with that change. Bug: none Change-Id: Ie4a9f087ac86b56d5aa1100b8d429a6328adf1f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6020620 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Commit-Queue: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/main@{#1382654}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
0a2dc5f36a
commit
4eb1325b02
@ -247,14 +247,18 @@ static inline void AddVertexToClippedQuad3d(
|
||||
base::span<gfx::Point3F, 6> clipped_quad,
|
||||
int* num_vertices_in_clipped_quad,
|
||||
bool* need_to_clamp) {
|
||||
CHECK(num_vertices_in_clipped_quad);
|
||||
CHECK_GE(*num_vertices_in_clipped_quad, 0);
|
||||
if (*num_vertices_in_clipped_quad > 0 &&
|
||||
IsNearlyTheSame(clipped_quad[*num_vertices_in_clipped_quad - 1],
|
||||
new_vertex))
|
||||
IsNearlyTheSame(
|
||||
clipped_quad[static_cast<size_t>(*num_vertices_in_clipped_quad - 1)],
|
||||
new_vertex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK_LT(*num_vertices_in_clipped_quad, 6);
|
||||
clipped_quad[*num_vertices_in_clipped_quad] = new_vertex;
|
||||
(*num_vertices_in_clipped_quad)++;
|
||||
CHECK_LT(*num_vertices_in_clipped_quad, 6);
|
||||
clipped_quad[static_cast<size_t>(*num_vertices_in_clipped_quad)] = new_vertex;
|
||||
++*num_vertices_in_clipped_quad;
|
||||
if (new_vertex.x() < -HomogeneousCoordinate::kInfiniteCoordinate ||
|
||||
new_vertex.x() > HomogeneousCoordinate::kInfiniteCoordinate ||
|
||||
new_vertex.y() < -HomogeneousCoordinate::kInfiniteCoordinate ||
|
||||
@ -436,8 +440,10 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
|
||||
|
||||
if (*num_vertices_in_clipped_quad > 2 &&
|
||||
IsNearlyTheSame(clipped_quad[0],
|
||||
clipped_quad[*num_vertices_in_clipped_quad - 1]))
|
||||
*num_vertices_in_clipped_quad -= 1;
|
||||
clipped_quad[static_cast<size_t>(
|
||||
*num_vertices_in_clipped_quad - 1)])) {
|
||||
--*num_vertices_in_clipped_quad;
|
||||
}
|
||||
|
||||
if (need_to_clamp) {
|
||||
// Some of the values need to be clamped, but we need to keep them
|
||||
@ -448,9 +454,11 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
|
||||
gfx::Vector3dF normal(0.0f, 0.0f, 0.0f);
|
||||
if (*num_vertices_in_clipped_quad > 2) {
|
||||
gfx::Vector3dF loop_vector =
|
||||
clipped_quad[0] - clipped_quad[*num_vertices_in_clipped_quad - 1];
|
||||
clipped_quad[0] -
|
||||
clipped_quad[static_cast<size_t>(*num_vertices_in_clipped_quad - 1)];
|
||||
gfx::Vector3dF prev_vector(loop_vector);
|
||||
for (int i = 1; i < *num_vertices_in_clipped_quad; ++i) {
|
||||
for (size_t i = 1; i < static_cast<size_t>(*num_vertices_in_clipped_quad);
|
||||
++i) {
|
||||
gfx::Vector3dF cur_vector = clipped_quad[i] - clipped_quad[i - 1];
|
||||
normal += CrossProduct(prev_vector, cur_vector);
|
||||
prev_vector = cur_vector;
|
||||
@ -507,7 +515,8 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
|
||||
} else {
|
||||
z_delta = -max_distance - z_at_xy_zero;
|
||||
}
|
||||
for (int i = 0; i < *num_vertices_in_clipped_quad; ++i) {
|
||||
for (size_t i = 0;
|
||||
i < static_cast<size_t>(*num_vertices_in_clipped_quad); ++i) {
|
||||
clipped_quad[i].set_z(clipped_quad[i].z() + z_delta);
|
||||
}
|
||||
z_at_xy_zero += z_delta;
|
||||
@ -515,7 +524,8 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
|
||||
|
||||
// Move all the points towards (0, 0, z_at_xy_zero) until all
|
||||
// their coordinates are less than kInfiniteCoordinate.
|
||||
for (int i = 0; i < *num_vertices_in_clipped_quad; ++i) {
|
||||
for (size_t i = 0;
|
||||
i < static_cast<size_t>(*num_vertices_in_clipped_quad); ++i) {
|
||||
gfx::Point3F& point = clipped_quad[i];
|
||||
float t = 1.0f;
|
||||
|
||||
@ -565,7 +575,8 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
|
||||
if (clamp_by_points) {
|
||||
// Just clamp each point separately in each axis, just like we do
|
||||
// for 2D.
|
||||
for (int i = 0; i < *num_vertices_in_clipped_quad; ++i) {
|
||||
for (size_t i = 0; i < static_cast<size_t>(*num_vertices_in_clipped_quad);
|
||||
++i) {
|
||||
gfx::Point3F& point = clipped_quad[i];
|
||||
point.set_x(
|
||||
std::clamp(point.x(), -HomogeneousCoordinate::kInfiniteCoordinate,
|
||||
@ -581,7 +592,7 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
|
||||
}
|
||||
|
||||
DCHECK_LE(*num_vertices_in_clipped_quad, 6);
|
||||
return (*num_vertices_in_clipped_quad >= 4);
|
||||
return *num_vertices_in_clipped_quad >= 4;
|
||||
}
|
||||
|
||||
gfx::RectF MathUtil::ComputeEnclosingRectOfVertices(
|
||||
|
Reference in New Issue
Block a user