OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_QUADS_DRAW_POLYGON_H_ | 5 #ifndef CC_QUADS_DRAW_POLYGON_H_ |
6 #define CC_QUADS_DRAW_POLYGON_H_ | 6 #define CC_QUADS_DRAW_POLYGON_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 void TransformToScreenSpace(const gfx::Transform& transform); | 49 void TransformToScreenSpace(const gfx::Transform& transform); |
50 void TransformToLayerSpace(const gfx::Transform& inverse_transform); | 50 void TransformToLayerSpace(const gfx::Transform& inverse_transform); |
51 | 51 |
52 const std::vector<gfx::Point3F>& points() const { return points_; } | 52 const std::vector<gfx::Point3F>& points() const { return points_; } |
53 const gfx::Vector3dF& normal() const { return normal_; } | 53 const gfx::Vector3dF& normal() const { return normal_; } |
54 const DrawQuad* original_ref() const { return original_ref_; } | 54 const DrawQuad* original_ref() const { return original_ref_; } |
55 int order_index() const { return order_index_; } | 55 int order_index() const { return order_index_; } |
56 bool is_split() const { return is_split_; } | 56 bool is_split() const { return is_split_; } |
57 std::unique_ptr<DrawPolygon> CreateCopy(); | 57 std::unique_ptr<DrawPolygon> CreateCopy(); |
58 | 58 |
| 59 // These are helper functions for testing. |
59 void RecomputeNormalForTesting(); | 60 void RecomputeNormalForTesting(); |
| 61 friend bool IsPlanarForTesting(const DrawPolygon& p); |
| 62 friend bool IsConvexForTesting(const DrawPolygon& p); |
60 | 63 |
61 private: | 64 private: |
62 void ApplyTransform(const gfx::Transform& transform); | 65 void ApplyTransform(const gfx::Transform& transform); |
63 void ApplyTransformToNormal(const gfx::Transform& transform); | 66 void ApplyTransformToNormal(const gfx::Transform& transform); |
64 | 67 |
65 void ConstructNormal(); | 68 void ConstructNormal(); |
66 | 69 |
67 std::vector<gfx::Point3F> points_; | 70 std::vector<gfx::Point3F> points_; |
68 // Normalized, necessitated by distance calculations and tests of coplanarity. | 71 // Normalized, necessitated by distance calculations and tests of coplanarity. |
69 gfx::Vector3dF normal_; | 72 gfx::Vector3dF normal_; |
70 // This is an index that can be used to test whether a quad comes before or | 73 // This is an index that can be used to test whether a quad comes before or |
71 // after another in document order, useful for tie-breaking when it comes | 74 // after another in document order, useful for tie-breaking when it comes |
72 // to coplanar surfaces. | 75 // to coplanar surfaces. |
73 int order_index_; | 76 int order_index_; |
74 // The pointer to the original quad, which gives us all the drawing info | 77 // The pointer to the original quad, which gives us all the drawing info |
75 // we need. | 78 // we need. |
76 // This DrawQuad is owned by the caller and its lifetime must be preserved | 79 // This DrawQuad is owned by the caller and its lifetime must be preserved |
77 // as long as this DrawPolygon is alive. | 80 // as long as this DrawPolygon is alive. |
78 const DrawQuad* original_ref_; | 81 const DrawQuad* original_ref_; |
79 bool is_split_; | 82 bool is_split_; |
80 }; | 83 }; |
81 | 84 |
82 } // namespace cc | 85 } // namespace cc |
83 | 86 |
84 #endif // CC_QUADS_DRAW_POLYGON_H_ | 87 #endif // CC_QUADS_DRAW_POLYGON_H_ |
OLD | NEW |