Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_QUADS_DRAW_POLYGON_H_ | |
| 6 #define CC_QUADS_DRAW_POLYGON_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "cc/base/math_util.h" | |
| 11 #include "cc/output/bsp_compare_result.h" | |
| 12 #include "cc/quads/draw_quad.h" | |
| 13 #include "ui/gfx/point3_f.h" | |
| 14 #include "ui/gfx/quad_f.h" | |
| 15 #include "ui/gfx/vector3d_f.h" | |
| 16 | |
| 17 namespace cc { | |
| 18 | |
| 19 class DrawPolygon { | |
| 20 public: | |
| 21 DrawPolygon(); | |
| 22 ~DrawPolygon(); | |
| 23 | |
| 24 DrawPolygon(DrawQuad* original_ref, | |
| 25 const std::vector<gfx::Point3F>& in_points, | |
| 26 int draw_order_index = 0); | |
| 27 | |
| 28 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.
| |
| 29 scoped_ptr<DrawPolygon>* front, | |
| 30 scoped_ptr<DrawPolygon>* back); | |
| 31 float SignedPointDistance(const gfx::Point3F& point) const; | |
| 32 void ApplyTransform(const gfx::Transform& transform); | |
| 33 void ApplyTransformToNormal(const gfx::Transform& transform); | |
| 34 // Checks polygon a against polygon b and returns which side it lies on, or | |
| 35 // whether it crosses (necessitating a split in the BSP tree). | |
| 36 static BspCompareResult SideCompare(const DrawPolygon& a, | |
| 37 const DrawPolygon& b); | |
| 38 void ToQuads2D(std::vector<gfx::QuadF>* quads) const; | |
| 39 bool GetInverseTransform(gfx::Transform* transform) const; | |
| 40 void SetNormal(const gfx::Vector3dF& normal); | |
| 41 | |
| 42 const std::vector<gfx::Point3F>& points() const { return points_; } | |
| 43 const gfx::Vector3dF& normal() const { return normal_; } | |
| 44 const DrawQuad* original_ref() const { return original_ref_; } | |
| 45 const int order_index() const { return order_index_; } | |
| 46 | |
| 47 scoped_ptr<DrawPolygon> CreateCopy(); | |
| 48 | |
| 49 private: | |
| 50 std::vector<gfx::Point3F> points_; | |
| 51 // Normalized, necessitated by distance calculations and tests of coplanarity. | |
| 52 gfx::Vector3dF normal_; | |
| 53 // This is an index that can be used to test whether a quad comes before or | |
| 54 // after another in document order, useful for tie-breaking when it comes | |
| 55 // to coplanar surfaces. | |
| 56 int order_index_; | |
| 57 // The pointer to the original quad, which gives us all the drawing info | |
| 58 // we need. | |
| 59 // This DrawQuad is owned by the caller and its lifetime must be preserved | |
| 60 // as long as this DrawPolygon is alive. | |
| 61 DrawQuad* original_ref_; | |
| 62 }; | |
| 63 | |
| 64 } // namespace cc | |
| 65 | |
| 66 #endif // CC_QUADS_DRAW_POLYGON_H_ | |
| OLD | NEW |