| 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_OUTPUT_BSP_TREE_H_ | 5 #ifndef CC_OUTPUT_BSP_TREE_H_ |
| 6 #define CC_OUTPUT_BSP_TREE_H_ | 6 #define CC_OUTPUT_BSP_TREE_H_ |
| 7 | 7 |
| 8 #include <deque> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/base/scoped_ptr_deque.h" | |
| 12 #include "cc/base/scoped_ptr_vector.h" | 12 #include "cc/base/scoped_ptr_vector.h" |
| 13 #include "cc/output/bsp_compare_result.h" | 13 #include "cc/output/bsp_compare_result.h" |
| 14 #include "cc/quads/draw_polygon.h" | 14 #include "cc/quads/draw_polygon.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 struct BspNode { | 18 struct BspNode { |
| 19 // This represents the splitting plane. | 19 // This represents the splitting plane. |
| 20 scoped_ptr<DrawPolygon> node_data; | 20 scoped_ptr<DrawPolygon> node_data; |
| 21 // This represents any coplanar geometry we found while building the BSP. | 21 // This represents any coplanar geometry we found while building the BSP. |
| 22 ScopedPtrVector<DrawPolygon> coplanars_front; | 22 ScopedPtrVector<DrawPolygon> coplanars_front; |
| 23 ScopedPtrVector<DrawPolygon> coplanars_back; | 23 ScopedPtrVector<DrawPolygon> coplanars_back; |
| 24 | 24 |
| 25 scoped_ptr<BspNode> back_child; | 25 scoped_ptr<BspNode> back_child; |
| 26 scoped_ptr<BspNode> front_child; | 26 scoped_ptr<BspNode> front_child; |
| 27 | 27 |
| 28 explicit BspNode(scoped_ptr<DrawPolygon> data); | 28 explicit BspNode(scoped_ptr<DrawPolygon> data); |
| 29 ~BspNode(); | 29 ~BspNode(); |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class CC_EXPORT BspTree { | 32 class CC_EXPORT BspTree { |
| 33 public: | 33 public: |
| 34 explicit BspTree(ScopedPtrDeque<DrawPolygon>* list); | 34 explicit BspTree(std::deque<scoped_ptr<DrawPolygon>>* list); |
| 35 scoped_ptr<BspNode>& root() { return root_; } | 35 scoped_ptr<BspNode>& root() { return root_; } |
| 36 | 36 |
| 37 template <typename ActionHandlerType> | 37 template <typename ActionHandlerType> |
| 38 void TraverseWithActionHandler(ActionHandlerType* action_handler) const { | 38 void TraverseWithActionHandler(ActionHandlerType* action_handler) const { |
| 39 if (root_) { | 39 if (root_) { |
| 40 WalkInOrderRecursion<ActionHandlerType>(action_handler, root_.get()); | 40 WalkInOrderRecursion<ActionHandlerType>(action_handler, root_.get()); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 ~BspTree(); | 44 ~BspTree(); |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 scoped_ptr<BspNode> root_; | 47 scoped_ptr<BspNode> root_; |
| 48 | 48 |
| 49 void FromList(ScopedPtrVector<DrawPolygon>* list); | 49 void FromList(ScopedPtrVector<DrawPolygon>* list); |
| 50 void BuildTree(BspNode* node, ScopedPtrDeque<DrawPolygon>* data); | 50 void BuildTree(BspNode* node, std::deque<scoped_ptr<DrawPolygon>>* data); |
| 51 | 51 |
| 52 template <typename ActionHandlerType> | 52 template <typename ActionHandlerType> |
| 53 void WalkInOrderAction(ActionHandlerType* action_handler, | 53 void WalkInOrderAction(ActionHandlerType* action_handler, |
| 54 DrawPolygon* item) const { | 54 DrawPolygon* item) const { |
| 55 (*action_handler)(item); | 55 (*action_handler)(item); |
| 56 } | 56 } |
| 57 | 57 |
| 58 template <typename ActionHandlerType> | 58 template <typename ActionHandlerType> |
| 59 void WalkInOrderVisitNodes( | 59 void WalkInOrderVisitNodes( |
| 60 ActionHandlerType* action_handler, | 60 ActionHandlerType* action_handler, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 static BspCompareResult GetNodePositionRelative(const DrawPolygon& node_a, | 105 static BspCompareResult GetNodePositionRelative(const DrawPolygon& node_a, |
| 106 const DrawPolygon& node_b); | 106 const DrawPolygon& node_b); |
| 107 // Returns whether or not our viewer is in front of or behind the plane | 107 // Returns whether or not our viewer is in front of or behind the plane |
| 108 // defined by this polygon/node | 108 // defined by this polygon/node |
| 109 static BspCompareResult GetCameraPositionRelative(const DrawPolygon& node); | 109 static BspCompareResult GetCameraPositionRelative(const DrawPolygon& node); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace cc | 112 } // namespace cc |
| 113 | 113 |
| 114 #endif // CC_OUTPUT_BSP_TREE_H_ | 114 #endif // CC_OUTPUT_BSP_TREE_H_ |
| OLD | NEW |