Chromium Code Reviews| Index: cc/quads/draw_polygon.h |
| diff --git a/cc/quads/draw_polygon.h b/cc/quads/draw_polygon.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..749cde9ad88af0bc8b5b7609ee3abe1ee7199a21 |
| --- /dev/null |
| +++ b/cc/quads/draw_polygon.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2014 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 CC_QUADS_DRAW_POLYGON_H_ |
| +#define CC_QUADS_DRAW_POLYGON_H_ |
| + |
| +#include <vector> |
| + |
| +#include "cc/base/math_util.h" |
| +#include "cc/output/bsp_compare_result.h" |
| +#include "cc/quads/draw_quad.h" |
| +#include "ui/gfx/point3_f.h" |
| +#include "ui/gfx/quad_f.h" |
| +#include "ui/gfx/vector3d_f.h" |
| + |
| +namespace cc { |
| + |
| +class DrawPolygon { |
| + public: |
| + DrawPolygon(); |
| + ~DrawPolygon(); |
| + |
| + DrawPolygon(DrawQuad* original_ref, |
| + const std::vector<gfx::Point3F>& in_points, |
| + int draw_order_index = 0); |
| + |
| + bool Split(const DrawPolygon& splitter, |
|
enne (OOO)
2014/07/28 20:46:40
Can you leave a comment about this function here a
troyhildebrandt
2014/07/28 23:48:44
Done.
|
| + scoped_ptr<DrawPolygon>* front, |
| + scoped_ptr<DrawPolygon>* back); |
| + float SignedPointDistance(const gfx::Point3F& point) const; |
| + void ApplyTransform(const gfx::Transform& transform); |
| + void ApplyTransformToNormal(const gfx::Transform& transform); |
| + // Checks polygon a against polygon b and returns which side it lies on, or |
| + // whether it crosses (necessitating a split in the BSP tree). |
| + static BspCompareResult SideCompare(const DrawPolygon& a, |
| + const DrawPolygon& b); |
| + void ToQuads2D(std::vector<gfx::QuadF>* quads) const; |
| + bool GetInverseTransform(gfx::Transform* transform) const; |
| + void SetNormal(const gfx::Vector3dF& normal); |
| + |
| + const std::vector<gfx::Point3F>& points() const { return points_; } |
| + const gfx::Vector3dF& normal() const { return normal_; } |
| + const DrawQuad* original_ref() const { return original_ref_; } |
| + const int order_index() const { return order_index_; } |
| + |
| + scoped_ptr<DrawPolygon> CreateCopy(); |
| + |
| + private: |
| + std::vector<gfx::Point3F> points_; |
| + // Normalized, necessitated by distance calculations and tests of coplanarity. |
| + gfx::Vector3dF normal_; |
| + // This is an index that can be used to test whether a quad comes before or |
| + // after another in document order, useful for tie-breaking when it comes |
| + // to coplanar surfaces. |
| + int order_index_; |
| + // The pointer to the original quad, which gives us all the drawing info |
| + // we need. |
| + // This DrawQuad is owned by the caller and its lifetime must be preserved |
| + // as long as this DrawPolygon is alive. |
| + DrawQuad* original_ref_; |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_QUADS_DRAW_POLYGON_H_ |