Bug 1351426 - Part 5: Cleanup style and comments r=kip

MozReview-Commit-ID: HOPY8v4UWKo
This commit is contained in:
Miko Mynttinen
2017-04-04 03:59:31 +02:00
parent 37f6ff1795
commit 807dea4bac
2 changed files with 56 additions and 22 deletions

View File

@@ -19,16 +19,18 @@ namespace layers {
class Layer;
// Represents a layer that might have a non-rectangular geometry.
/**
* Represents a layer that might have a non-rectangular geometry.
*/
struct LayerPolygon {
explicit LayerPolygon(Layer *aLayer)
explicit LayerPolygon(Layer* aLayer)
: layer(aLayer) {}
LayerPolygon(Layer *aLayer,
LayerPolygon(Layer* aLayer,
gfx::Polygon&& aGeometry)
: layer(aLayer), geometry(Some(Move(aGeometry))) {}
LayerPolygon(Layer *aLayer,
LayerPolygon(Layer* aLayer,
nsTArray<gfx::Point4D>&& aPoints,
const gfx::Point4D& aNormal)
: layer(aLayer)
@@ -36,7 +38,7 @@ struct LayerPolygon {
geometry.emplace(Move(aPoints), aNormal);
}
Layer *layer;
Layer* layer;
Maybe<gfx::Polygon> geometry;
};
@@ -48,9 +50,11 @@ struct LayerPolygon {
*/
typedef mozilla::ArenaAllocator<4096, 8> BSPTreeArena;
// Represents a node in a BSP tree. The node contains at least one layer with
// associated geometry that is used as a splitting plane, and at most two child
// nodes that represent the splitting planes that further subdivide the space.
/**
* Represents a node in a BSP tree. The node contains at least one layer with
* associated geometry that is used as a splitting plane, and at most two child
* nodes that represent the splitting planes that further subdivide the space.
*/
struct BSPTreeNode {
BSPTreeNode()
: front(nullptr), back(nullptr) {}
@@ -72,13 +76,15 @@ struct BSPTreeNode {
std::list<LayerPolygon> layers;
};
// BSPTree class takes a list of layers as an input and uses binary space
// partitioning algorithm to create a tree structure that can be used for
// depth sorting.
//
// Sources for more information:
// https://en.wikipedia.org/wiki/Binary_space_partitioning
// ftp://ftp.sgi.com/other/bspfaq/faq/bspfaq.html
/**
* BSPTree class takes a list of layers as an input and uses binary space
* partitioning algorithm to create a tree structure that can be used for
* depth sorting.
* Sources for more information:
* https://en.wikipedia.org/wiki/Binary_space_partitioning
* ftp://ftp.sgi.com/other/bspfaq/faq/bspfaq.html
*/
class BSPTree {
public:
/**
@@ -92,7 +98,9 @@ public:
BuildTree(mRoot, aLayers);
}
// Builds and returns the back-to-front draw order for the created BSP tree.
/**
* Builds and returns the back-to-front draw order for the created BSP tree.
*/
nsTArray<LayerPolygon> GetDrawOrder() const
{
nsTArray<LayerPolygon> layers;
@@ -104,8 +112,10 @@ private:
BSPTreeArena mPool;
BSPTreeNode* mRoot;
// BuildDrawOrder and BuildTree are called recursively. The depth of the
// recursion depends on the amount of polygons and their intersections.
/**
* BuildDrawOrder and BuildTree are called recursively. The depth of the
* recursion depends on the amount of polygons and their intersections.
*/
void BuildDrawOrder(BSPTreeNode* aNode,
nsTArray<LayerPolygon>& aLayers) const;