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, |
| 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 |
| 34 // Normalized, necessitated by distance calculations and tests of coplanarity. |
| 35 gfx::Vector3dF normal; |
| 36 float area; |
| 37 // This is an index that can be used to test whether a quad comes before or |
| 38 // after another in document order, useful for tie-breaking when it comes |
| 39 // to coplanar surfaces. |
| 40 int order_index; |
| 41 |
| 42 std::vector<gfx::Point3F> points; |
| 43 |
| 44 // Checks polygon a against polygon b and returns which side it lies on, or |
| 45 // whether it crosses (necessitating a split in the BSP tree). |
| 46 static BspCompareResult SideCompare(const DrawPolygon& a, |
| 47 const DrawPolygon& b); |
| 48 void ToQuads2D(std::vector<gfx::QuadF>* quads) const; |
| 49 int NumPoints() { return points.size(); } |
| 50 bool GetInverseTransform(gfx::Transform* transform) const; |
| 51 unsigned int NumberOfPoints() { return points.size(); } |
| 52 const gfx::Point3F& point(unsigned int index) { return points[index]; } |
| 53 |
| 54 scoped_ptr<DrawPolygon> CreateCopy(); |
| 55 |
| 56 // The pointer to the original quad, which gives us all the drawing info |
| 57 // we need. |
| 58 // This DrawQuad is owned by the caller and its lifetime must be preserved |
| 59 // as long as this DrawPolygon is alive. |
| 60 DrawQuad* original_ref; |
| 61 |
| 62 // This threshold controls how "thick" a plane is. If a point's distance is |
| 63 // <= compare_threshold, then it is considered on the plane. Only when this |
| 64 // boundary is crossed do we consider doing splitting. |
| 65 static float compare_threshold; |
| 66 static float split_threshold; |
| 67 }; |
| 68 |
| 69 } // namespace cc |
| 70 |
| 71 #endif // CC_QUADS_DRAW_POLYGON_H_ |
OLD | NEW |