Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Side by Side Diff: src/core/SkRTree.h

Issue 23480002: R-Tree -- Don't sort draw commands unless specified. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: s/order/sort. Changed default rtree to sorted and specified unsorted in factory functions Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkRTree_DEFINED 9 #ifndef SkRTree_DEFINED
10 #define SkRTree_DEFINED 10 #define SkRTree_DEFINED
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * Create a new R-Tree with specified min/max child counts. 48 * Create a new R-Tree with specified min/max child counts.
49 * The child counts are valid iff: 49 * The child counts are valid iff:
50 * - (max + 1) / 2 >= min (splitting an overfull node must be enough to popu late 2 nodes) 50 * - (max + 1) / 2 >= min (splitting an overfull node must be enough to popu late 2 nodes)
51 * - min < max 51 * - min < max
52 * - min > 0 52 * - min > 0
53 * - max < SK_MaxU16 53 * - max < SK_MaxU16
54 * If you have some prior information about the distribution of bounds you'r e expecting, you 54 * If you have some prior information about the distribution of bounds you'r e expecting, you
55 * can provide an optional aspect ratio parameter. This allows the bulk-load algorithm to create 55 * can provide an optional aspect ratio parameter. This allows the bulk-load algorithm to create
56 * better proportioned tiles of rectangles. 56 * better proportioned tiles of rectangles.
57 */ 57 */
58 static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRati o = 1); 58 static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRati o = 1,
59 bool orderWhenBulkLoading = true);
reed1 2013/08/29 19:17:35 add a comment above for this new param?
59 virtual ~SkRTree(); 60 virtual ~SkRTree();
60 61
61 /** 62 /**
62 * Insert a node, consisting of bounds and a data value into the tree, if we don't immediately 63 * Insert a node, consisting of bounds and a data value into the tree, if we don't immediately
63 * need to use the tree; we may allow the insert to be deferred (this can al low us to bulk-load 64 * need to use the tree; we may allow the insert to be deferred (this can al low us to bulk-load
64 * a large batch of nodes at once, which tends to be faster and produce a be tter tree). 65 * a large batch of nodes at once, which tends to be faster and produce a be tter tree).
65 * @param data The data value 66 * @param data The data value
66 * @param bounds The corresponding bounding box 67 * @param bounds The corresponding bounding box
67 * @param defer Can this insert be deferred? (this may be ignored) 68 * @param defer Can this insert be deferred? (this may be ignored)
68 */ 69 */
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 138 }
138 }; 139 };
139 140
140 struct RectLessY { 141 struct RectLessY {
141 bool operator()(const SkRTree::Branch lhs, const SkRTree::Branch rhs) { 142 bool operator()(const SkRTree::Branch lhs, const SkRTree::Branch rhs) {
142 return ((lhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1) < 143 return ((lhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1) <
143 ((rhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1); 144 ((rhs.fBounds.fBottom - lhs.fBounds.fTop) >> 1);
144 } 145 }
145 }; 146 };
146 147
147 SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio); 148 SkRTree(int minChildren, int maxChildren, SkScalar aspectRatio, bool orderWh enBulkLoading);
148 149
149 /** 150 /**
150 * Recursively descend the tree to find an insertion position for 'branch', updates 151 * Recursively descend the tree to find an insertion position for 'branch', updates
151 * bounding boxes on the way up. 152 * bounding boxes on the way up.
152 */ 153 */
153 Branch* insert(Node* root, Branch* branch, uint16_t level = 0); 154 Branch* insert(Node* root, Branch* branch, uint16_t level = 0);
154 155
155 int chooseSubtree(Node* root, Branch* branch); 156 int chooseSubtree(Node* root, Branch* branch);
156 SkIRect computeBounds(Node* n); 157 SkIRect computeBounds(Node* n);
157 int distributeChildren(Branch* children); 158 int distributeChildren(Branch* children);
(...skipping 19 matching lines...) Expand all
177 const int fMaxChildren; 178 const int fMaxChildren;
178 const size_t fNodeSize; 179 const size_t fNodeSize;
179 180
180 // This is the count of data elements (rather than total nodes in the tree) 181 // This is the count of data elements (rather than total nodes in the tree)
181 size_t fCount; 182 size_t fCount;
182 183
183 Branch fRoot; 184 Branch fRoot;
184 SkChunkAlloc fNodes; 185 SkChunkAlloc fNodes;
185 SkTDArray<Branch> fDeferredInserts; 186 SkTDArray<Branch> fDeferredInserts;
186 SkScalar fAspectRatio; 187 SkScalar fAspectRatio;
188 bool fSortWhenBulkLoading;
187 189
188 Node* allocateNode(uint16_t level); 190 Node* allocateNode(uint16_t level);
189 191
190 typedef SkBBoxHierarchy INHERITED; 192 typedef SkBBoxHierarchy INHERITED;
191 }; 193 };
192 194
193 #endif 195 #endif
OLDNEW
« bench/RTreeBench.cpp ('K') | « src/core/SkPicture.cpp ('k') | src/core/SkRTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698