Commit 61b5a492 authored by petermayo's avatar petermayo Committed by Commit bot

Tighten bounds on 3d clipping.

We can only generate 6 points for even non-convex quads.
It falls from the w component crossing 0 implies we have to remove
at least one corner for each 2 we add. We can only do that twice.
4 -> 3+2 -> 2+4 -> 1+2.

BUG=None
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2627213002
Cr-Commit-Position: refs/heads/master@{#443350}
parent 5a7ffae7
......@@ -178,7 +178,7 @@ static inline bool IsNearlyTheSame(const gfx::Point3F& lhs,
}
static inline void AddVertexToClippedQuad3d(const gfx::Point3F& new_vertex,
gfx::Point3F clipped_quad[8],
gfx::Point3F clipped_quad[6],
int* num_vertices_in_clipped_quad) {
if (*num_vertices_in_clipped_quad > 0 &&
IsNearlyTheSame(clipped_quad[*num_vertices_in_clipped_quad - 1],
......@@ -309,7 +309,7 @@ gfx::Rect MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
const gfx::QuadF& src_quad,
gfx::Point3F clipped_quad[8],
gfx::Point3F clipped_quad[6],
int* num_vertices_in_clipped_quad) {
HomogeneousCoordinate h1 =
MapHomogeneousPoint(transform, gfx::Point3F(src_quad.p1()));
......@@ -370,7 +370,7 @@ bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
clipped_quad[*num_vertices_in_clipped_quad - 1]))
*num_vertices_in_clipped_quad -= 1;
DCHECK_LE(*num_vertices_in_clipped_quad, 8);
DCHECK_LE(*num_vertices_in_clipped_quad, 6);
return (*num_vertices_in_clipped_quad >= 4);
}
......
......@@ -189,7 +189,7 @@ class CC_EXPORT MathUtil {
// array are valid.
static bool MapClippedQuad3d(const gfx::Transform& transform,
const gfx::QuadF& src_quad,
gfx::Point3F clipped_quad[8],
gfx::Point3F clipped_quad[6],
int* num_vertices_in_clipped_quad);
static gfx::RectF ComputeEnclosingRectOfVertices(const gfx::PointF vertices[],
......
......@@ -62,7 +62,7 @@ DrawPolygon::DrawPolygon(const DrawQuad* original_ref,
order_index_(draw_order_index),
original_ref_(original_ref),
is_split_(false) {
gfx::Point3F points[8];
gfx::Point3F points[6];
int num_vertices_in_clipped_quad;
gfx::QuadF send_quad(visible_layer_rect);
......
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