Add optional aspect ratio parameter to R-Tree, this helps the bulk load algorithm create more square tiles.
Review URL: https://codereview.appspot.com/6489102
git-svn-id: http://skia.googlecode.com/svn/trunk@5466 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkRTree.h b/src/core/SkRTree.h
index 756798b..9688159 100644
--- a/src/core/SkRTree.h
+++ b/src/core/SkRTree.h
@@ -50,8 +50,11 @@
* - min < max
* - min > 0
* - max < SK_MaxU16
+ * If you have some prior information about the distribution of bounds you're expecting, you
+ * can provide an optional aspect ratio parameter. This allows the bulk-load algorithm to create
+ * better proportioned tiles of rectangles.
*/
- static SkRTree* Create(int minChildren, int maxChildren);
+ static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRatio = 1);
virtual ~SkRTree();
/**
@@ -129,7 +132,7 @@
((rhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1);
}
- SkRTree(int minChildren, int maxChildren);
+ SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio);
/**
* Recursively descend the tree to find an insertion position for 'branch', updates
@@ -168,6 +171,7 @@
Branch fRoot;
SkChunkAlloc fNodes;
SkTDArray<Branch> fDeferredInserts;
+ SkScalar fAspectRatio;
Node* allocateNode(uint16_t level);